gocardless_pro 2.29.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gocardless_pro/client.rb +1 -1
  3. data/lib/gocardless_pro/resources/billing_request.rb +2 -0
  4. data/lib/gocardless_pro/resources/billing_request_flow.rb +4 -0
  5. data/lib/gocardless_pro/resources/block.rb +19 -9
  6. data/lib/gocardless_pro/resources/institution.rb +5 -1
  7. data/lib/gocardless_pro/resources/payer_authorisation.rb +4 -4
  8. data/lib/gocardless_pro/resources/redirect_flow.rb +4 -0
  9. data/lib/gocardless_pro/services/billing_request_flows_service.rb +1 -1
  10. data/lib/gocardless_pro/services/billing_requests_service.rb +40 -2
  11. data/lib/gocardless_pro/services/institutions_service.rb +1 -1
  12. data/lib/gocardless_pro/version.rb +1 -1
  13. data/spec/resources/billing_request_flow_spec.rb +14 -0
  14. data/spec/resources/billing_request_spec.rb +108 -0
  15. data/spec/resources/block_spec.rb +18 -1
  16. data/spec/resources/creditor_bank_account_spec.rb +2 -0
  17. data/spec/resources/customer_bank_account_spec.rb +2 -0
  18. data/spec/resources/customer_notification_spec.rb +2 -0
  19. data/spec/resources/customer_spec.rb +2 -0
  20. data/spec/resources/instalment_schedule_spec.rb +2 -0
  21. data/spec/resources/mandate_import_spec.rb +4 -0
  22. data/spec/resources/mandate_spec.rb +4 -0
  23. data/spec/resources/payer_authorisation_spec.rb +4 -0
  24. data/spec/resources/payment_spec.rb +4 -0
  25. data/spec/resources/redirect_flow_spec.rb +2 -0
  26. data/spec/resources/scenario_simulator_spec.rb +2 -0
  27. data/spec/resources/subscription_spec.rb +6 -0
  28. data/spec/resources/webhook_spec.rb +2 -0
  29. data/spec/services/billing_request_flows_service_spec.rb +14 -0
  30. data/spec/services/billing_requests_service_spec.rb +123 -0
  31. data/spec/services/blocks_service_spec.rb +18 -1
  32. data/spec/services/creditor_bank_accounts_service_spec.rb +2 -0
  33. data/spec/services/customer_bank_accounts_service_spec.rb +2 -0
  34. data/spec/services/customer_notifications_service_spec.rb +2 -0
  35. data/spec/services/customers_service_spec.rb +2 -0
  36. data/spec/services/instalment_schedules_service_spec.rb +2 -0
  37. data/spec/services/mandate_imports_service_spec.rb +4 -0
  38. data/spec/services/mandates_service_spec.rb +4 -0
  39. data/spec/services/payer_authorisations_service_spec.rb +4 -0
  40. data/spec/services/payments_service_spec.rb +4 -0
  41. data/spec/services/redirect_flows_service_spec.rb +2 -0
  42. data/spec/services/scenario_simulators_service_spec.rb +2 -0
  43. data/spec/services/subscriptions_service_spec.rb +6 -0
  44. data/spec/services/webhooks_service_spec.rb +2 -0
  45. metadata +7 -7
@@ -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
@@ -18,6 +18,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
18
18
  'authorisation_url' => 'authorisation_url-input',
19
19
  'auto_fulfil' => 'auto_fulfil-input',
20
20
  'created_at' => 'created_at-input',
21
+ 'exit_uri' => 'exit_uri-input',
21
22
  'expires_at' => 'expires_at-input',
22
23
  'id' => 'id-input',
23
24
  'links' => 'links-input',
@@ -25,6 +26,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
25
26
  'lock_customer_details' => 'lock_customer_details-input',
26
27
  'redirect_uri' => 'redirect_uri-input',
27
28
  'session_token' => 'session_token-input',
29
+ 'show_redirect_buttons' => 'show_redirect_buttons-input',
28
30
  }
29
31
  end
30
32
 
@@ -37,6 +39,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
37
39
  'authorisation_url' => 'authorisation_url-input',
