Skip to content

Commit

Permalink
[DP-468] Retrieve Invoice endpoint (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkopac authored May 26, 2017
1 parent 4eb1353 commit 0781c60
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ ChartMogul.Plan.destroy(config, uuid)
```js
ChartMogul.Invoice.create(config, customerUuid, data)
ChartMogul.Invoice.all(config, customerUuid, query)
ChartMogul.Invoice.all(config, query)
ChartMogul.Invoice.retrieve(config, invoiceUuid)
```

#### [Transactions](https://dev.chartmogul.com/docs/transactions)
Expand Down
3 changes: 3 additions & 0 deletions lib/chartmogul/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Invoice extends Resource {

// @Override
Invoice.all_customer = Invoice.all;

Invoice.all_any = Resource._method('GET', '/v1/invoices');

Invoice.all = function (config, params, cb) {
Expand All @@ -23,4 +24,6 @@ Invoice.all = function (config, params, cb) {

Invoice.destroy = Resource._method('DELETE', '/v1/invoices{/uuid}');

Invoice.retrieve = Resource._method('GET', '/v1/invoices{/uuid}');

module.exports = Invoice;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chartmogul-node",
"version": "1.0.4",
"version": "1.0.5",
"description": "Official Chartmogul API Node.js Client",
"main": "lib/chartmogul.js",
"scripts": {
Expand Down
12 changes: 12 additions & 0 deletions test/chartmogul/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,16 @@ describe('Invoices', () => {
expect(res).to.be.deep.equal({});
});
});

it('should retrieve an invoice', () => {
var payload = {external_id: 'some_invoice_id'};
nock(config.API_BASE)
.get('/v1/invoices/inv_cff3a63c-3915-435e-a675-85a8a8ef4454')
.reply(200, payload);

return Invoice.retrieve(config, 'inv_cff3a63c-3915-435e-a675-85a8a8ef4454')
.then(res => {
expect(res).to.be.deep.equal(payload);
});
});
});

0 comments on commit 0781c60

Please sign in to comment.