Class: XtractSDK::Client
- Inherits:
-
Object
- Object
- XtractSDK::Client
- Defined in:
- lib/xtract_sdk/client.rb
Instance Method Summary collapse
-
#initialize(api_key: nil) ⇒ Client
constructor
A new instance of Client.
- #invoice(id) ⇒ Object
- #invoices(params = {}) ⇒ Object
- #update_invoice(id, options) ⇒ Object
- #update_invoices(ids, options) ⇒ Object
Constructor Details
Instance Method Details
#invoice(id) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/xtract_sdk/client.rb', line 13 def invoice(id) response = HTTPClient.invoice(id, @api_key) Error.raise_from_code!(response.code) if response.code != 200 # TODO: use dry-rb structs instead of OpenStruct JSON.parse(response.body.to_s, object_class: OpenStruct) # rubocop:disable Style/OpenStructUse end |
#invoices(params = {}) ⇒ Object
9 10 11 |
# File 'lib/xtract_sdk/client.rb', line 9 def invoices(params = {}) XtractSDK::Invoices::RequestBuilder.new(@api_key, params) end |
#update_invoice(id, options) ⇒ Object
20 21 22 23 24 |
# File 'lib/xtract_sdk/client.rb', line 20 def update_invoice(id, ) response = HTTPClient.update_invoice(id, , @api_key) Error.raise_from_code!(response.code) if response.code != 200 :ok end |
#update_invoices(ids, options) ⇒ Object
26 27 28 29 30 |
# File 'lib/xtract_sdk/client.rb', line 26 def update_invoices(ids, ) response = HTTPClient.update_invoices(ids, , @api_key) Error.raise_from_code!(response.code) if response.code != 200 :ok end |