38
40
  'auto_fulfil' => 'auto_fulfil-input',
39
41
  'created_at' => 'created_at-input',
42
+ 'exit_uri' => 'exit_uri-input',
40
43
  'expires_at' => 'expires_at-input',
41
44
  'id' => 'id-input',
42
45
  'links' => 'links-input',
@@ -44,6 +47,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
44
47
  'lock_customer_details' => 'lock_customer_details-input',
45
48
  'redirect_uri' => 'redirect_uri-input',
46
49
  'session_token' => 'session_token-input',
50
+ 'show_redirect_buttons' => 'show_redirect_buttons-input',
47
51
  },
48
52
  }
49
53
  ).
@@ -56,6 +60,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
56
60
  'authorisation_url' => 'authorisation_url-input',
57
61
  'auto_fulfil' => 'auto_fulfil-input',
58
62
  'created_at' => 'created_at-input',
63
+ 'exit_uri' => 'exit_uri-input',
59
64
  'expires_at' => 'expires_at-input',
60
65
  'id' => 'id-input',
61
66
  'links' => 'links-input',
@@ -63,6 +68,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
63
68
  'lock_customer_details' => 'lock_customer_details-input',
64
69
  'redirect_uri' => 'redirect_uri-input',
65
70
  'session_token' => 'session_token-input',
71
+ 'show_redirect_buttons' => 'show_redirect_buttons-input',
66
72
  },
67
73
 
68
74
  }.to_json,
@@ -131,6 +137,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
131
137
  'authorisation_url' => 'authorisation_url-input',
132
138
  'auto_fulfil' => 'auto_fulfil-input',
133
139
  'created_at' => 'created_at-input',
140
+ 'exit_uri' => 'exit_uri-input',
134
141
  'expires_at' => 'expires_at-input',
135
142
  'id' => 'id-input',
136
143
  'links' => 'links-input',
@@ -138,6 +145,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
138
145
  'lock_customer_details' => 'lock_customer_details-input',
139
146
  'redirect_uri' => 'redirect_uri-input',
140
147
  'session_token' => 'session_token-input',
148
+ 'show_redirect_buttons' => 'show_redirect_buttons-input',
141
149
  }
142
150
  end
143
151
 
@@ -179,12 +187,14 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
179
187
  # /billing_request_flows/%v/actions/initialise
180
188
  stub_url = '/billing_request_flows/:identity/actions/initialise'.gsub(':identity', resource_id)
181
189
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
190
+
182
191
  body: {
183
192
  'billing_request_flows' => {
184
193
 
185
194
  'authorisation_url' => 'authorisation_url-input',
186
195
  'auto_fulfil' => 'auto_fulfil-input',
187
196
  'created_at' => 'created_at-input',
197
+ 'exit_uri' => 'exit_uri-input',
188
198
  'expires_at' => 'expires_at-input',
189
199
  'id' => 'id-input',
190
200
  'links' => 'links-input',
@@ -192,8 +202,10 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
192
202
  'lock_customer_details' => 'lock_customer_details-input',
193
203
  'redirect_uri' => 'redirect_uri-input',
194
204
  'session_token' => 'session_token-input',
205
+ 'show_redirect_buttons' => 'show_redirect_buttons-input',
195
206
  },
196
207
  }.to_json,
208
+
197
209
  headers: response_headers
198
210
  )
199
211
  end
@@ -236,6 +248,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
236
248
  'authorisation_url' => 'authorisation_url-input',
237
249
  'auto_fulfil' => 'auto_fulfil-input',
238
250
  'created_at' => 'created_at-input',
251
+ 'exit_uri' => 'exit_uri-input',
239
252
  'expires_at' => 'expires_at-input',
240
253
  'id' => 'id-input',
241
254
  'links' => 'links-input',
@@ -243,6 +256,7 @@ describe GoCardlessPro::Services::BillingRequestFlowsService do
243
256
  'lock_customer_details' => 'lock_customer_details-input',
244
257
  'redirect_uri' => 'redirect_uri-input',
245
258
  'session_token' => 'session_token-input',
259
+ 'show_redirect_buttons' => 'show_redirect_buttons-input',
246
260
  },
