Sha256: 59932ba4253a2494a1c198ed4f165576cba7016d8addb47e9b9e128c8941795a
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
require 'forwardable' module ChartMogul class CustomerInvoices < APIResource extend Forwardable include Enumerable set_resource_name 'Invoices' set_resource_path '/v1/import/customers/:customer_uuid/invoices' writeable_attr :invoices, default: [] writeable_attr :customer_uuid include API::Actions::All include API::Actions::Create include Concerns::Pageable2 def serialize_invoices map(&:serialize_for_write) end def self.all(customer_uuid, options = {}) super(options.merge(customer_uuid: customer_uuid)) end def_delegators :invoices, :each, :[], :<<, :size, :length, :empty?, :first private # TODO: replace with Entries concern? def set_invoices(invoices_attributes) @invoices = invoices_attributes.map.with_index do |invoice_attributes, index| existing_invoice = invoices[index] if existing_invoice existing_invoice.assign_all_attributes(invoice_attributes) else Invoice.new_from_json(invoice_attributes) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
chartmogul-ruby-1.1.5 | lib/chartmogul/customer_invoices.rb |
chartmogul-ruby-1.1.4 | lib/chartmogul/customer_invoices.rb |
chartmogul-ruby-1.1.2 | lib/chartmogul/customer_invoices.rb |