gocardless_pro 2.27.0 → 2.30.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 +20 -1
- data/lib/gocardless_pro/api_service.rb +4 -0
- data/lib/gocardless_pro/client.rb +11 -1
- data/lib/gocardless_pro/error/authentication_error.rb +4 -0
- data/lib/gocardless_pro/error/permission_error.rb +4 -0
- data/lib/gocardless_pro/error/rate_limit_error.rb +4 -0
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +12 -1
- data/lib/gocardless_pro/resources/bank_authorisation.rb +3 -9
- data/lib/gocardless_pro/resources/billing_request.rb +31 -7
- data/lib/gocardless_pro/resources/billing_request_flow.rb +14 -0
- data/lib/gocardless_pro/resources/billing_request_template.rb +68 -0
- data/lib/gocardless_pro/resources/block.rb +76 -0
- data/lib/gocardless_pro/resources/event.rb +20 -0
- data/lib/gocardless_pro/resources/institution.rb +7 -1
- data/lib/gocardless_pro/resources/payer_authorisation.rb +9 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +6 -0
- data/lib/gocardless_pro/services/bank_authorisations_service.rb +0 -2
- data/lib/gocardless_pro/services/billing_request_flows_service.rb +23 -0
- data/lib/gocardless_pro/services/billing_request_templates_service.rb +131 -0
- data/lib/gocardless_pro/services/billing_requests_service.rb +89 -24
- data/lib/gocardless_pro/services/blocks_service.rb +223 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +1 -5
- data/lib/gocardless_pro/services/creditors_service.rb +1 -3
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +1 -1
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +1 -5
- data/lib/gocardless_pro/services/customers_service.rb +1 -3
- data/lib/gocardless_pro/services/events_service.rb +1 -1
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +1 -7
- data/lib/gocardless_pro/services/institutions_service.rb +2 -2
- data/lib/gocardless_pro/services/mandate_import_entries_service.rb +1 -1
- data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -6
- data/lib/gocardless_pro/services/mandates_service.rb +1 -7
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +0 -6
- data/lib/gocardless_pro/services/payments_service.rb +1 -7
- data/lib/gocardless_pro/services/payout_items_service.rb +1 -1
- data/lib/gocardless_pro/services/payouts_service.rb +1 -1
- data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -4
- data/lib/gocardless_pro/services/refunds_service.rb +1 -3
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +28 -6
- data/lib/gocardless_pro/services/subscriptions_service.rb +3 -11
- data/lib/gocardless_pro/services/tax_rates_service.rb +1 -1
- data/lib/gocardless_pro/services/webhooks_service.rb +1 -3
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro.rb +9 -0
- data/spec/api_service_spec.rb +12 -1
- data/spec/middlewares/raise_gocardless_errors_spec.rb +30 -0
- data/spec/resources/bank_authorisation_spec.rb +7 -7
- data/spec/resources/billing_request_flow_spec.rb +104 -0
- data/spec/resources/billing_request_spec.rb +183 -29
- data/spec/resources/billing_request_template_spec.rb +502 -0
- data/spec/resources/block_spec.rb +577 -0
- data/spec/resources/creditor_bank_account_spec.rb +2 -0
- data/spec/resources/customer_bank_account_spec.rb +2 -0
- data/spec/resources/customer_notification_spec.rb +2 -0
- data/spec/resources/customer_spec.rb +2 -0
- data/spec/resources/instalment_schedule_spec.rb +2 -0
- data/spec/resources/institution_spec.rb +5 -0
- data/spec/resources/mandate_import_spec.rb +4 -0
- data/spec/resources/mandate_spec.rb +4 -0
- data/spec/resources/payer_authorisation_spec.rb +4 -0
- data/spec/resources/payment_spec.rb +4 -0
- data/spec/resources/redirect_flow_spec.rb +11 -0
- data/spec/resources/scenario_simulator_spec.rb +2 -0
- data/spec/resources/subscription_spec.rb +6 -0
- data/spec/resources/webhook_spec.rb +2 -0
- data/spec/services/bank_authorisations_service_spec.rb +7 -20
- data/spec/services/billing_request_flows_service_spec.rb +115 -0
- data/spec/services/billing_request_templates_service_spec.rb +789 -0
- data/spec/services/billing_requests_service_spec.rb +210 -47
- data/spec/services/blocks_service_spec.rb +840 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +2 -13
- data/spec/services/creditors_service_spec.rb +0 -13
- data/spec/services/customer_bank_accounts_service_spec.rb +2 -13
- data/spec/services/customer_notifications_service_spec.rb +2 -0
- data/spec/services/customers_service_spec.rb +2 -13
- data/spec/services/instalment_schedules_service_spec.rb +2 -26
- data/spec/services/institutions_service_spec.rb +9 -0
- data/spec/services/mandate_imports_service_spec.rb +4 -13
- data/spec/services/mandates_service_spec.rb +4 -13
- data/spec/services/payer_authorisations_service_spec.rb +4 -13
- data/spec/services/payments_service_spec.rb +4 -13
- data/spec/services/redirect_flows_service_spec.rb +11 -13
- data/spec/services/refunds_service_spec.rb +0 -13
- data/spec/services/scenario_simulators_service_spec.rb +2 -0
- data/spec/services/subscriptions_service_spec.rb +6 -13
- data/spec/services/webhooks_service_spec.rb +2 -0
- metadata +18 -3
@@ -231,6 +231,7 @@ describe GoCardlessPro::Resources::MandateImport do
|
|
231
231
|
# /mandate_imports/%v/actions/submit
|
232
232
|
stub_url = '/mandate_imports/:identity/actions/submit'.gsub(':identity', resource_id)
|
233
233
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
234
|
+
|
234
235
|
body: {
|
235
236
|
'mandate_imports' => {
|
236
237
|
|
@@ -240,6 +241,7 @@ describe GoCardlessPro::Resources::MandateImport do
|
|
240
241
|
'status' => 'status-input',
|
241
242
|
},
|
242
243
|
}.to_json,
|
244
|
+
|
243
245
|
headers: response_headers
|
244
246
|
)
|
245
247
|
end
|
@@ -289,6 +291,7 @@ describe GoCardlessPro::Resources::MandateImport do
|
|
289
291
|
# /mandate_imports/%v/actions/cancel
|
290
292
|
stub_url = '/mandate_imports/:identity/actions/cancel'.gsub(':identity', resource_id)
|
291
293
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
294
|
+
|
292
295
|
body: {
|
293
296
|
'mandate_imports' => {
|
294
297
|
|
@@ -298,6 +301,7 @@ describe GoCardlessPro::Resources::MandateImport do
|
|
298
301
|
'status' => 'status-input',
|
299
302
|
},
|
300
303
|
}.to_json,
|
304
|
+
|
301
305
|
headers: response_headers
|
302
306
|
)
|
303
307
|
end
|
@@ -416,6 +416,7 @@ describe GoCardlessPro::Resources::Mandate do
|
|
416
416
|
# /mandates/%v/actions/cancel
|
417
417
|
stub_url = '/mandates/:identity/actions/cancel'.gsub(':identity', resource_id)
|
418
418
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
419
|
+
|
419
420
|
body: {
|
420
421
|
'mandates' => {
|
421
422
|
|
@@ -430,6 +431,7 @@ describe GoCardlessPro::Resources::Mandate do
|
|
430
431
|
'status' => 'status-input',
|
431
432
|
},
|
432
433
|
}.to_json,
|
434
|
+
|
433
435
|
headers: response_headers
|
434
436
|
)
|
435
437
|
end
|
@@ -484,6 +486,7 @@ describe GoCardlessPro::Resources::Mandate do
|
|
484
486
|
# /mandates/%v/actions/reinstate
|
485
487
|
stub_url = '/mandates/:identity/actions/reinstate'.gsub(':identity', resource_id)
|
486
488
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
489
|
+
|
487
490
|
body: {
|
488
491
|
'mandates' => {
|
489
492
|
|
@@ -498,6 +501,7 @@ describe GoCardlessPro::Resources::Mandate do
|
|
498
501
|
'status' => 'status-input',
|
499
502
|
},
|
500
503
|
}.to_json,
|
504
|
+
|
501
505
|
headers: response_headers
|
502
506
|
)
|
503
507
|
end
|
@@ -293,6 +293,7 @@ describe GoCardlessPro::Resources::PayerAuthorisation do
|
|
293
293
|
# /payer_authorisations/%v/actions/submit
|
294
294
|
stub_url = '/payer_authorisations/:identity/actions/submit'.gsub(':identity', resource_id)
|
295
295
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
296
|
+
|
296
297
|
body: {
|
297
298
|
'payer_authorisations' => {
|
298
299
|
|
@@ -306,6 +307,7 @@ describe GoCardlessPro::Resources::PayerAuthorisation do
|
|
306
307
|
'status' => 'status-input',
|
307
308
|
},
|
308
309
|
}.to_json,
|
310
|
+
|
309
311
|
headers: response_headers
|
310
312
|
)
|
311
313
|
end
|
@@ -359,6 +361,7 @@ describe GoCardlessPro::Resources::PayerAuthorisation do
|
|
359
361
|
# /payer_authorisations/%v/actions/confirm
|
360
362
|
stub_url = '/payer_authorisations/:identity/actions/confirm'.gsub(':identity', resource_id)
|
361
363
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
364
|
+
|
362
365
|
body: {
|
363
366
|
'payer_authorisations' => {
|
364
367
|
|
@@ -372,6 +375,7 @@ describe GoCardlessPro::Resources::PayerAuthorisation do
|
|
372
375
|
'status' => 'status-input',
|
373
376
|
},
|
374
377
|
}.to_json,
|
378
|
+
|
375
379
|
headers: response_headers
|
376
380
|
)
|
377
381
|
end
|
@@ -468,6 +468,7 @@ describe GoCardlessPro::Resources::Payment do
|
|
468
468
|
# /payments/%v/actions/cancel
|
469
469
|
stub_url = '/payments/:identity/actions/cancel'.gsub(':identity', resource_id)
|
470
470
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
471
|
+
|
471
472
|
body: {
|
472
473
|
'payments' => {
|
473
474
|
|
@@ -486,6 +487,7 @@ describe GoCardlessPro::Resources::Payment do
|
|
486
487
|
'status' => 'status-input',
|
487
488
|
},
|
488
489
|
}.to_json,
|
490
|
+
|
489
491
|
headers: response_headers
|
490
492
|
)
|
491
493
|
end
|
@@ -544,6 +546,7 @@ describe GoCardlessPro::Resources::Payment do
|
|
544
546
|
# /payments/%v/actions/retry
|
545
547
|
stub_url = '/payments/:identity/actions/retry'.gsub(':identity', resource_id)
|
546
548
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
549
|
+
|
547
550
|
body: {
|
548
551
|
'payments' => {
|
549
552
|
|
@@ -562,6 +565,7 @@ describe GoCardlessPro::Resources::Payment do
|
|
562
565
|
'status' => 'status-input',
|
563
566
|
},
|
564
567
|
}.to_json,
|
568
|
+
|
565
569
|
headers: response_headers
|
566
570
|
)
|
567
571
|
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
|
+
'mandate_reference' => 'mandate_reference-input',
|
23
24
|
'metadata' => 'metadata-input',
|
24
25
|
'redirect_url' => 'redirect_url-input',
|
25
26
|
'scheme' => 'scheme-input',
|
@@ -39,6 +40,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
39
40
|
'description' => 'description-input',
|
40
41
|
'id' => 'id-input',
|
41
42
|
'links' => 'links-input',
|
43
|
+
'mandate_reference' => 'mandate_reference-input',
|
42
44
|
'metadata' => 'metadata-input',
|
43
45
|
'redirect_url' => 'redirect_url-input',
|
44
46
|
'scheme' => 'scheme-input',
|
@@ -58,6 +60,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
58
60
|
'description' => 'description-input',
|
59
61
|
'id' => 'id-input',
|
60
62
|
'links' => 'links-input',
|
63
|
+
'mandate_reference' => 'mandate_reference-input',
|
61
64
|
'metadata' => 'metadata-input',
|
62
65
|
'redirect_url' => 'redirect_url-input',
|
63
66
|
'scheme' => 'scheme-input',
|
@@ -110,6 +113,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
110
113
|
'description' => 'description-input',
|
111
114
|
'id' => 'id-input',
|
112
115
|
'links' => 'links-input',
|
116
|
+
'mandate_reference' => 'mandate_reference-input',
|
113
117
|
'metadata' => 'metadata-input',
|
114
118
|
'redirect_url' => 'redirect_url-input',
|
115
119
|
'scheme' => 'scheme-input',
|
@@ -152,6 +156,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
152
156
|
'description' => 'description-input',
|
153
157
|
'id' => 'id-input',
|
154
158
|
'links' => 'links-input',
|
159
|
+
'mandate_reference' => 'mandate_reference-input',
|
155
160
|
'metadata' => 'metadata-input',
|
156
161
|
'redirect_url' => 'redirect_url-input',
|
157
162
|
'scheme' => 'scheme-input',
|
@@ -190,6 +195,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
190
195
|
'description' => 'description-input',
|
191
196
|
'id' => 'id-input',
|
192
197
|
'links' => 'links-input',
|
198
|
+
'mandate_reference' => 'mandate_reference-input',
|
193
199
|
'metadata' => 'metadata-input',
|
194
200
|
'redirect_url' => 'redirect_url-input',
|
195
201
|
'scheme' => 'scheme-input',
|
@@ -225,6 +231,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
225
231
|
'description' => 'description-input',
|
226
232
|
'id' => 'id-input',
|
227
233
|
'links' => 'links-input',
|
234
|
+
'mandate_reference' => 'mandate_reference-input',
|
228
235
|
'metadata' => 'metadata-input',
|
229
236
|
'redirect_url' => 'redirect_url-input',
|
230
237
|
'scheme' => 'scheme-input',
|
@@ -273,6 +280,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
273
280
|
# /redirect_flows/%v/actions/complete
|
274
281
|
stub_url = '/redirect_flows/:identity/actions/complete'.gsub(':identity', resource_id)
|
275
282
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
283
|
+
|
276
284
|
body: {
|
277
285
|
'redirect_flows' => {
|
278
286
|
|
@@ -281,6 +289,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
281
289
|
'description' => 'description-input',
|
282
290
|
'id' => 'id-input',
|
283
291
|
'links' => 'links-input',
|
292
|
+
'mandate_reference' => 'mandate_reference-input',
|
284
293
|
'metadata' => 'metadata-input',
|
285
294
|
'redirect_url' => 'redirect_url-input',
|
286
295
|
'scheme' => 'scheme-input',
|
@@ -288,6 +297,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
288
297
|
'success_redirect_url' => 'success_redirect_url-input',
|
289
298
|
},
|
290
299
|
}.to_json,
|
300
|
+
|
291
301
|
headers: response_headers
|
292
302
|
)
|
293
303
|
end
|
@@ -321,6 +331,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
321
331
|
'description' => 'description-input',
|
322
332
|
'id' => 'id-input',
|
323
333
|
'links' => 'links-input',
|
334
|
+
'mandate_reference' => 'mandate_reference-input',
|
324
335
|
'metadata' => 'metadata-input',
|
325
336
|
'redirect_url' => 'redirect_url-input',
|
326
337
|
'scheme' => 'scheme-input',
|
@@ -18,12 +18,14 @@ describe GoCardlessPro::Resources::ScenarioSimulator do
|
|
18
18
|
# /scenario_simulators/%v/actions/run
|
19
19
|
stub_url = '/scenario_simulators/:identity/actions/run'.gsub(':identity', resource_id)
|
20
20
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
21
|
+
|
21
22
|
body: {
|
22
23
|
'scenario_simulators' => {
|
23
24
|
|
24
25
|
'id' => 'id-input',
|
25
26
|
},
|
26
27
|
}.to_json,
|
28
|
+
|
27
29
|
headers: response_headers
|
28
30
|
)
|
29
31
|
end
|
@@ -559,6 +559,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
559
559
|
# /subscriptions/%v/actions/pause
|
560
560
|
stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
|
561
561
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
562
|
+
|
562
563
|
body: {
|
563
564
|
'subscriptions' => {
|
564
565
|
|
@@ -584,6 +585,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
584
585
|
'upcoming_payments' => 'upcoming_payments-input',
|
585
586
|
},
|
586
587
|
}.to_json,
|
588
|
+
|
587
589
|
headers: response_headers
|
588
590
|
)
|
589
591
|
end
|
@@ -649,6 +651,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
649
651
|
# /subscriptions/%v/actions/resume
|
650
652
|
stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
|
651
653
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
654
|
+
|
652
655
|
body: {
|
653
656
|
'subscriptions' => {
|
654
657
|
|
@@ -674,6 +677,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
674
677
|
'upcoming_payments' => 'upcoming_payments-input',
|
675
678
|
},
|
676
679
|
}.to_json,
|
680
|
+
|
677
681
|
headers: response_headers
|
678
682
|
)
|
679
683
|
end
|
@@ -739,6 +743,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
739
743
|
# /subscriptions/%v/actions/cancel
|
740
744
|
stub_url = '/subscriptions/:identity/actions/cancel'.gsub(':identity', resource_id)
|
741
745
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
746
|
+
|
742
747
|
body: {
|
743
748
|
'subscriptions' => {
|
744
749
|
|
@@ -764,6 +769,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
764
769
|
'upcoming_payments' => 'upcoming_payments-input',
|
765
770
|
},
|
766
771
|
}.to_json,
|
772
|
+
|
767
773
|
headers: response_headers
|
768
774
|
)
|
769
775
|
end
|
@@ -254,6 +254,7 @@ describe GoCardlessPro::Resources::Webhook do
|
|
254
254
|
# /webhooks/%v/actions/retry
|
255
255
|
stub_url = '/webhooks/:identity/actions/retry'.gsub(':identity', resource_id)
|
256
256
|
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
257
|
+
|
257
258
|
body: {
|
258
259
|
'webhooks' => {
|
259
260
|
|
@@ -272,6 +273,7 @@ describe GoCardlessPro::Resources::Webhook do
|
|
272
273
|
'url' => 'url-input',
|
273
274
|
},
|
274
275
|
}.to_json,
|
276
|
+
|
275
277
|
headers: response_headers
|
276
278
|
)
|
277
279
|
end
|
@@ -24,13 +24,13 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
24
24
|
'bank_authorisations' => {
|
25
25
|
|
26
26
|
'authorisation_type' => 'authorisation_type-input',
|
27
|
+
'authorised_at' => 'authorised_at-input',
|
27
28
|
'created_at' => 'created_at-input',
|
28
29
|
'expires_at' => 'expires_at-input',
|
29
30
|
'id' => 'id-input',
|
30
31
|
'last_visited_at' => 'last_visited_at-input',
|
31
32
|
'links' => 'links-input',
|
32
33
|
'redirect_uri' => 'redirect_uri-input',
|
33
|
-
'short_url' => 'short_url-input',
|
34
34
|
'url' => 'url-input',
|
35
35
|
},
|
36
36
|
}.to_json,
|
@@ -58,13 +58,13 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
58
58
|
'bank_authorisations' => {
|
59
59
|
|
60
60
|
'authorisation_type' => 'authorisation_type-input',
|
61
|
+
'authorised_at' => 'authorised_at-input',
|
61
62
|
'created_at' => 'created_at-input',
|
62
63
|
'expires_at' => 'expires_at-input',
|
63
64
|
'id' => 'id-input',
|
64
65
|
'last_visited_at' => 'last_visited_at-input',
|
65
66
|
'links' => 'links-input',
|
66
67
|
'redirect_uri' => 'redirect_uri-input',
|
67
|
-
'short_url' => 'short_url-input',
|
68
68
|
'url' => 'url-input',
|
69
69
|
},
|
70
70
|
}.to_json,
|
@@ -162,13 +162,13 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
162
162
|
{
|
163
163
|
|
164
164
|
'authorisation_type' => 'authorisation_type-input',
|
165
|
+
'authorised_at' => 'authorised_at-input',
|
165
166
|
'created_at' => 'created_at-input',
|
166
167
|
'expires_at' => 'expires_at-input',
|
167
168
|
'id' => 'id-input',
|
168
169
|
'last_visited_at' => 'last_visited_at-input',
|
169
170
|
'links' => 'links-input',
|
170
171
|
'redirect_uri' => 'redirect_uri-input',
|
171
|
-
'short_url' => 'short_url-input',
|
172
172
|
'url' => 'url-input',
|
173
173
|
}
|
174
174
|
end
|
@@ -180,13 +180,13 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
180
180
|
'bank_authorisations' => {
|
181
181
|
|
182
182
|
'authorisation_type' => 'authorisation_type-input',
|
183
|
+
'authorised_at' => 'authorised_at-input',
|
183
184
|
'created_at' => 'created_at-input',
|
184
185
|
'expires_at' => 'expires_at-input',
|
185
186
|
'id' => 'id-input',
|
186
187
|
'last_visited_at' => 'last_visited_at-input',
|
187
188
|
'links' => 'links-input',
|
188
189
|
'redirect_uri' => 'redirect_uri-input',
|
189
|
-
'short_url' => 'short_url-input',
|
190
190
|
'url' => 'url-input',
|
191
191
|
},
|
192
192
|
}
|
@@ -198,13 +198,13 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
198
198
|
{
|
199
199
|
|
200
200
|
'authorisation_type' => 'authorisation_type-input',
|
201
|
+
'authorised_at' => 'authorised_at-input',
|
201
202
|
'created_at' => 'created_at-input',
|
202
203
|
'expires_at' => 'expires_at-input',
|
203
204
|
'id' => 'id-input',
|
204
205
|
'last_visited_at' => 'last_visited_at-input',
|
205
206
|
'links' => 'links-input',
|
206
207
|
'redirect_uri' => 'redirect_uri-input',
|
207
|
-
'short_url' => 'short_url-input',
|
208
208
|
'url' => 'url-input',
|
209
209
|
},
|
210
210
|
|
@@ -272,13 +272,13 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
272
272
|
{
|
273
273
|
|
274
274
|
'authorisation_type' => 'authorisation_type-input',
|
275
|
+
'authorised_at' => 'authorised_at-input',
|
275
276
|
'created_at' => 'created_at-input',
|
276
277
|
'expires_at' => 'expires_at-input',
|
277
278
|
'id' => 'id-input',
|
278
279
|
'last_visited_at' => 'last_visited_at-input',
|
279
280
|
'links' => 'links-input',
|
280
281
|
'redirect_uri' => 'redirect_uri-input',
|
281
|
-
'short_url' => 'short_url-input',
|
282
282
|
'url' => 'url-input',
|
283
283
|
}
|
284
284
|
end
|
@@ -313,13 +313,13 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
313
313
|
'bank_authorisations' => {
|
314
314
|
|
315
315
|
'authorisation_type' => 'authorisation_type-input',
|
316
|
+
'authorised_at' => 'authorised_at-input',
|
316
317
|
'created_at' => 'created_at-input',
|
317
318
|
'expires_at' => 'expires_at-input',
|
318
319
|
'id' => 'id-input',
|
319
320
|
'last_visited_at' => 'last_visited_at-input',
|
320
321
|
'links' => 'links-input',
|
321
322
|
'redirect_uri' => 'redirect_uri-input',
|
322
|
-
'short_url' => 'short_url-input',
|
323
323
|
'url' => 'url-input',
|
324
324
|
},
|
325
325
|
}.to_json,
|
@@ -348,19 +348,6 @@ describe GoCardlessPro::Services::BankAuthorisationsService do
|
|
348
348
|
to raise_error(GoCardlessPro::IdempotencyConflict)
|
349
349
|
end
|
350
350
|
end
|
351
|
-
|
352
|
-
context 'with on_idempotency_conflict: :unknown' do
|
353
|
-
let(:client) do
|
354
|
-
GoCardlessPro::Client.new(
|
355
|
-
access_token: 'SECRET_TOKEN',
|
356
|
-
on_idempotency_conflict: :unknown
|
357
|
-
)
|
358
|
-
end
|
359
|
-
|
360
|
-
it 'raises an ArgumentError' do
|
361
|
-
expect { post_create_response }.to raise_error(ArgumentError)
|
362
|
-
end
|
363
|
-
end
|
364
351
|
end
|
365
352
|
end
|
366
353
|
end
|
@@ -16,10 +16,17 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
16
16
|
{
|
17
17
|
|
18
18
|
'authorisation_url' => 'authorisation_url-input',
|
19
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
19
20
|
'created_at' => 'created_at-input',
|
21
|
+
'exit_uri' => 'exit_uri-input',
|
20
22
|
'expires_at' => 'expires_at-input',
|
23
|
+
'id' => 'id-input',
|
21
24
|
'links' => 'links-input',
|
25
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
26
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
22
27
|
'redirect_uri' => 'redirect_uri-input',
|
28
|
+
'session_token' => 'session_token-input',
|
29
|
+
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
23
30
|
}
|
24
31
|
end
|
25
32
|
|
@@ -30,10 +37,17 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
30
37
|
'billing_request_flows' => {
|
31
38
|
|
32
39
|
'authorisation_url' => 'authorisation_url-input',
|
40
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
33
41
|
'created_at' => 'created_at-input',
|
42
|
+
'exit_uri' => 'exit_uri-input',
|
34
43
|
'expires_at' => 'expires_at-input',
|
44
|
+
'id' => 'id-input',
|
35
45
|
'links' => 'links-input',
|
46
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
47
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
36
48
|
'redirect_uri' => 'redirect_uri-input',
|
49
|
+
'session_token' => 'session_token-input',
|
50
|
+
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
37
51
|
},
|
38
52
|
}
|
39
53
|
).
|
@@ -44,10 +58,17 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
44
58
|
{
|
45
59
|
|
46
60
|
'authorisation_url' => 'authorisation_url-input',
|
61
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
47
62
|
'created_at' => 'created_at-input',
|
63
|
+
'exit_uri' => 'exit_uri-input',
|
48
64
|
'expires_at' => 'expires_at-input',
|
65
|
+
'id' => 'id-input',
|
49
66
|
'links' => 'links-input',
|
67
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
68
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
50
69
|
'redirect_uri' => 'redirect_uri-input',
|
70
|
+
'session_token' => 'session_token-input',
|
71
|
+
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
51
72
|
},
|
52
73
|
|
53
74
|
}.to_json,
|
@@ -114,10 +135,17 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
114
135
|
{
|
115
136
|
|
116
137
|
'authorisation_url' => 'authorisation_url-input',
|
138
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
117
139
|
'created_at' => 'created_at-input',
|
140
|
+
'exit_uri' => 'exit_uri-input',
|
118
141
|
'expires_at' => 'expires_at-input',
|
142
|
+
'id' => 'id-input',
|
119
143
|
'links' => 'links-input',
|
144
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
145
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
120
146
|
'redirect_uri' => 'redirect_uri-input',
|
147
|
+
'session_token' => 'session_token-input',
|
148
|
+
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
121
149
|
}
|
122
150
|
end
|
123
151
|
|
@@ -149,4 +177,91 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
|
|
149
177
|
end
|
150
178
|
end
|
151
179
|
end
|
180
|
+
|
181
|
+
describe '#initialise' do
|
182
|
+
subject(:post_response) { client.billing_request_flows.initialise(resource_id) }
|
183
|
+
|
184
|
+
let(:resource_id) { 'ABC123' }
|
185
|
+
|
186
|
+
let!(:stub) do
|
187
|
+
# /billing_request_flows/%v/actions/initialise
|
188
|
+
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
|
189
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
190
|
+
|
191
|
+
body: {
|
192
|
+
'billing_request_flows' => {
|
193
|
+
|
194
|
+
'authorisation_url' => 'authorisation_url-input',
|
195
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
196
|
+
'created_at' => 'created_at-input',
|
197
|
+
'exit_uri' => 'exit_uri-input',
|
198
|
+
'expires_at' => 'expires_at-input',
|
199
|
+
'id' => 'id-input',
|
200
|
+
'links' => 'links-input',
|
201
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
202
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
203
|
+
'redirect_uri' => 'redirect_uri-input',
|
204
|
+
'session_token' => 'session_token-input',
|
205
|
+
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
206
|
+
},
|
207
|
+
}.to_json,
|
208
|
+
|
209
|
+
headers: response_headers
|
210
|
+
)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'wraps the response and calls the right endpoint' do
|
214
|
+
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequestFlow)
|
215
|
+
|
216
|
+
expect(stub).to have_been_requested
|
217
|
+
end
|
218
|
+
|
219
|
+
describe 'retry behaviour' do
|
220
|
+
it "doesn't retry errors" do
|
221
|
+
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
|
222
|
+
stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
223
|
+
to_timeout
|
224
|
+
|
225
|
+
expect { post_response }.to raise_error(Faraday::ConnectionFailed)
|
226
|
+
expect(stub).to have_been_requested
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'when the request needs a body and custom header' do
|
231
|
+
let(:body) { { foo: 'bar' } }
|
232
|
+
let(:headers) { { 'Foo' => 'Bar' } }
|
233
|
+
subject(:post_response) { client.billing_request_flows.initialise(resource_id, body, headers) }
|
234
|
+
|
235
|
+
let(:resource_id) { 'ABC123' }
|
236
|
+
|
237
|
+
let!(:stub) do
|
238
|
+
# /billing_request_flows/%v/actions/initialise
|
239
|
+
stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
|
240
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
241
|
+
with(
|
242
|
+
body: { foo: 'bar' },
|
243
|
+
headers: { 'Foo' => 'Bar' }
|
244
|
+
).to_return(
|
245
|
+
body: {
|
246
|
+
'billing_request_flows' => {
|
247
|
+
|
248
|
+
'authorisation_url' => 'authorisation_url-input',
|
249
|
+
'auto_fulfil' => 'auto_fulfil-input',
|
250
|
+
'created_at' => 'created_at-input',
|
251
|
+
'exit_uri' => 'exit_uri-input',
|
252
|
+
'expires_at' => 'expires_at-input',
|
253
|
+
'id' => 'id-input',
|
254
|
+
'links' => 'links-input',
|
255
|
+
'lock_bank_account' => 'lock_bank_account-input',
|
256
|
+
'lock_customer_details' => 'lock_customer_details-input',
|
257
|
+
'redirect_uri' => 'redirect_uri-input',
|
258
|
+
'session_token' => 'session_token-input',
|
259
|
+
'show_redirect_buttons' => 'show_redirect_buttons-input',
|
260
|
+
},
|
261
|
+
}.to_json,
|
262
|
+
headers: response_headers
|
263
|
+
)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
152
267
|
end
|