247
261
  }.to_json,
248
262
  headers: response_headers
@@ -19,6 +19,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
19
19
 
20
20
  'actions' => 'actions-input',
21
21
  'created_at' => 'created_at-input',
22
+ 'fallback_enabled' => 'fallback_enabled-input',
22
23
  'id' => 'id-input',
23
24
  'links' => 'links-input',
24
25
  'mandate_request' => 'mandate_request-input',
@@ -50,6 +51,8 @@ describe GoCardlessPro::Services::BillingRequestsService do
50
51
 
51
52
  expect(get_list_response.records.first.created_at).to eq('created_at-input')
52
53
 
54
+ expect(get_list_response.records.first.fallback_enabled).to eq('fallback_enabled-input')
55
+
53
56
  expect(get_list_response.records.first.id).to eq('id-input')
54
57
 
55
58
  expect(get_list_response.records.first.mandate_request).to eq('mandate_request-input')
@@ -103,6 +106,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
103
106
 
104
107
  'actions' => 'actions-input',
105
108
  'created_at' => 'created_at-input',
109
+ 'fallback_enabled' => 'fallback_enabled-input',
106
110
  'id' => 'id-input',
107
111
  'links' => 'links-input',
108
112
  'mandate_request' => 'mandate_request-input',
@@ -127,6 +131,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
127
131
 
128
132
  'actions' => 'actions-input',
129
133
  'created_at' => 'created_at-input',
134
+ 'fallback_enabled' => 'fallback_enabled-input',
130
135
  'id' => 'id-input',
131
136
  'links' => 'links-input',
132
137
  'mandate_request' => 'mandate_request-input',
@@ -160,6 +165,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
160
165
 
161
166
  'actions' => 'actions-input',
162
167
  'created_at' => 'created_at-input',
168
+ 'fallback_enabled' => 'fallback_enabled-input',
163
169
  'id' => 'id-input',
164
170
  'links' => 'links-input',
165
171
  'mandate_request' => 'mandate_request-input',
@@ -184,6 +190,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
184
190
 
185
191
  'actions' => 'actions-input',
186
192
  'created_at' => 'created_at-input',
193
+ 'fallback_enabled' => 'fallback_enabled-input',
187
194
  'id' => 'id-input',
188
195
  'links' => 'links-input',
189
196
  'mandate_request' => 'mandate_request-input',
@@ -213,6 +220,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
213
220
 
214
221
  'actions' => 'actions-input',
215
222
  'created_at' => 'created_at-input',
223
+ 'fallback_enabled' => 'fallback_enabled-input',
216
224
  'id' => 'id-input',
217
225
  'links' => 'links-input',
218
226
  'mandate_request' => 'mandate_request-input',
@@ -240,6 +248,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
240
248
 
241
249
  'actions' => 'actions-input',
242
250
  'created_at' => 'created_at-input',
251
+ 'fallback_enabled' => 'fallback_enabled-input',
243
252
  'id' => 'id-input',
244
253
  'links' => 'links-input',
245
254
  'mandate_request' => 'mandate_request-input',
@@ -272,6 +281,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
272
281
 
273
282
  'actions' => 'actions-input',
274
283
  'created_at' => 'created_at-input',
284
+ 'fallback_enabled' => 'fallback_enabled-input',
275
285
  'id' => 'id-input',
276
286
  'links' => 'links-input',
277
287
  'mandate_request' => 'mandate_request-input',
@@ -290,6 +300,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
290
300
 
291
301
  'actions' => 'actions-input',
292
302
  'created_at' => 'created_at-input',
303
+ 'fallback_enabled' => 'fallback_enabled-input',
293
304
  'id' => 'id-input',
294
305
  'links' => 'links-input',
295
306
  'mandate_request' => 'mandate_request-input',
@@ -308,6 +319,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
308
319
 
309
320
  'actions' => 'actions-input',
310
321
  'created_at' => 'created_at-input',
322
+ 'fallback_enabled' => 'fallback_enabled-input',
311
323
  'id' => 'id-input',
312
324
  'links' => 'links-input',
313
325
  'mandate_request' => 'mandate_request-input',
