Class: Vatsense::Resources::Invoice::Item
- Inherits:
-
Object
- Object
- Vatsense::Resources::Invoice::Item
- Defined in:
- lib/vatsense/resources/invoice/item.rb
Overview
VAT-compliant invoice management
Instance Method Summary collapse
-
#add(invoice_id, items:, request_options: {}) ⇒ Vatsense::Models::InvoiceResponse
Add one or more line items to an existing invoice.
-
#delete(item_id, invoice_id:, request_options: {}) ⇒ Vatsense::Models::InvoiceResponse
Remove a specific line item from an invoice.
-
#initialize(client:) ⇒ Item
constructor
private
A new instance of Item.
-
#retrieve(item_id, invoice_id:, request_options: {}) ⇒ Vatsense::Models::Invoice::ItemRetrieveResponse
Retrieve a specific line item from an invoice.
-
#update(item_id, invoice_id:, item:, price_each:, quantity:, vat_rate:, discount_rate: nil, request_options: {}) ⇒ Vatsense::Models::InvoiceResponse
Update a specific line item on an invoice.
Constructor Details
#initialize(client:) ⇒ Item
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Item.
127 128 129 |
# File 'lib/vatsense/resources/invoice/item.rb', line 127 def initialize(client:) @client = client end |
Instance Method Details
#add(invoice_id, items:, request_options: {}) ⇒ Vatsense::Models::InvoiceResponse
Add one or more line items to an existing invoice.
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/vatsense/resources/invoice/item.rb', line 113 def add(invoice_id, params) parsed, = Vatsense::Invoice::ItemAddParams.dump_request(params) @client.request( method: :post, path: ["invoice/%1$s/item", invoice_id], body: parsed, model: Vatsense::InvoiceResponse, options: ) end |
#delete(item_id, invoice_id:, request_options: {}) ⇒ Vatsense::Models::InvoiceResponse
Remove a specific line item from an invoice.
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/vatsense/resources/invoice/item.rb', line 86 def delete(item_id, params) parsed, = Vatsense::Invoice::ItemDeleteParams.dump_request(params) invoice_id = parsed.delete(:invoice_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["invoice/%1$s/item/%2$s", invoice_id, item_id], model: Vatsense::InvoiceResponse, options: ) end |
#retrieve(item_id, invoice_id:, request_options: {}) ⇒ Vatsense::Models::Invoice::ItemRetrieveResponse
Retrieve a specific line item from an invoice.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vatsense/resources/invoice/item.rb', line 21 def retrieve(item_id, params) parsed, = Vatsense::Invoice::ItemRetrieveParams.dump_request(params) invoice_id = parsed.delete(:invoice_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["invoice/%1$s/item/%2$s", invoice_id, item_id], model: Vatsense::Models::Invoice::ItemRetrieveResponse, options: ) end |
#update(item_id, invoice_id:, item:, price_each:, quantity:, vat_rate:, discount_rate: nil, request_options: {}) ⇒ Vatsense::Models::InvoiceResponse
Update a specific line item on an invoice.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/vatsense/resources/invoice/item.rb', line 58 def update(item_id, params) parsed, = Vatsense::Invoice::ItemUpdateParams.dump_request(params) invoice_id = parsed.delete(:invoice_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :patch, path: ["invoice/%1$s/item/%2$s", invoice_id, item_id], body: parsed, model: Vatsense::InvoiceResponse, options: ) end |