From 4eb1353821cf50d16bff0122938cdcba216efb60 Mon Sep 17 00:00:00 2001 From: Petr Kopac Date: Fri, 19 May 2017 12:45:50 +0200 Subject: [PATCH] [DP-309] support for Delete Invoice (#23) --- lib/chartmogul/invoice.js | 4 +++- package.json | 2 +- test/chartmogul/invoice.js | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/chartmogul/invoice.js b/lib/chartmogul/invoice.js index 830ffcb..044e3b6 100644 --- a/lib/chartmogul/invoice.js +++ b/lib/chartmogul/invoice.js @@ -5,7 +5,7 @@ const Resource = require('./resource.js'); class Invoice extends Resource { static get path () { - return '/v1/import/customers/{customerUuid}/invoices{/invoiceUuid}'; + return '/v1/import/customers/{customerUuid}/invoices'; } } @@ -21,4 +21,6 @@ Invoice.all = function (config, params, cb) { } }; +Invoice.destroy = Resource._method('DELETE', '/v1/invoices{/uuid}'); + module.exports = Invoice; diff --git a/package.json b/package.json index e3f6915..233a2e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chartmogul-node", - "version": "1.0.3", + "version": "1.0.4", "description": "Official Chartmogul API Node.js Client", "main": "lib/chartmogul.js", "scripts": { diff --git a/test/chartmogul/invoice.js b/test/chartmogul/invoice.js index 31c9a98..f3aedeb 100644 --- a/test/chartmogul/invoice.js +++ b/test/chartmogul/invoice.js @@ -216,4 +216,15 @@ describe('Invoices', () => { expect(res.invoices[0].external_id).to.equal('INV0001'); }); }); + + it('should delete an invoice', () => { + nock(config.API_BASE) + .delete('/v1/invoices/inv_cff3a63c-3915-435e-a675-85a8a8ef4454') + .reply(204, {}); + + return Invoice.destroy(config, 'inv_cff3a63c-3915-435e-a675-85a8a8ef4454') + .then(res => { + expect(res).to.be.deep.equal({}); + }); + }); });