@@ -382,6 +394,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
382
394
 
383
395
  'actions' => 'actions-input',
384
396
  'created_at' => 'created_at-input',
397
+ 'fallback_enabled' => 'fallback_enabled-input',
385
398
  'id' => 'id-input',
386
399
  'links' => 'links-input',
387
400
  'mandate_request' => 'mandate_request-input',
@@ -423,6 +436,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
423
436
 
424
437
  'actions' => 'actions-input',
425
438
  'created_at' => 'created_at-input',
439
+ 'fallback_enabled' => 'fallback_enabled-input',
426
440
  'id' => 'id-input',
427
441
  'links' => 'links-input',
428
442
  'mandate_request' => 'mandate_request-input',
@@ -476,6 +490,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
476
490
 
477
491
  'actions' => 'actions-input',
478
492
  'created_at' => 'created_at-input',
493
+ 'fallback_enabled' => 'fallback_enabled-input',
479
494
  'id' => 'id-input',
480
495
  'links' => 'links-input',
481
496
  'mandate_request' => 'mandate_request-input',
@@ -510,6 +525,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
510
525
 
511
526
  'actions' => 'actions-input',
512
527
  'created_at' => 'created_at-input',
528
+ 'fallback_enabled' => 'fallback_enabled-input',
513
529
  'id' => 'id-input',
514
530
  'links' => 'links-input',
515
531
  'mandate_request' => 'mandate_request-input',
@@ -615,11 +631,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
615
631
  # /billing_requests/%v/actions/collect_customer_details
616
632
  stub_url = '/billing_requests/:identity/actions/collect_customer_details'.gsub(':identity', resource_id)
617
633
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
634
+
618
635
  body: {
619
636
  'billing_requests' => {
620
637
 
621
638
  'actions' => 'actions-input',
622
639
  'created_at' => 'created_at-input',
640
+ 'fallback_enabled' => 'fallback_enabled-input',
623
641
  'id' => 'id-input',
624
642
  'links' => 'links-input',
625
643
  'mandate_request' => 'mandate_request-input',
@@ -629,6 +647,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
629
647
  'status' => 'status-input',
630
648
  },
631
649
  }.to_json,
650
+
632
651
  headers: response_headers
633
652
  )
634
653
  end
@@ -670,6 +689,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
670
689
 
671
690
  'actions' => 'actions-input',
672
691
  'created_at' => 'created_at-input',
692
+ 'fallback_enabled' => 'fallback_enabled-input',
673
693
  'id' => 'id-input',
674
694
  'links' => 'links-input',
675
695
  'mandate_request' => 'mandate_request-input',
@@ -694,11 +714,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
694
714
  # /billing_requests/%v/actions/collect_bank_account
695
715
  stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
696
716
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
717
+
697
718
  body: {
698
719
  'billing_requests' => {
699
720
 
700
721
  'actions' => 'actions-input',
701
722
  'created_at' => 'created_at-input',
723
+ 'fallback_enabled' => 'fallback_enabled-input',
702
724
  'id' => 'id-input',
703
725
  'links' => 'links-input',
704
726
  'mandate_request' => 'mandate_request-input',
@@ -708,6 +730,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
708
730
  'status' => 'status-input',
709
731
  },
710
732
  }.to_json,
733
+
711
734
  headers: response_headers
712
735
  )
713
736
  end
@@ -749,6 +772,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
749
772
 
750
773
  'actions' => 'actions-input',
751
774
  'created_at' => 'created_at-input',
775
+ 'fallback_enabled' => 'fallback_enabled-input',
752
776
  'id' => 'id-input',
753
777
  'links' => 'links-input',
754
778
  'mandate_request' => 'mandate_request-input',
@@ -773,11 +797,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
773
797
  # /billing_requests/%v/actions/fulfil
774
798
  stub_url = '/billing_requests/:identity/actions/fulfil'.gsub(':identity', resource_id)
