Class: Io::Flow::V0::Clients::ConsumerInvoices
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ConsumerInvoices
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_key(organization, key) ⇒ Object
- #delete_credit_and_memos_by_invoice_key_and_key(organization, invoice_key, key) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_key(organization, key) ⇒ Object
-
#initialize(client) ⇒ ConsumerInvoices
constructor
A new instance of ConsumerInvoices.
-
#post_credit_and_memos_by_invoice_key(organization, invoice_key, credit_memo_form) ⇒ Object
Creates a credit memo against this invoice.
-
#post_exports(organization, invoice_export_form) ⇒ Object
Creates an export of the consumer/invoices.
- #put_by_key(organization, key, consumer_invoice_form) ⇒ Object
-
#put_credit_and_memos_by_invoice_key_and_key(organization, invoice_key, key, credit_memo_form) ⇒ Object
Upserts a credit memo against this invoice.
- #put_order_by_number(organization, number, consumer_invoice_form_by_order) ⇒ Object
Constructor Details
#initialize(client) ⇒ ConsumerInvoices
Returns a new instance of ConsumerInvoices.
5421 5422 5423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5421 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
5498 5499 5500 5501 5502 5503 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5498 def delete_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/#{CGI.escape(key)}").delete nil end |
#delete_credit_and_memos_by_invoice_key_and_key(organization, invoice_key, key) ⇒ Object
5475 5476 5477 5478 5479 5480 5481 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5475 def delete_credit_and_memos_by_invoice_key_and_key(organization, invoice_key, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('invoice_key', invoice_key, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/#{CGI.escape(invoice_key)}/credit/memos/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5425 def get(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String)), :order_number => (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String)), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/consumer/invoices").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ConsumerInvoice.new(x) } end |
#get_by_key(organization, key) ⇒ Object
5483 5484 5485 5486 5487 5488 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5483 def get_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::ConsumerInvoice.new(r) end |
#post_credit_and_memos_by_invoice_key(organization, invoice_key, credit_memo_form) ⇒ Object
Creates a credit memo against this invoice
5457 5458 5459 5460 5461 5462 5463 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5457 def post_credit_and_memos_by_invoice_key(organization, invoice_key, credit_memo_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('invoice_key', invoice_key, String) (x = credit_memo_form; x.is_a?(::Io::Flow::V0::Models::CreditMemoForm) ? x : ::Io::Flow::V0::Models::CreditMemoForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/#{CGI.escape(invoice_key)}/credit/memos").with_json(credit_memo_form.to_json).post ::Io::Flow::V0::Models::CreditMemo.new(r) end |
#post_exports(organization, invoice_export_form) ⇒ Object
Creates an export of the consumer/invoices
5441 5442 5443 5444 5445 5446 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5441 def post_exports(organization, invoice_export_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = invoice_export_form; x.is_a?(::Io::Flow::V0::Models::InvoiceExportForm) ? x : ::Io::Flow::V0::Models::InvoiceExportForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/exports").with_json(invoice_export_form.to_json).post ::Io::Flow::V0::Models::InvoiceExport.new(r) end |
#put_by_key(organization, key, consumer_invoice_form) ⇒ Object
5490 5491 5492 5493 5494 5495 5496 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5490 def put_by_key(organization, key, consumer_invoice_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = consumer_invoice_form; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceForm) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/#{CGI.escape(key)}").with_json(consumer_invoice_form.to_json).put ::Io::Flow::V0::Models::ConsumerInvoice.new(r) end |
#put_credit_and_memos_by_invoice_key_and_key(organization, invoice_key, key, credit_memo_form) ⇒ Object
Upserts a credit memo against this invoice
5466 5467 5468 5469 5470 5471 5472 5473 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5466 def put_credit_and_memos_by_invoice_key_and_key(organization, invoice_key, key, credit_memo_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('invoice_key', invoice_key, String) HttpClient::Preconditions.assert_class('key', key, String) (x = credit_memo_form; x.is_a?(::Io::Flow::V0::Models::CreditMemoForm) ? x : ::Io::Flow::V0::Models::CreditMemoForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/#{CGI.escape(invoice_key)}/credit/memos/#{CGI.escape(key)}").with_json(credit_memo_form.to_json).put ::Io::Flow::V0::Models::CreditMemo.new(r) end |
#put_order_by_number(organization, number, consumer_invoice_form_by_order) ⇒ Object
5448 5449 5450 5451 5452 5453 5454 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5448 def put_order_by_number(organization, number, consumer_invoice_form_by_order) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) (x = consumer_invoice_form_by_order; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceFormByOrder) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceFormByOrder.new(x)) r = @client.request("/#{CGI.escape(organization)}/consumer/invoices/order/#{CGI.escape(number)}").with_json(consumer_invoice_form_by_order.to_json).put r.map { |x| ::Io::Flow::V0::Models::ConsumerInvoice.new(x) } end |