Skip to content

Commit

Permalink
Adding List Invoices endpoint with spec (#39)
Browse files Browse the repository at this point in the history
* Adding List Invoices endpoint with spec

* version 1.1.1

* Customer_uuid now on invoice in this case
  • Loading branch information
pkopac authored May 2, 2017
1 parent d705af1 commit e5cc193
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions lib/chartmogul/invoice.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ChartMogul
class Invoice < ChartMogul::Object
readonly_attr :uuid
readonly_attr :customer_uuid

writeable_attr :date, type: :time
writeable_attr :currency
Expand Down Expand Up @@ -58,5 +59,20 @@ def transaction_class(type)
when 'refund' then ChartMogul::Transactions::Refund
end
end

def self.all(options = {})
Invoices.all(options)
end
end
class Invoices < APIResource
set_resource_name 'Invoices'
set_resource_path '/v1/invoices'

set_resource_root_key :invoices

include Concerns::Entries
include Concerns::Pageable2

set_entry_class Invoice
end
end
2 changes: 1 addition & 1 deletion lib/chartmogul/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ChartMogul
VERSION = "1.1.0"
VERSION = "1.1.1"
end
10 changes: 10 additions & 0 deletions spec/chartmogul/invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,14 @@
)
end
end
describe 'API Interactions', vcr: true do
it 'returns all invoices through list all endpoint', uses_api: true do
invoices = described_class.all(per_page: 10, external_id: "invoice_eid")
expect(invoices.instance_of? ChartMogul::Invoices).to be true
expect(invoices.size).to eq 1
expect(invoices[0].instance_of? described_class).to be true
expect(invoices[0].external_id).to eq "invoice_eid"
expect(invoices[0].customer_uuid).to eq "customer_uuid"
end
end
end

0 comments on commit e5cc193

Please sign in to comment.