775
799
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
800
+
776
801
  body: {
777
802
  'billing_requests' => {
778
803
 
779
804
  'actions' => 'actions-input',
780
805
  'created_at' => 'created_at-input',
806
+ 'fallback_enabled' => 'fallback_enabled-input',
781
807
  'id' => 'id-input',
782
808
  'links' => 'links-input',
783
809
  'mandate_request' => 'mandate_request-input',
@@ -787,6 +813,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
787
813
  'status' => 'status-input',
788
814
  },
789
815
  }.to_json,
816
+
790
817
  headers: response_headers
791
818
  )
792
819
  end
@@ -828,6 +855,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
828
855
 
829
856
  'actions' => 'actions-input',
830
857
  'created_at' => 'created_at-input',
858
+ 'fallback_enabled' => 'fallback_enabled-input',
831
859
  'id' => 'id-input',
832
860
  'links' => 'links-input',
833
861
  'mandate_request' => 'mandate_request-input',
@@ -852,11 +880,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
852
880
  # /billing_requests/%v/actions/confirm_payer_details
853
881
  stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
854
882
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
883
+
855
884
  body: {
856
885
  'billing_requests' => {
857
886
 
858
887
  'actions' => 'actions-input',
859
888
  'created_at' => 'created_at-input',
889
+ 'fallback_enabled' => 'fallback_enabled-input',
860
890
  'id' => 'id-input',
861
891
  'links' => 'links-input',
862
892
  'mandate_request' => 'mandate_request-input',
@@ -866,6 +896,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
866
896
  'status' => 'status-input',
867
897
  },
868
898
  }.to_json,
899
+
869
900
  headers: response_headers
870
901
  )
871
902
  end
@@ -907,6 +938,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
907
938
 
908
939
  'actions' => 'actions-input',
909
940
  'created_at' => 'created_at-input',
941
+ 'fallback_enabled' => 'fallback_enabled-input',
910
942
  'id' => 'id-input',
911
943
  'links' => 'links-input',
912
944
  'mandate_request' => 'mandate_request-input',
@@ -931,11 +963,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
931
963
  # /billing_requests/%v/actions/cancel
932
964
  stub_url = '/billing_requests/:identity/actions/cancel'.gsub(':identity', resource_id)
933
965
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
966
+
934
967
  body: {
935
968
  'billing_requests' => {
936
969
 
937
970
  'actions' => 'actions-input',
938
971
  'created_at' => 'created_at-input',
972
+ 'fallback_enabled' => 'fallback_enabled-input',
939
973
  'id' => 'id-input',
940
974
  'links' => 'links-input',
941
975
  'mandate_request' => 'mandate_request-input',
@@ -945,6 +979,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
945
979
  'status' => 'status-input',
946
980
  },
947
981
  }.to_json,
982
+
948
983
  headers: response_headers
949
984
  )
950
985
  end
@@ -986,6 +1021,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
986
1021
 
987
1022
  'actions' => 'actions-input',
988
1023
  'created_at' => 'created_at-input',
1024
+ 'fallback_enabled' => 'fallback_enabled-input',
989
1025
  'id' => 'id-input',
990
1026
  'links' => 'links-input',
991
1027
  'mandate_request' => 'mandate_request-input',
@@ -1010,11 +1046,13 @@ describe GoCardlessPro::Services::BillingRequestsService do
1010
1046
  # /billing_requests/%v/actions/notify
1011
1047
  stub_url = '/billing_requests/:identity/actions/notify'.gsub(':identity', resource_id)
1012
1048
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
1049
+
1013
1050
  body: {
1014
1051
  'billing_requests' => {
1015
1052
 
1016
1053
  'actions' => 'actions-input',
1017
1054
  'created_at' => 'created_at-input',
1055
+ 'fallback_enabled' => 'fallback_enabled-input',
1018
1056
  'id' => 'id-input',
1019
1057
  'links' => 'links-input',
1020
1058
  'mandate_request' => 'mandate_request-input',
@@ -1024,6 +1062,7 @@ describe GoCardlessPro::Services::BillingRequestsService do
1024
1062
  'status' => 'status-input',
1025
1063
  },
1026
1064
  }.to_json,
1065
+
1027
1066
  headers: response_headers
1028
1067
  )
1029
1068
  end
@@ -1065,6 +1104,90 @@ describe GoCardlessPro::Services::BillingRequestsService do
1065
1104
 
