Class: Xolphin::Api::Endpoint::Invoice
- Inherits:
-
Object
- Object
- Xolphin::Api::Endpoint::Invoice
- Defined in:
- lib/xolphin/api/endpoint/invoice.rb
Instance Method Summary collapse
- #all ⇒ Object
- #download(id, type = "PDF") ⇒ Object
- #get(id) ⇒ Object
-
#initialize(http) ⇒ Invoice
constructor
A new instance of Invoice.
Constructor Details
#initialize(http) ⇒ Invoice
Returns a new instance of Invoice.
5 6 7 |
# File 'lib/xolphin/api/endpoint/invoice.rb', line 5 def initialize(http) @http = http end |
Instance Method Details
#all ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/xolphin/api/endpoint/invoice.rb', line 9 def all invoices = [] result = @http.get("/invoices", page: 1) response = Xolphin::Api::Responses::Invoices.new(result) unless response.error? invoices = response.invoices while response.page < response.pages result = @http.get("/invoices", page: response.page + 1) response = Xolphin::Api::Responses::Invoices.new(result) break if response.error? invoices += response.invoices end end invoices end |
#download(id, type = "PDF") ⇒ Object
34 35 36 |
# File 'lib/xolphin/api/endpoint/invoice.rb', line 34 def download(id, type = "PDF") @http.download("/invoices/#{id}/download", type: type) end |