gocardless_pro 2.18.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +25 -43
- data/Gemfile +7 -0
- data/gocardless_pro.gemspec +2 -2
- data/lib/gocardless_pro/api_service.rb +1 -1
- data/lib/gocardless_pro/client.rb +1 -1
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +1 -2
- 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 +36 -29
- data/lib/gocardless_pro/services/customers_service.rb +1 -2
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +21 -0
- 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/instalment_schedule_spec.rb +35 -0
- data/spec/resources/payout_spec.rb +45 -0
- data/spec/resources/redirect_flow_spec.rb +9 -0
- data/spec/resources/subscription_spec.rb +195 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +1 -1
- data/spec/services/customer_bank_accounts_service_spec.rb +1 -1
- data/spec/services/customer_notifications_service_spec.rb +1 -1
- data/spec/services/customers_service_spec.rb +1 -1
- data/spec/services/instalment_schedules_service_spec.rb +61 -1
- data/spec/services/mandate_imports_service_spec.rb +2 -2
- data/spec/services/mandates_service_spec.rb +2 -2
- data/spec/services/payments_service_spec.rb +2 -2
- data/spec/services/payouts_service_spec.rb +74 -0
- data/spec/services/redirect_flows_service_spec.rb +10 -1
- data/spec/services/subscriptions_service_spec.rb +222 -1
- metadata +7 -8
- data/gocardless_pro-2.17.1.gem +0 -0
@@ -529,6 +529,41 @@ describe GoCardlessPro::Resources::InstalmentSchedule do
|
|
529
529
|
end
|
530
530
|
end
|
531
531
|
|
532
|
+
describe '#update' do
|
533
|
+
subject(:put_update_response) { client.instalment_schedules.update(id, params: update_params) }
|
534
|
+
let(:id) { 'ABC123' }
|
535
|
+
|
536
|
+
context 'with a valid request' do
|
537
|
+
let(:update_params) { { 'hello' => 'world' } }
|
538
|
+
|
539
|
+
let!(:stub) do
|
540
|
+
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
|
541
|
+
stub_request(:put, /.*api.gocardless.com#{stub_url}/).to_return(
|
542
|
+
body: {
|
543
|
+
'instalment_schedules' => {
|
544
|
+
|
545
|
+
'created_at' => 'created_at-input',
|
546
|
+
'currency' => 'currency-input',
|
547
|
+
'id' => 'id-input',
|
548
|
+
'links' => 'links-input',
|
549
|
+
'metadata' => 'metadata-input',
|
550
|
+
'name' => 'name-input',
|
551
|
+
'payment_errors' => 'payment_errors-input',
|
552
|
+
'status' => 'status-input',
|
553
|
+
'total_amount' => 'total_amount-input',
|
554
|
+
},
|
555
|
+
}.to_json,
|
556
|
+
headers: response_headers
|
557
|
+
)
|
558
|
+
end
|
559
|
+
|
560
|
+
it 'updates and returns the resource' do
|
561
|
+
expect(put_update_response).to be_a(GoCardlessPro::Resources::InstalmentSchedule)
|
562
|
+
expect(stub).to have_been_requested
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
532
567
|
describe '#cancel' do
|
533
568
|
subject(:post_response) { client.instalment_schedules.cancel(resource_id) }
|
534
569
|
|
@@ -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',
|
@@ -21,6 +21,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
21
21
|
'created_at' => 'created_at-input',
|
22
22
|
'currency' => 'currency-input',
|
23
23
|
'day_of_month' => 'day_of_month-input',
|
24
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
24
25
|
'end_date' => 'end_date-input',
|
25
26
|
'id' => 'id-input',
|
26
27
|
'interval' => 'interval-input',
|
@@ -49,6 +50,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
49
50
|
'created_at' => 'created_at-input',
|
50
51
|
'currency' => 'currency-input',
|
51
52
|
'day_of_month' => 'day_of_month-input',
|
53
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
52
54
|
'end_date' => 'end_date-input',
|
53
55
|
'id' => 'id-input',
|
54
56
|
'interval' => 'interval-input',
|
@@ -77,6 +79,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
77
79
|
'created_at' => 'created_at-input',
|
78
80
|
'currency' => 'currency-input',
|
79
81
|
'day_of_month' => 'day_of_month-input',
|
82
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
80
83
|
'end_date' => 'end_date-input',
|
81
84
|
'id' => 'id-input',
|
82
85
|
'interval' => 'interval-input',
|
@@ -138,6 +141,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
138
141
|
'created_at' => 'created_at-input',
|
139
142
|
'currency' => 'currency-input',
|
140
143
|
'day_of_month' => 'day_of_month-input',
|
144
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
141
145
|
'end_date' => 'end_date-input',
|
142
146
|
'id' => 'id-input',
|
143
147
|
'interval' => 'interval-input',
|
@@ -189,6 +193,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
189
193
|
'created_at' => 'created_at-input',
|
190
194
|
'currency' => 'currency-input',
|
191
195
|
'day_of_month' => 'day_of_month-input',
|
196
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
192
197
|
'end_date' => 'end_date-input',
|
193
198
|
'id' => 'id-input',
|
194
199
|
'interval' => 'interval-input',
|
@@ -231,6 +236,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
231
236
|
'created_at' => 'created_at-input',
|
232
237
|
'currency' => 'currency-input',
|
233
238
|
'day_of_month' => 'day_of_month-input',
|
239
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
234
240
|
'end_date' => 'end_date-input',
|
235
241
|
'id' => 'id-input',
|
236
242
|
'interval' => 'interval-input',
|
@@ -271,6 +277,8 @@ describe GoCardlessPro::Resources::Subscription do
|
|
271
277
|
|
272
278
|
expect(get_list_response.records.first.day_of_month).to eq('day_of_month-input')
|
273
279
|
|
280
|
+
expect(get_list_response.records.first.earliest_charge_date_after_resume).to eq('earliest_charge_date_after_resume-input')
|
281
|
+
|
274
282
|
expect(get_list_response.records.first.end_date).to eq('end_date-input')
|
275
283
|
|
276
284
|
expect(get_list_response.records.first.id).to eq('id-input')
|
@@ -317,6 +325,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
317
325
|
'created_at' => 'created_at-input',
|
318
326
|
'currency' => 'currency-input',
|
319
327
|
'day_of_month' => 'day_of_month-input',
|
328
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
320
329
|
'end_date' => 'end_date-input',
|
321
330
|
'id' => 'id-input',
|
322
331
|
'interval' => 'interval-input',
|
@@ -351,6 +360,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
351
360
|
'created_at' => 'created_at-input',
|
352
361
|
'currency' => 'currency-input',
|
353
362
|
'day_of_month' => 'day_of_month-input',
|
363
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
354
364
|
'end_date' => 'end_date-input',
|
355
365
|
'id' => 'id-input',
|
356
366
|
'interval' => 'interval-input',
|
@@ -401,6 +411,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
401
411
|
'created_at' => 'created_at-input',
|
402
412
|
'currency' => 'currency-input',
|
403
413
|
'day_of_month' => 'day_of_month-input',
|
414
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
404
415
|
'end_date' => 'end_date-input',
|
405
416
|
'id' => 'id-input',
|
406
417
|
'interval' => 'interval-input',
|
@@ -445,6 +456,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
445
456
|
'created_at' => 'created_at-input',
|
446
457
|
'currency' => 'currency-input',
|
447
458
|
'day_of_month' => 'day_of_month-input',
|
459
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
448
460
|
'end_date' => 'end_date-input',
|
449
461
|
'id' => 'id-input',
|
450
462
|
'interval' => 'interval-input',
|
@@ -511,6 +523,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
511
523
|
'created_at' => 'created_at-input',
|
512
524
|
'currency' => 'currency-input',
|
513
525
|
'day_of_month' => 'day_of_month-input',
|
526
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
514
527
|
'end_date' => 'end_date-input',
|
515
528
|
'id' => 'id-input',
|
516
529
|
'interval' => 'interval-input',
|
@@ -537,6 +550,186 @@ describe GoCardlessPro::Resources::Subscription do
|
|
537
550
|
end
|
538
551
|
end
|
539
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
|
+
|
540
733
|
describe '#cancel' do
|
541
734
|
subject(:post_response) { client.subscriptions.cancel(resource_id) }
|
542
735
|
|
@@ -555,6 +748,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
555
748
|
'created_at' => 'created_at-input',
|
556
749
|
'currency' => 'currency-input',
|
557
750
|
'day_of_month' => 'day_of_month-input',
|
751
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
558
752
|
'end_date' => 'end_date-input',
|
559
753
|
'id' => 'id-input',
|
560
754
|
'interval' => 'interval-input',
|
@@ -604,6 +798,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
604
798
|
'created_at' => 'created_at-input',
|
605
799
|
'currency' => 'currency-input',
|
606
800
|
'day_of_month' => 'day_of_month-input',
|
801
|
+
'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
|
607
802
|
'end_date' => 'end_date-input',
|
608
803
|
'id' => 'id-input',
|
609
804
|
'interval' => 'interval-input',
|