diff --git a/lib/resources/UsageRecordSummaries.js b/lib/resources/UsageRecordSummaries.js new file mode 100644 index 0000000000..afa89b6d91 --- /dev/null +++ b/lib/resources/UsageRecordSummaries.js @@ -0,0 +1,14 @@ +'use strict'; + +var StripeResource = require('../StripeResource'); +var stripeMethod = StripeResource.method; + +module.exports = StripeResource.extend({ + path: 'subscription_items', + + list: stripeMethod({ + method: 'GET', + path: '{subscriptionItem}/usage_record_summaries', + urlParams: ['subscriptionItem'], + }), +}); diff --git a/lib/stripe.js b/lib/stripe.js index ddaa83000f..59032e65c6 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -68,6 +68,7 @@ var resources = { Topups: require('./resources/Topups'), Transfers: require('./resources/Transfers'), UsageRecords: require('./resources/UsageRecords'), + UsageRecordSummaries: require('./resources/UsageRecordSummaries'), // The following rely on pre-filled IDs: ApplicationFeeRefunds: require('./resources/ApplicationFeeRefunds'), diff --git a/test/resources/UsageRecordSummaries.spec.js b/test/resources/UsageRecordSummaries.spec.js new file mode 100644 index 0000000000..4569708e6b --- /dev/null +++ b/test/resources/UsageRecordSummaries.spec.js @@ -0,0 +1,42 @@ +'use strict'; + +var stripe = require('../testUtils').getSpyableStripe(); +var expect = require('chai').expect; + +describe('UsageRecordSummaries Resource', function() { + describe('list', function() { + it('Sends the correct request', function() { + stripe.usageRecordSummaries.list('si_123', {}); + + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/subscription_items/si_123/usage_record_summaries', + headers: {}, + data: {} + }); + }); + + it('Includes any options that were provided', function(done) { + stripe.usageRecordSummaries.list('si_123', {}, { + stripe_account: 'acct_456', + }).then(function(record) { + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/subscription_items/si_123/usage_record_summaries', + headers: { + 'Stripe-Account': 'acct_456' + }, + data: {} + }); + + done(); + }); + }); + + it('Calls a given callback', function(done) { + stripe.usageRecordSummaries.list('si_123', {}, function(error, record) { + done(error); + }); + }); + }); +});