Class: Craigslist::API::Resources::Billing
- Defined in:
- lib/craigslist/api/resources/billing.rb
Overview
Account credit, prepaid posting blocks, pricing, and invoicing.
Constant Summary
Constants inherited from Base
Craigslist::API::Resources::Base::BASE_PATH, Craigslist::API::Resources::Base::RESERVED
Instance Method Summary collapse
-
#create_invoice ⇒ Array<String>
Invoices everything not yet invoiced, ahead of the normal cycle.
- #credit ⇒ CreditSummary
-
#posting_blocks ⇒ Array<PostingBlock>
Prepaid blocks still available, per area and product.
-
#pricing(area:, category:) ⇒ Money?
Current cost of posting in an area and category.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Craigslist::API::Resources::Base
Instance Method Details
#create_invoice ⇒ Array<String>
Invoices everything not yet invoiced, ahead of the normal cycle.
40 41 42 43 |
# File 'lib/craigslist/api/resources/billing.rb', line 40 def create_invoice data = transport.post(path("account", "billing", "make-invoice")).data || {} Array(data["invoiceIDs"]).map(&:to_s) end |
#credit ⇒ CreditSummary
9 10 11 |
# File 'lib/craigslist/api/resources/billing.rb', line 9 def credit CreditSummary.from(transport.get(path("account", "billing", "credit")).data) end |
#posting_blocks ⇒ Array<PostingBlock>
Prepaid blocks still available, per area and product.
16 17 18 19 |
# File 'lib/craigslist/api/resources/billing.rb', line 16 def posting_blocks Array(transport.get(path("account", "billing", "posting-block-balances")).data) .map { |entry| PostingBlock.from(entry) } end |
#pricing(area:, category:) ⇒ Money?
Current cost of posting in an area and category.
Prices can change without notice, so treat the result as a quote rather than something to cache.
29 30 31 32 33 34 35 |
# File 'lib/craigslist/api/resources/billing.rb', line 29 def pricing(area:, category:) data = transport.get( path("account", "billing", "current-pricing", "area", area, "category", category) ).data || {} Money.from(data["currentPricing"]) end |