From a1c629be41c0e6adeb02d898ccc617dddf18da48 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Tue, 9 Apr 2019 15:30:40 -0700 Subject: [PATCH] Add support for the TaxRate resource and APIs --- lib/resources/TaxRates.js | 7 ++++ lib/stripe.js | 1 + test/resources/TaxRates.spec.js | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 lib/resources/TaxRates.js create mode 100644 test/resources/TaxRates.spec.js diff --git a/lib/resources/TaxRates.js b/lib/resources/TaxRates.js new file mode 100644 index 0000000000..7bea8e7f33 --- /dev/null +++ b/lib/resources/TaxRates.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = require('../StripeResource').extend({ + path: 'tax_rates', + includeBasic: ['create', 'list', 'update', 'retrieve'], +}); + diff --git a/lib/stripe.js b/lib/stripe.js index f19f571d4a..727202f379 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -72,6 +72,7 @@ var resources = { SubscriptionItems: require('./resources/SubscriptionItems'), SubscriptionSchedules: require('./resources/SubscriptionSchedules'), Subscriptions: require('./resources/Subscriptions'), + TaxRates: require('./resources/TaxRates'), ThreeDSecure: require('./resources/ThreeDSecure'), Tokens: require('./resources/Tokens'), Topups: require('./resources/Topups'), diff --git a/test/resources/TaxRates.spec.js b/test/resources/TaxRates.spec.js new file mode 100644 index 0000000000..74e931b29b --- /dev/null +++ b/test/resources/TaxRates.spec.js @@ -0,0 +1,63 @@ +'use strict'; + +var stripe = require('../../testUtils').getSpyableStripe(); +var expect = require('chai').expect; + +describe('TaxRates Resource', function() { + describe('retrieve', function() { + it('Sends the correct request', function() { + stripe.taxRates.retrieve('txr_123'); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/tax_rates/txr_123', + headers: {}, + data: {}, + }); + }); + }); + + describe('update', function() { + it('Sends the correct request', function() { + var data = { + metadata: {a: '1234'}, + }; + stripe.taxRates.update('txr_123', data); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'POST', + url: '/v1/tax_rates/txr_123', + headers: {}, + data: data, + }); + }); + }); + + describe('create', function() { + it('Sends the correct request', function() { + var data = { + display_name: 'name', + inclusive: false, + percentage: 10.15, + }; + stripe.taxRates.create(data); + + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'POST', + url: '/v1/tax_rates', + headers: {}, + data: data, + }); + }); + }); + + describe('list', function() { + it('Sends the correct request', function() { + stripe.taxRates.list(); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/tax_rates', + headers: {}, + data: {}, + }); + }); + }); +});