Skip to content

Commit

Permalink
Merge pull request #588 from stripe/remi-add-tax-rates
Browse files Browse the repository at this point in the history
Add support for the TaxRate resource and APIs
  • Loading branch information
remi-stripe authored Apr 24, 2019
2 parents 7917688 + a1c629b commit 9993232
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/resources/TaxRates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = require('../StripeResource').extend({
path: 'tax_rates',
includeBasic: ['create', 'list', 'update', 'retrieve'],
});

1 change: 1 addition & 0 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
63 changes: 63 additions & 0 deletions test/resources/TaxRates.spec.js
Original file line number Diff line number Diff line change
@@ -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: {},
});
});
});
});

0 comments on commit 9993232

Please sign in to comment.