File tree 2 files changed +48
-4
lines changed
2 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,19 @@ var stripeMethod = require('../StripeMethod');
4
4
5
5
module . exports = require ( '../StripeResource' ) . extend ( {
6
6
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
+
10
13
delete reqArgs . subscription_item ;
14
+
15
+ args . unshift ( reqArgs ) ;
16
+
11
17
return stripeMethod ( {
12
18
method : 'POST' ,
13
19
path : requestPath
14
- } ) . bind ( this ) ( reqArgs ) ;
20
+ } ) . apply ( this , args ) ;
15
21
}
16
22
} ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ describe('UsageRecords Resource', function() {
12
12
timestmap : 123321 ,
13
13
action : 'increment'
14
14
} ) ;
15
+
15
16
expect ( stripe . LAST_REQUEST ) . to . deep . equal ( {
16
17
method : 'POST' ,
17
18
url : '/v1/subscription_items/si_123/usage_records' ,
@@ -23,5 +24,42 @@ describe('UsageRecords Resource', function() {
23
24
}
24
25
} ) ;
25
26
} ) ;
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
+ } ) ;
26
64
} ) ;
27
65
} ) ;
You can’t perform that action at this time.
0 commit comments