gocardless_pro 2.17.1 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gocardless_pro.rb +3 -0
- data/lib/gocardless_pro/client.rb +6 -1
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +1 -2
- data/lib/gocardless_pro/resources/currency_exchange_rate.rb +44 -0
- data/lib/gocardless_pro/resources/customer_notification.rb +3 -5
- data/lib/gocardless_pro/resources/event.rb +2 -1
- data/lib/gocardless_pro/resources/mandate_import.rb +5 -8
- data/lib/gocardless_pro/resources/mandate_import_entry.rb +3 -5
- data/lib/gocardless_pro/resources/payout.rb +2 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +2 -0
- data/lib/gocardless_pro/resources/subscription.rb +38 -29
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +67 -0
- data/lib/gocardless_pro/services/customers_service.rb +1 -2
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +81 -5
- data/lib/gocardless_pro/services/mandates_service.rb +1 -1
- data/lib/gocardless_pro/services/payouts_service.rb +21 -0
- data/lib/gocardless_pro/services/subscriptions_service.rb +129 -0
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/resources/currency_exchange_rate_spec.rb +103 -0
- data/spec/resources/instalment_schedule_spec.rb +193 -1
- data/spec/resources/payout_spec.rb +45 -0
- data/spec/resources/redirect_flow_spec.rb +9 -0
- data/spec/resources/subscription_spec.rb +210 -0
- data/spec/services/currency_exchange_rates_service_spec.rb +223 -0
- data/spec/services/instalment_schedules_service_spec.rb +270 -1
- data/spec/services/payouts_service_spec.rb +74 -0
- data/spec/services/redirect_flows_service_spec.rb +9 -0
- data/spec/services/subscriptions_service_spec.rb +240 -0
- metadata +9 -3
@@ -26,6 +26,7 @@ describe GoCardlessPro::Resources::Payout do
|
|
26
26
|
'fx' => 'fx-input',
|
27
27
|
'id' => 'id-input',
|
28
28
|
'links' => 'links-input',
|
29
|
+
'metadata' => 'metadata-input',
|
29
30
|
'payout_type' => 'payout_type-input',
|
30
31
|
'reference' => 'reference-input',
|
31
32
|
'status' => 'status-input',
|
@@ -58,6 +59,8 @@ describe GoCardlessPro::Resources::Payout do
|
|
58
59
|
|
59
60
|
expect(get_list_response.records.first.id).to eq('id-input')
|
60
61
|
|
62
|
+
expect(get_list_response.records.first.metadata).to eq('metadata-input')
|
63
|
+
|
61
64
|
expect(get_list_response.records.first.payout_type).to eq('payout_type-input')
|
62
65
|
|
63
66
|
expect(get_list_response.records.first.reference).to eq('reference-input')
|
@@ -88,6 +91,7 @@ describe GoCardlessPro::Resources::Payout do
|
|
88
91
|
'fx' => 'fx-input',
|
89
92
|
'id' => 'id-input',
|
90
93
|
'links' => 'links-input',
|
94
|
+
'metadata' => 'metadata-input',
|
91
95
|
'payout_type' => 'payout_type-input',
|
92
96
|
'reference' => 'reference-input',
|
93
97
|
'status' => 'status-input',
|
@@ -114,6 +118,7 @@ describe GoCardlessPro::Resources::Payout do
|
|
114
118
|
'fx' => 'fx-input',
|
115
119
|
'id' => 'id-input',
|
116
120
|
'links' => 'links-input',
|
121
|
+
'metadata' => 'metadata-input',
|
117
122
|
'payout_type' => 'payout_type-input',
|
118
123
|
'reference' => 'reference-input',
|
119
124
|
'status' => 'status-input',
|
@@ -156,6 +161,7 @@ describe GoCardlessPro::Resources::Payout do
|
|
156
161
|
'fx' => 'fx-input',
|
157
162
|
'id' => 'id-input',
|
158
163
|
'links' => 'links-input',
|
164
|
+
'metadata' => 'metadata-input',
|
159
165
|
'payout_type' => 'payout_type-input',
|
160
166
|
'reference' => 'reference-input',
|
161
167
|
'status' => 'status-input',
|
@@ -192,6 +198,7 @@ describe GoCardlessPro::Resources::Payout do
|
|
192
198
|
'fx' => 'fx-input',
|
193
199
|
'id' => 'id-input',
|
194
200
|
'links' => 'links-input',
|
201
|
+
'metadata' => 'metadata-input',
|
195
202
|
'payout_type' => 'payout_type-input',
|
196
203
|
'reference' => 'reference-input',
|
197
204
|
'status' => 'status-input',
|
@@ -228,4 +235,42 @@ describe GoCardlessPro::Resources::Payout do
|
|
228
235
|
end
|
229
236
|
end
|
230
237
|
end
|
238
|
+
|
239
|
+
describe '#update' do
|
240
|
+
subject(:put_update_response) { client.payouts.update(id, params: update_params) }
|
241
|
+
let(:id) { 'ABC123' }
|
242
|
+
|
243
|
+
context 'with a valid request' do
|
244
|
+
let(:update_params) { { 'hello' => 'world' } }
|
245
|
+
|
246
|
+
let!(:stub) do
|
247
|
+
stub_url = '/payouts/:identity'.gsub(':identity', id)
|
248
|
+
stub_request(:put, /.*api.gocardless.com#{stub_url}/).to_return(
|
249
|
+
body: {
|
250
|
+
'payouts' => {
|
251
|
+
|
252
|
+
'amount' => 'amount-input',
|
253
|
+
'arrival_date' => 'arrival_date-input',
|
254
|
+
'created_at' => 'created_at-input',
|
255
|
+
'currency' => 'currency-input',
|
256
|
+
'deducted_fees' => 'deducted_fees-input',
|
257
|
+
'fx' => 'fx-input',
|
258
|
+
'id' => 'id-input',
|
259
|
+
'links' => 'links-input',
|
260
|
+
'metadata' => 'metadata-input',
|
261
|
+
'payout_type' => 'payout_type-input',
|
262
|
+
'reference' => 'reference-input',
|
263
|
+
'status' => 'status-input',
|
264
|
+
},
|
265
|
+
}.to_json,
|
266
|
+
headers: response_headers
|
267
|
+
)
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'updates and returns the resource' do
|
271
|
+
expect(put_update_response).to be_a(GoCardlessPro::Resources::Payout)
|
272
|
+
expect(stub).to have_been_requested
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
231
276
|
end
|
@@ -20,6 +20,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
20
20
|
'description' => 'description-input',
|
21
21
|
'id' => 'id-input',
|
22
22
|
'links' => 'links-input',
|
23
|
+
'metadata' => 'metadata-input',
|
23
24
|
'redirect_url' => 'redirect_url-input',
|
24
25
|
'scheme' => 'scheme-input',
|
25
26
|
'session_token' => 'session_token-input',
|
@@ -38,6 +39,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
38
39
|
'description' => 'description-input',
|
39
40
|
'id' => 'id-input',
|
40
41
|
'links' => 'links-input',
|
42
|
+
'metadata' => 'metadata-input',
|
41
43
|
'redirect_url' => 'redirect_url-input',
|
42
44
|
'scheme' => 'scheme-input',
|
43
45
|
'session_token' => 'session_token-input',
|
@@ -56,6 +58,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
56
58
|
'description' => 'description-input',
|
57
59
|
'id' => 'id-input',
|
58
60
|
'links' => 'links-input',
|
61
|
+
'metadata' => 'metadata-input',
|
59
62
|
'redirect_url' => 'redirect_url-input',
|
60
63
|
'scheme' => 'scheme-input',
|
61
64
|
'session_token' => 'session_token-input',
|
@@ -107,6 +110,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
107
110
|
'description' => 'description-input',
|
108
111
|
'id' => 'id-input',
|
109
112
|
'links' => 'links-input',
|
113
|
+
'metadata' => 'metadata-input',
|
110
114
|
'redirect_url' => 'redirect_url-input',
|
111
115
|
'scheme' => 'scheme-input',
|
112
116
|
'session_token' => 'session_token-input',
|
@@ -148,6 +152,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
148
152
|
'description' => 'description-input',
|
149
153
|
'id' => 'id-input',
|
150
154
|
'links' => 'links-input',
|
155
|
+
'metadata' => 'metadata-input',
|
151
156
|
'redirect_url' => 'redirect_url-input',
|
152
157
|
'scheme' => 'scheme-input',
|
153
158
|
'session_token' => 'session_token-input',
|
@@ -185,6 +190,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
185
190
|
'description' => 'description-input',
|
186
191
|
'id' => 'id-input',
|
187
192
|
'links' => 'links-input',
|
193
|
+
'metadata' => 'metadata-input',
|
188
194
|
'redirect_url' => 'redirect_url-input',
|
189
195
|
'scheme' => 'scheme-input',
|
190
196
|
'session_token' => 'session_token-input',
|
@@ -219,6 +225,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
219
225
|
'description' => 'description-input',
|
220
226
|
'id' => 'id-input',
|
221
227
|
'links' => 'links-input',
|
228
|
+
'metadata' => 'metadata-input',
|
222
229
|
'redirect_url' => 'redirect_url-input',
|
223
230
|
'scheme' => 'scheme-input',
|
224
231
|
'session_token' => 'session_token-input',
|
@@ -274,6 +281,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
274
281
|
'description' => 'description-input',
|
275
282
|
'id' => 'id-input',
|
276
283
|
'links' => 'links-input',
|
284
|
+
'metadata' => 'metadata-input',
|
277
285
|
'redirect_url' => 'redirect_url-input',
|
278
286
|
'scheme' => 'scheme-input',
|
279
287
|
'session_token' => 'session_token-input',
|
@@ -313,6 +321,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
313
321
|
'description' => 'description-input',
|
314
322
|
'id' => 'id-input',
|
315
323
|
'links' => 'links-input',
|
324
|
+
'metadata' => 'metadata-input',
|
316
325
|
'redirect_url' => 'redirect_url-input',
|
317
326
|
'scheme' => 'scheme-input',
|
318
327
|
'session_token' => 'session_token-input',
|
@@ -17,9 +17,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
17
17
|
|
18
18
|
'amount' => 'amount-input',
|
19
19
|
'app_fee' => 'app_fee-input',
|
20
|
+
'count' => 'count-input',
|
20
21
|
'created_at' => 'created_at-input',
|
21
22
|
'currency' => 'currency-input',
|
22
23
|
'day_of_month' => 'day_of_month-input',
|
24
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
23
25
|
'end_date' => 'end_date-input',
|
24
26
|
'id' => 'id-input',
|
25
27
|
'interval' => 'interval-input',
|
@@ -44,9 +46,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
44
46
|
|
45
47
|
'amount' => 'amount-input',
|
46
48
|
'app_fee' => 'app_fee-input',
|
49
|
+
'count' => 'count-input',
|
47
50
|
'created_at' => 'created_at-input',
|
48
51
|
'currency' => 'currency-input',
|
49
52
|
'day_of_month' => 'day_of_month-input',
|
53
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
50
54
|
'end_date' => 'end_date-input',
|
51
55
|
'id' => 'id-input',
|
52
56
|
'interval' => 'interval-input',
|
@@ -71,9 +75,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
71
75
|
|
72
76
|
'amount' => 'amount-input',
|
73
77
|
'app_fee' => 'app_fee-input',
|
78
|
+
'count' => 'count-input',
|
74
79
|
'created_at' => 'created_at-input',
|
75
80
|
'currency' => 'currency-input',
|
76
81
|
'day_of_month' => 'day_of_month-input',
|
82
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
77
83
|
'end_date' => 'end_date-input',
|
78
84
|
'id' => 'id-input',
|
79
85
|
'interval' => 'interval-input',
|
@@ -131,9 +137,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
131
137
|
|
132
138
|
'amount' => 'amount-input',
|
133
139
|
'app_fee' => 'app_fee-input',
|
140
|
+
'count' => 'count-input',
|
134
141
|
'created_at' => 'created_at-input',
|
135
142
|
'currency' => 'currency-input',
|
136
143
|
'day_of_month' => 'day_of_month-input',
|
144
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
137
145
|
'end_date' => 'end_date-input',
|
138
146
|
'id' => 'id-input',
|
139
147
|
'interval' => 'interval-input',
|
@@ -181,9 +189,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
181
189
|
|
182
190
|
'amount' => 'amount-input',
|
183
191
|
'app_fee' => 'app_fee-input',
|
192
|
+
'count' => 'count-input',
|
184
193
|
'created_at' => 'created_at-input',
|
185
194
|
'currency' => 'currency-input',
|
186
195
|
'day_of_month' => 'day_of_month-input',
|
196
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
187
197
|
'end_date' => 'end_date-input',
|
188
198
|
'id' => 'id-input',
|
189
199
|
'interval' => 'interval-input',
|
@@ -222,9 +232,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
222
232
|
|
223
233
|
'amount' => 'amount-input',
|
224
234
|
'app_fee' => 'app_fee-input',
|
235
|
+
'count' => 'count-input',
|
225
236
|
'created_at' => 'created_at-input',
|
226
237
|
'currency' => 'currency-input',
|
227
238
|
'day_of_month' => 'day_of_month-input',
|
239
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
228
240
|
'end_date' => 'end_date-input',
|
229
241
|
'id' => 'id-input',
|
230
242
|
'interval' => 'interval-input',
|
@@ -257,12 +269,16 @@ describe GoCardlessPro::Resources::Subscription do
|
|
257
269
|
|
258
270
|
expect(get_list_response.records.first.app_fee).to eq('app_fee-input')
|
259
271
|
|
272
|
+
expect(get_list_response.records.first.count).to eq('count-input')
|
273
|
+
|
260
274
|
expect(get_list_response.records.first.created_at).to eq('created_at-input')
|
261
275
|
|
262
276
|
expect(get_list_response.records.first.currency).to eq('currency-input')
|
263
277
|
|
264
278
|
expect(get_list_response.records.first.day_of_month).to eq('day_of_month-input')
|
265
279
|
|
280
|
+
expect(get_list_response.records.first.earliest_charge_date_after_resume).to eq('earliest_charge_date_after_resume-input')
|
281
|
+
|
266
282
|
expect(get_list_response.records.first.end_date).to eq('end_date-input')
|
267
283
|
|
268
284
|
expect(get_list_response.records.first.id).to eq('id-input')
|
@@ -305,9 +321,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
305
321
|
|
306
322
|
'amount' => 'amount-input',
|
307
323
|
'app_fee' => 'app_fee-input',
|
324
|
+
'count' => 'count-input',
|
308
325
|
'created_at' => 'created_at-input',
|
309
326
|
'currency' => 'currency-input',
|
310
327
|
'day_of_month' => 'day_of_month-input',
|
328
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
311
329
|
'end_date' => 'end_date-input',
|
312
330
|
'id' => 'id-input',
|
313
331
|
'interval' => 'interval-input',
|
@@ -338,9 +356,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
338
356
|
|
339
357
|
'amount' => 'amount-input',
|
340
358
|
'app_fee' => 'app_fee-input',
|
359
|
+
'count' => 'count-input',
|
341
360
|
'created_at' => 'created_at-input',
|
342
361
|
'currency' => 'currency-input',
|
343
362
|
'day_of_month' => 'day_of_month-input',
|
363
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
344
364
|
'end_date' => 'end_date-input',
|
345
365
|
'id' => 'id-input',
|
346
366
|
'interval' => 'interval-input',
|
@@ -387,9 +407,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
387
407
|
|
388
408
|
'amount' => 'amount-input',
|
389
409
|
'app_fee' => 'app_fee-input',
|
410
|
+
'count' => 'count-input',
|
390
411
|
'created_at' => 'created_at-input',
|
391
412
|
'currency' => 'currency-input',
|
392
413
|
'day_of_month' => 'day_of_month-input',
|
414
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
393
415
|
'end_date' => 'end_date-input',
|
394
416
|
'id' => 'id-input',
|
395
417
|
'interval' => 'interval-input',
|
@@ -430,9 +452,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
430
452
|
|
431
453
|
'amount' => 'amount-input',
|
432
454
|
'app_fee' => 'app_fee-input',
|
455
|
+
'count' => 'count-input',
|
433
456
|
'created_at' => 'created_at-input',
|
434
457
|
'currency' => 'currency-input',
|
435
458
|
'day_of_month' => 'day_of_month-input',
|
459
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
436
460
|
'end_date' => 'end_date-input',
|
437
461
|
'id' => 'id-input',
|
438
462
|
'interval' => 'interval-input',
|
@@ -495,9 +519,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
495
519
|
|
496
520
|
'amount' => 'amount-input',
|
497
521
|
'app_fee' => 'app_fee-input',
|
522
|
+
'count' => 'count-input',
|
498
523
|
'created_at' => 'created_at-input',
|
499
524
|
'currency' => 'currency-input',
|
500
525
|
'day_of_month' => 'day_of_month-input',
|
526
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
501
527
|
'end_date' => 'end_date-input',
|
502
528
|
'id' => 'id-input',
|
503
529
|
'interval' => 'interval-input',
|
@@ -524,6 +550,186 @@ describe GoCardlessPro::Resources::Subscription do
|
|
524
550
|
end
|
525
551
|
end
|
526
552
|
|
553
|
+
describe '#pause' do
|
554
|
+
subject(:post_response) { client.subscriptions.pause(resource_id) }
|
555
|
+
|
556
|
+
let(:resource_id) { 'ABC123' }
|
557
|
+
|
558
|
+
let!(:stub) do
|
559
|
+
# /subscriptions/%v/actions/pause
|
560
|
+
stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
|
561
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
562
|
+
body: {
|
563
|
+
'subscriptions' => {
|
564
|
+
|
565
|
+
'amount' => 'amount-input',
|
566
|
+
'app_fee' => 'app_fee-input',
|
567
|
+
'count' => 'count-input',
|
568
|
+
'created_at' => 'created_at-input',
|
569
|
+
'currency' => 'currency-input',
|
570
|
+
'day_of_month' => 'day_of_month-input',
|
571
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
572
|
+
'end_date' => 'end_date-input',
|
573
|
+
'id' => 'id-input',
|
574
|
+
'interval' => 'interval-input',
|
575
|
+
'interval_unit' => 'interval_unit-input',
|
576
|
+
'links' => 'links-input',
|
577
|
+
'metadata' => 'metadata-input',
|
578
|
+
'month' => 'month-input',
|
579
|
+
'name' => 'name-input',
|
580
|
+
'payment_reference' => 'payment_reference-input',
|
581
|
+
'retry_if_possible' => 'retry_if_possible-input',
|
582
|
+
'start_date' => 'start_date-input',
|
583
|
+
'status' => 'status-input',
|
584
|
+
'upcoming_payments' => 'upcoming_payments-input',
|
585
|
+
},
|
586
|
+
}.to_json,
|
587
|
+
headers: response_headers
|
588
|
+
)
|
589
|
+
end
|
590
|
+
|
591
|
+
it 'wraps the response and calls the right endpoint' do
|
592
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::Subscription)
|
593
|
+
|
594
|
+
expect(stub).to have_been_requested
|
595
|
+
end
|
596
|
+
|
597
|
+
context 'when the request needs a body and custom header' do
|
598
|
+
let(:body) { { foo: 'bar' } }
|
599
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
600
|
+
subject(:post_response) { client.subscriptions.pause(resource_id, body, headers) }
|
601
|
+
|
602
|
+
let(:resource_id) { 'ABC123' }
|
603
|
+
|
604
|
+
let!(:stub) do
|
605
|
+
# /subscriptions/%v/actions/pause
|
606
|
+
stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
|
607
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
608
|
+
with(
|
609
|
+
body: { foo: 'bar' },
|
610
|
+
headers: { 'Foo' => 'Bar' }
|
611
|
+
).to_return(
|
612
|
+
body: {
|
613
|
+
'subscriptions' => {
|
614
|
+
|
615
|
+
'amount' => 'amount-input',
|
616
|
+
'app_fee' => 'app_fee-input',
|
617
|
+
'count' => 'count-input',
|
618
|
+
'created_at' => 'created_at-input',
|
619
|
+
'currency' => 'currency-input',
|
620
|
+
'day_of_month' => 'day_of_month-input',
|
621
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
622
|
+
'end_date' => 'end_date-input',
|
623
|
+
'id' => 'id-input',
|
624
|
+
'interval' => 'interval-input',
|
625
|
+
'interval_unit' => 'interval_unit-input',
|
626
|
+
'links' => 'links-input',
|
627
|
+
'metadata' => 'metadata-input',
|
628
|
+
'month' => 'month-input',
|
629
|
+
'name' => 'name-input',
|
630
|
+
'payment_reference' => 'payment_reference-input',
|
631
|
+
'retry_if_possible' => 'retry_if_possible-input',
|
632
|
+
'start_date' => 'start_date-input',
|
633
|
+
'status' => 'status-input',
|
634
|
+
'upcoming_payments' => 'upcoming_payments-input',
|
635
|
+
},
|
636
|
+
}.to_json,
|
637
|
+
headers: response_headers
|
638
|
+
)
|
639
|
+
end
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
describe '#resume' do
|
644
|
+
subject(:post_response) { client.subscriptions.resume(resource_id) }
|
645
|
+
|
646
|
+
let(:resource_id) { 'ABC123' }
|
647
|
+
|
648
|
+
let!(:stub) do
|
649
|
+
# /subscriptions/%v/actions/resume
|
650
|
+
stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
|
651
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
652
|
+
body: {
|
653
|
+
'subscriptions' => {
|
654
|
+
|
655
|
+
'amount' => 'amount-input',
|
656
|
+
'app_fee' => 'app_fee-input',
|
657
|
+
'count' => 'count-input',
|
658
|
+
'created_at' => 'created_at-input',
|
659
|
+
'currency' => 'currency-input',
|
660
|
+
'day_of_month' => 'day_of_month-input',
|
661
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
662
|
+
'end_date' => 'end_date-input',
|
663
|
+
'id' => 'id-input',
|
664
|
+
'interval' => 'interval-input',
|
665
|
+
'interval_unit' => 'interval_unit-input',
|
666
|
+
'links' => 'links-input',
|
667
|
+
'metadata' => 'metadata-input',
|
668
|
+
'month' => 'month-input',
|
669
|
+
'name' => 'name-input',
|
670
|
+
'payment_reference' => 'payment_reference-input',
|
671
|
+
'retry_if_possible' => 'retry_if_possible-input',
|
672
|
+
'start_date' => 'start_date-input',
|
673
|
+
'status' => 'status-input',
|
674
|
+
'upcoming_payments' => 'upcoming_payments-input',
|
675
|
+
},
|
676
|
+
}.to_json,
|
677
|
+
headers: response_headers
|
678
|
+
)
|
679
|
+
end
|
680
|
+
|
681
|
+
it 'wraps the response and calls the right endpoint' do
|
682
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::Subscription)
|
683
|
+
|
684
|
+
expect(stub).to have_been_requested
|
685
|
+
end
|
686
|
+
|
687
|
+
context 'when the request needs a body and custom header' do
|
688
|
+
let(:body) { { foo: 'bar' } }
|
689
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
690
|
+
subject(:post_response) { client.subscriptions.resume(resource_id, body, headers) }
|
691
|
+
|
692
|
+
let(:resource_id) { 'ABC123' }
|
693
|
+
|
694
|
+
let!(:stub) do
|
695
|
+
# /subscriptions/%v/actions/resume
|
696
|
+
stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
|
697
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
698
|
+
with(
|
699
|
+
body: { foo: 'bar' },
|
700
|
+
headers: { 'Foo' => 'Bar' }
|
701
|
+
).to_return(
|
702
|
+
body: {
|
703
|
+
'subscriptions' => {
|
704
|
+
|
705
|
+
'amount' => 'amount-input',
|
706
|
+
'app_fee' => 'app_fee-input',
|
707
|
+
'count' => 'count-input',
|
708
|
+
'created_at' => 'created_at-input',
|
709
|
+
'currency' => 'currency-input',
|
710
|
+
'day_of_month' => 'day_of_month-input',
|
711
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
712
|
+
'end_date' => 'end_date-input',
|
713
|
+
'id' => 'id-input',
|
714
|
+
'interval' => 'interval-input',
|
715
|
+
'interval_unit' => 'interval_unit-input',
|
716
|
+
'links' => 'links-input',
|
717
|
+
'metadata' => 'metadata-input',
|
718
|
+
'month' => 'month-input',
|
719
|
+
'name' => 'name-input',
|
720
|
+
'payment_reference' => 'payment_reference-input',
|
721
|
+
'retry_if_possible' => 'retry_if_possible-input',
|
722
|
+
'start_date' => 'start_date-input',
|
723
|
+
'status' => 'status-input',
|
724
|
+
'upcoming_payments' => 'upcoming_payments-input',
|
725
|
+
},
|
726
|
+
}.to_json,
|
727
|
+
headers: response_headers
|
728
|
+
)
|
729
|
+
end
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
527
733
|
describe '#cancel' do
|
528
734
|
subject(:post_response) { client.subscriptions.cancel(resource_id) }
|
529
735
|
|
@@ -538,9 +744,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
538
744
|
|
539
745
|
'amount' => 'amount-input',
|
540
746
|
'app_fee' => 'app_fee-input',
|
747
|
+
'count' => 'count-input',
|
541
748
|
'created_at' => 'created_at-input',
|
542
749
|
'currency' => 'currency-input',
|
543
750
|
'day_of_month' => 'day_of_month-input',
|
751
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
544
752
|
'end_date' => 'end_date-input',
|
545
753
|
'id' => 'id-input',
|
546
754
|
'interval' => 'interval-input',
|
@@ -586,9 +794,11 @@ describe GoCardlessPro::Resources::Subscription do
|
|
586
794
|
|
587
795
|
'amount' => 'amount-input',
|
588
796
|
'app_fee' => 'app_fee-input',
|
797
|
+
'count' => 'count-input',
|
589
798
|
'created_at' => 'created_at-input',
|
590
799
|
'currency' => 'currency-input',
|
591
800
|
'day_of_month' => 'day_of_month-input',
|
801
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
592
802
|
'end_date' => 'end_date-input',
|
593
803
|
'id' => 'id-input',
|
594
804
|
'interval' => 'interval-input',
|