1066
1105
  'actions' => 'actions-input',
1067
1106
  'created_at' => 'created_at-input',
1107
+ 'fallback_enabled' => 'fallback_enabled-input',
1108
+ 'id' => 'id-input',
1109
+ 'links' => 'links-input',
1110
+ 'mandate_request' => 'mandate_request-input',
1111
+ 'metadata' => 'metadata-input',
1112
+ 'payment_request' => 'payment_request-input',
1113
+ 'resources' => 'resources-input',
1114
+ 'status' => 'status-input',
1115
+ },
1116
+ }.to_json,
1117
+ headers: response_headers
1118
+ )
1119
+ end
1120
+ end
1121
+ end
1122
+
1123
+ describe '#fallback' do
1124
+ subject(:post_response) { client.billing_requests.fallback(resource_id) }
1125
+
1126
+ let(:resource_id) { 'ABC123' }
1127
+
1128
+ let!(:stub) do
1129
+ # /billing_requests/%v/actions/fallback
1130
+ stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
1131
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
1132
+
1133
+ body: {
1134
+ 'billing_requests' => {
1135
+
1136
+ 'actions' => 'actions-input',
1137
+ 'created_at' => 'created_at-input',
1138
+ 'fallback_enabled' => 'fallback_enabled-input',
1139
+ 'id' => 'id-input',
1140
+ 'links' => 'links-input',
1141
+ 'mandate_request' => 'mandate_request-input',
1142
+ 'metadata' => 'metadata-input',
1143
+ 'payment_request' => 'payment_request-input',
1144
+ 'resources' => 'resources-input',
1145
+ 'status' => 'status-input',
1146
+ },
1147
+ }.to_json,
1148
+
1149
+ headers: response_headers
1150
+ )
1151
+ end
1152
+
1153
+ it 'wraps the response and calls the right endpoint' do
1154
+ expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
1155
+
1156
+ expect(stub).to have_been_requested
1157
+ end
1158
+
1159
+ describe 'retry behaviour' do
1160
+ it "doesn't retry errors" do
1161
+ stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
1162
+ stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
1163
+ to_timeout
1164
+
1165
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
1166
+ expect(stub).to have_been_requested
1167
+ end
1168
+ end
1169
+
1170
+ context 'when the request needs a body and custom header' do
1171
+ let(:body) { { foo: 'bar' } }
1172
+ let(:headers) { { 'Foo' => 'Bar' } }
1173
+ subject(:post_response) { client.billing_requests.fallback(resource_id, body, headers) }
1174
+
1175
+ let(:resource_id) { 'ABC123' }
1176
+
1177
+ let!(:stub) do
1178
+ # /billing_requests/%v/actions/fallback
1179
+ stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
1180
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
1181
+ with(
1182
+ body: { foo: 'bar' },
1183
+ headers: { 'Foo' => 'Bar' }
1184
+ ).to_return(
1185
+ body: {
1186
+ 'billing_requests' => {
1187
+
1188
+ 'actions' => 'actions-input',
1189
+ 'created_at' => 'created_at-input',
1190
+ 'fallback_enabled' => 'fallback_enabled-input',
1068
1191
  'id' => 'id-input',
1069
1192
  'links' => 'links-input',
1070
1193
  'mandate_request' => 'mandate_request-input',
@@ -601,6 +601,7 @@ describe GoCardlessPro::Services::BlocksService do
601
601
  # /blocks/%v/actions/disable
602
602
  stub_url = '/blocks/:identity/actions/disable'.gsub(':identity', resource_id)
603
603
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
604
+
604
605
  body: {
605
606
  'blocks' => {
606
607
 
@@ -614,6 +615,7 @@ describe GoCardlessPro::Services::BlocksService do
614
615
  'updated_at' => 'updated_at-input',
615
616
  },
616
617
  }.to_json,
618
+
617
619
  headers: response_headers
618
620
  )
619
621
  end
@@ -678,6 +680,7 @@ describe GoCardlessPro::Services::BlocksService do
678
680
  # /blocks/%v/actions/enable
679
681
  stub_url = '/blocks/:identity/actions/enable'.gsub(':identity', resource_id)
680
682
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
683
+
681
684
  body: {
682
685
  'blocks' => {
683
686
 
@@ -691,6 +694,7 @@ describe GoCardlessPro::Services::BlocksService do
691
694
  'updated_at' => 'updated_at-input',
692
695
  },
693
696
  }.to_json,
697
+
694
698
  headers: response_headers
695
699
  )
696
700
  end
@@ -755,8 +759,9 @@ describe GoCardlessPro::Services::BlocksService do
755
759
  # /block_by_ref
756
760
  stub_url = '/block_by_ref'.gsub(':identity', resource_id)
757
761
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
762
+
758
763
  body: {
759
- 'blocks' => [{
764
+ 'blocks' => [{
760
765
 
761
766
  'active' => 'active-input',
762
767
  'block_type' => 'block_type-input',
@@ -767,7 +772,14 @@ describe GoCardlessPro::Services::BlocksService do
767
772
  'resource_reference' => 'resource_reference-input',
768
773
  'updated_at' => 'updated_at-input',
769
774
  }],
775
+ meta: {
776
+ cursors: {
777
+ before: nil,
778
+ after: 'ABC123',
779
+ },
780
+ },
770
781
  }.to_json,
782
+
771
783
  headers: response_headers
772
784
  )
773
785
  end
@@ -778,6 +790,11 @@ describe GoCardlessPro::Services::BlocksService do
778
790
  expect(stub).to have_been_requested
779
791
  end
780
792
 
793
+ it 'exposes the cursors for before and after' do
794
+ expect(post_response.before).to eq(nil)
795
+ expect(post_response.after).to eq('ABC123')
796
+ end
797
+
781
798
  describe 'retry behaviour' do
782
799
  it "doesn't retry errors" do
783
800
  stub_url = '/block_by_ref'.gsub(':identity', resource_id)
@@ -647,6 +647,7 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
647
647
  # /creditor_bank_accounts/%v/actions/disable
648
648
  stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
649
649
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
650
+
650
651
  body: {
651
652
  'creditor_bank_accounts' => {
652
653
 
@@ -663,6 +664,7 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
663
664
  'metadata' => 'metadata-input',
664
665
  },
665
666
  }.to_json,
667
+
666
668
  headers: response_headers
667
669
  )
668
670
  end
@@ -709,6 +709,7 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
709
709
  # /customer_bank_accounts/%v/actions/disable
710
710
  stub_url = '/customer_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
711
711
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
712
+
712
713
  body: {
713
714
  'customer_bank_accounts' => {
714
715
 
@@ -725,6 +726,7 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
725
726
  'metadata' => 'metadata-input',
726
727
  },
727
728
  }.to_json,
729
+
728
730
  headers: response_headers
729
731
  )
