File tree Expand file tree Collapse file tree 2 files changed +48
-4
lines changed Top Open diff view settings Expand file tree Collapse file tree 2 files changed +48
-4
lines changed Top Open diff view settings Original file line number Diff line number Diff line change @@ -4,13 +4,19 @@ var stripeMethod = require('../StripeMethod');
44
55module . exports = require ( '../StripeResource' ) . extend ( {
66 path : 'subscription_items' ,
7- create : function ( args ) {
8- var requestPath = args . subscription_item + '/usage_records' ;
9- var reqArgs = Object . assign ( { } , args ) ;
7+ create : function ( ) {
8+ var args = Array . prototype . slice . call ( arguments ) ;
9+
10+ var reqArgs = args . shift ( ) ;
11+ var requestPath = reqArgs . subscription_item + '/usage_records' ;
12+
1013 delete reqArgs . subscription_item ;
14+
15+ args . unshift ( reqArgs ) ;
16+
1117 return stripeMethod ( {
1218 method : 'POST' ,
1319 path : requestPath
14- } ) . bind ( this ) ( reqArgs ) ;
20+ } ) . apply ( this , args ) ;
1521 }
1622} ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ describe('UsageRecords Resource', function() {
1212 timestmap : 123321 ,
1313 action : 'increment'
1414 } ) ;
15+
1516 expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
1617 method : 'POST' ,
1718 url : '/v1/subscription_items/si_123/usage_records' ,
@@ -23,5 +24,42 @@ describe('UsageRecords Resource', function() {
2324 }
2425 } ) ;
2526 } ) ;
27+
28+ it ( 'Includes any options that were provided' , function ( done ) {
29+ stripe . usageRecords . create ( {
30+ subscription_item : 'si_123' ,
31+ quantity : 123 ,
32+ timestmap : 123321 ,
33+ action : 'increment'
34+ } , {
35+ stripe_account : 'acct_456' ,
36+ } ) . then ( function ( record ) {
37+ expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
38+ method : 'POST' ,
39+ url : '/v1/subscription_items/si_123/usage_records' ,
40+ headers : {
41+ "Stripe-Account" : "acct_456"
42+ } ,
43+ data : {
44+ quantity : 123 ,
45+ timestmap : 123321 ,
46+ action : 'increment'
47+ }
48+ } ) ;
49+
50+ done ( ) ;
51+ } ) ;
52+ } ) ;
53+
54+ it ( 'Calls a given callback' , function ( done ) {
55+ stripe . usageRecords . create ( {
56+ subscription_item : 'si_123' ,
57+ quantity : 123 ,
58+ timestmap : 123321 ,
59+ action : 'increment'
60+ } , function ( error , record ) {
61+ done ( error ) ;
62+ } ) ;
63+ } ) ;
2664 } ) ;
2765} ) ;
You can’t perform that action at this time.
0 commit comments