730
732
  end
@@ -18,6 +18,7 @@ describe GoCardlessPro::Services::CustomerNotificationsService do
18
18
  # /customer_notifications/%v/actions/handle
19
19
  stub_url = '/customer_notifications/:identity/actions/handle'.gsub(':identity', resource_id)
20
20
  stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
21
+
21
22
  body: {
22
23
  'customer_notifications' => {
23
24
 
@@ -29,6 +30,7 @@ describe GoCardlessPro::Services::CustomerNotificationsService do
29
30
  'type' => 'type-input',
30
31
  },
31
32
  }.to_json,
33
+
32
34
  headers: response_headers
33
35
  )
34
36
  end
@@ -830,6 +830,7 @@ describe GoCardlessPro::Services::CustomersService do
830
830
  # /customers/%v
831
831
  stub_url = '/customers/:identity'.gsub(':identity', resource_id)
832
832
  stub_request(:delete, /.*api.gocardless.com#{stub_url}/).to_return(
833
+
833
834
  body: {
834
835
  'customers' => {
835
836
 
@@ -853,6 +854,7 @@ describe GoCardlessPro::Services::CustomersService do
853
854
  'swedish_identity_number' => 'swedish_identity_number-input',
854
855
  },
855
856
  }.to_json,
857
+
856
858
  headers: response_headers
857
859
  )
858
860
  end