gocardless_pro 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/circle.yml +11 -3
  4. data/demo.rb +3 -3
  5. data/gocardless_pro.gemspec +6 -6
  6. data/lib/gocardless_pro.rb +2 -1
  7. data/lib/gocardless_pro/api_service.rb +3 -2
  8. data/lib/gocardless_pro/client.rb +6 -6
  9. data/lib/gocardless_pro/error.rb +4 -4
  10. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +4 -4
  11. data/lib/gocardless_pro/request.rb +2 -2
  12. data/lib/gocardless_pro/resources/bank_details_lookup.rb +1 -0
  13. data/lib/gocardless_pro/resources/creditor.rb +1 -0
  14. data/lib/gocardless_pro/resources/creditor_bank_account.rb +1 -0
  15. data/lib/gocardless_pro/resources/customer.rb +1 -0
  16. data/lib/gocardless_pro/resources/customer_bank_account.rb +1 -0
  17. data/lib/gocardless_pro/resources/event.rb +1 -0
  18. data/lib/gocardless_pro/resources/mandate.rb +1 -0
  19. data/lib/gocardless_pro/resources/mandate_pdf.rb +1 -0
  20. data/lib/gocardless_pro/resources/payment.rb +1 -0
  21. data/lib/gocardless_pro/resources/payout.rb +1 -0
  22. data/lib/gocardless_pro/resources/redirect_flow.rb +1 -0
  23. data/lib/gocardless_pro/resources/refund.rb +1 -0
  24. data/lib/gocardless_pro/resources/subscription.rb +1 -0
  25. data/lib/gocardless_pro/services/base_service.rb +1 -1
  26. data/lib/gocardless_pro/version.rb +1 -1
  27. data/spec/api_service_spec.rb +49 -49
  28. data/spec/client_spec.rb +1 -1
  29. data/spec/error_spec.rb +13 -13
  30. data/spec/middlewares/raise_gocardless_errors_spec.rb +15 -16
  31. data/spec/resources/bank_details_lookup_spec.rb +18 -18
  32. data/spec/resources/creditor_bank_account_spec.rb +46 -46
  33. data/spec/resources/creditor_spec.rb +42 -42
  34. data/spec/resources/customer_bank_account_spec.rb +48 -48
  35. data/spec/resources/customer_spec.rb +42 -42
  36. data/spec/resources/event_spec.rb +18 -18
  37. data/spec/resources/mandate_pdf_spec.rb +18 -18
  38. data/spec/resources/mandate_spec.rb +54 -54
  39. data/spec/resources/payment_spec.rb +54 -54
  40. data/spec/resources/payout_spec.rb +18 -18
  41. data/spec/resources/redirect_flow_spec.rb +36 -36
  42. data/spec/resources/refund_spec.rb +42 -42
  43. data/spec/resources/subscription_spec.rb +48 -48
  44. data/spec/response_spec.rb +1 -2
  45. data/spec/services/bank_details_lookups_service_spec.rb +25 -25
  46. data/spec/services/creditor_bank_accounts_service_spec.rb +86 -86
  47. data/spec/services/creditors_service_spec.rb +87 -87
  48. data/spec/services/customer_bank_accounts_service_spec.rb +95 -95
  49. data/spec/services/customers_service_spec.rb +87 -87
  50. data/spec/services/events_service_spec.rb +49 -49
  51. data/spec/services/mandate_pdfs_service_spec.rb +25 -25
  52. data/spec/services/mandates_service_spec.rb +103 -103
  53. data/spec/services/payments_service_spec.rb +103 -103
  54. data/spec/services/payouts_service_spec.rb +49 -49
  55. data/spec/services/redirect_flows_service_spec.rb +52 -52
  56. data/spec/services/refunds_service_spec.rb +87 -87
  57. data/spec/services/subscriptions_service_spec.rb +95 -95
  58. metadata +10 -10
@@ -28,13 +28,13 @@ describe GoCardlessPro::Services::CreditorsService do
28
28
  'postal_code' => 'postal_code-input',
29
29
  'region' => 'region-input',
30
30
  'scheme_identifiers' => 'scheme_identifiers-input',
31
- 'verification_status' => 'verification_status-input'
31
+ 'verification_status' => 'verification_status-input',
32
32
  }
33
33
  end
34
34
 
35
35
  before do
36
- stub_request(:post, %r{.*api.gocardless.com/creditors})
37
- .with(
36
+ stub_request(:post, %r{.*api.gocardless.com/creditors}).
37
+ with(
38
38
  body: {
39
39
  'creditors' => {
40
40
 
@@ -51,11 +51,11 @@ describe GoCardlessPro::Services::CreditorsService do
51
51
  'postal_code' => 'postal_code-input',
52
52
  'region' => 'region-input',
53
53
  'scheme_identifiers' => 'scheme_identifiers-input',
54
- 'verification_status' => 'verification_status-input'
55
- }
54
+ 'verification_status' => 'verification_status-input',
55
+ },
56
56
  }
57
- )
58
- .to_return(
57
+ ).
58
+ to_return(
59
59
  body: {
60
60
  'creditors' =>
61
61
 
@@ -74,8 +74,8 @@ describe GoCardlessPro::Services::CreditorsService do
74
74
  'postal_code' => 'postal_code-input',
75
75
  'region' => 'region-input',
76
76
  'scheme_identifiers' => 'scheme_identifiers-input',
77
- 'verification_status' => 'verification_status-input'
78
- }
77
+ 'verification_status' => 'verification_status-input',
78
+ },
79
79
 
80
80
  }.to_json,
81
81
  headers: response_headers
@@ -90,19 +90,19 @@ describe GoCardlessPro::Services::CreditorsService do
90
90
  before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
91
91
 
92
92
  it 'retries timeouts' do
93
- stub = stub_request(:post, %r{.*api.gocardless.com/creditors})
94
- .to_timeout.then.to_return(status: 200, headers: response_headers)
93
+ stub = stub_request(:post, %r{.*api.gocardless.com/creditors}).
94
+ to_timeout.then.to_return(status: 200, headers: response_headers)
95
95
 
96
96
  post_create_response
97
97
  expect(stub).to have_been_requested.twice
98
98
  end
99
99
 
100
100
  it 'retries 5XX errors' do
101
- stub = stub_request(:post, %r{.*api.gocardless.com/creditors})
102
- .to_return(status: 502,
103
- headers: { 'Content-Type' => 'text/html' },
104
- body: '<html><body>Response from Cloudflare</body></html>')
105
- .then.to_return(status: 200, headers: response_headers)
101
+ stub = stub_request(:post, %r{.*api.gocardless.com/creditors}).
102
+ to_return(status: 502,
103
+ headers: { 'Content-Type' => 'text/html' },
104
+ body: '<html><body>Response from Cloudflare</body></html>').
105
+ then.to_return(status: 200, headers: response_headers)
106
106
 
107
107
  post_create_response
108
108
  expect(stub).to have_been_requested.twice
@@ -120,9 +120,9 @@ describe GoCardlessPro::Services::CreditorsService do
120
120
  type: 'validation_failed',
121
121
  code: 422,
122
122
  errors: [
123
- { message: 'test error message', field: 'test_field' }
124
- ]
125
- }
123
+ { message: 'test error message', field: 'test_field' },
124
+ ],
125
+ },
126
126
  }.to_json,
127
127
  headers: response_headers,
128
128
  status: 422
@@ -153,7 +153,7 @@ describe GoCardlessPro::Services::CreditorsService do
153
153
  'postal_code' => 'postal_code-input',
154
154
  'region' => 'region-input',
155
155
  'scheme_identifiers' => 'scheme_identifiers-input',
156
- 'verification_status' => 'verification_status-input'
156
+ 'verification_status' => 'verification_status-input',
157
157
  }
158
158
  end
159
159
 
@@ -168,11 +168,11 @@ describe GoCardlessPro::Services::CreditorsService do
168
168
  message: 'A resource has already been created with this idempotency key',
169
169
  reason: 'idempotent_creation_conflict',
170
170
  links: {
171
- conflicting_resource_id: id
172
- }
173
- }
174
- ]
175
- }
171
+ conflicting_resource_id: id,
172
+ },
173
+ },
174
+ ],
175
+ },
176
176
  }.to_json,
177
177
  headers: response_headers,
178
178
  status: 409
@@ -181,8 +181,8 @@ describe GoCardlessPro::Services::CreditorsService do
181
181
 
182
182
  let!(:get_stub) do
183
183
  stub_url = "/creditors/#{id}"
184
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
185
- .to_return(
184
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
185
+ to_return(
186
186
  body: {
187
187
  'creditors' => {
188
188
 
@@ -199,8 +199,8 @@ describe GoCardlessPro::Services::CreditorsService do
199
199
  'postal_code' => 'postal_code-input',
200
200
  'region' => 'region-input',
201
201
  'scheme_identifiers' => 'scheme_identifiers-input',
202
- 'verification_status' => 'verification_status-input'
203
- }
202
+ 'verification_status' => 'verification_status-input',
203
+ },
204
204
  }.to_json,
205
205
  headers: response_headers
206
206
  )
@@ -235,14 +235,14 @@ describe GoCardlessPro::Services::CreditorsService do
235
235
  'postal_code' => 'postal_code-input',
236
236
  'region' => 'region-input',
237
237
  'scheme_identifiers' => 'scheme_identifiers-input',
238
- 'verification_status' => 'verification_status-input'
238
+ 'verification_status' => 'verification_status-input',
239
239
  }],
240
240
  meta: {
241
241
  cursors: {
242
242
  before: nil,
243
- after: 'ABC123'
244
- }
245
- }
243
+ after: 'ABC123',
244
+ },
245
+ },
246
246
  }.to_json
247
247
  end
248
248
 
@@ -294,19 +294,19 @@ describe GoCardlessPro::Services::CreditorsService do
294
294
  before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
295
295
 
296
296
  it 'retries timeouts' do
297
- stub = stub_request(:get, %r{.*api.gocardless.com/creditors})
298
- .to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
297
+ stub = stub_request(:get, %r{.*api.gocardless.com/creditors}).
298
+ to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
299
299
 
300
300
  get_list_response
301
301
  expect(stub).to have_been_requested.twice
302
302
  end
303
303
 
304
304
  it 'retries 5XX errors' do
305
- stub = stub_request(:get, %r{.*api.gocardless.com/creditors})
306
- .to_return(status: 502,
307
- headers: { 'Content-Type' => 'text/html' },
308
- body: '<html><body>Response from Cloudflare</body></html>')
309
- .then.to_return(status: 200, headers: response_headers, body: body)
305
+ stub = stub_request(:get, %r{.*api.gocardless.com/creditors}).
306
+ to_return(status: 502,
307
+ headers: { 'Content-Type' => 'text/html' },
308
+ body: '<html><body>Response from Cloudflare</body></html>').
309
+ then.to_return(status: 200, headers: response_headers, body: body)
310
310
 
311
311
  get_list_response
312
312
  expect(stub).to have_been_requested.twice
@@ -334,12 +334,12 @@ describe GoCardlessPro::Services::CreditorsService do
334
334
  'postal_code' => 'postal_code-input',
335
335
  'region' => 'region-input',
336
336
  'scheme_identifiers' => 'scheme_identifiers-input',
337
- 'verification_status' => 'verification_status-input'
337
+ 'verification_status' => 'verification_status-input',
338
338
  }],
339
339
  meta: {
340
340
  cursors: { after: 'AB345' },
341
- limit: 1
342
- }
341
+ limit: 1,
342
+ },
343
343
  }.to_json,
344
344
  headers: response_headers
345
345
  )
@@ -363,12 +363,12 @@ describe GoCardlessPro::Services::CreditorsService do
363
363
  'postal_code' => 'postal_code-input',
364
364
  'region' => 'region-input',
365
365
  'scheme_identifiers' => 'scheme_identifiers-input',
366
- 'verification_status' => 'verification_status-input'
366
+ 'verification_status' => 'verification_status-input',
367
367
  }],
368
368
  meta: {
369
369
  limit: 2,
370
- cursors: {}
371
- }
370
+ cursors: {},
371
+ },
372
372
  }.to_json,
373
373
  headers: response_headers
374
374
  )
@@ -401,19 +401,19 @@ describe GoCardlessPro::Services::CreditorsService do
401
401
  'postal_code' => 'postal_code-input',
402
402
  'region' => 'region-input',
403
403
  'scheme_identifiers' => 'scheme_identifiers-input',
404
- 'verification_status' => 'verification_status-input'
404
+ 'verification_status' => 'verification_status-input',
405
405
  }],
406
406
  meta: {
407
407
  cursors: { after: 'AB345' },
408
- limit: 1
409
- }
408
+ limit: 1,
409
+ },
410
410
  }.to_json,
411
411
  headers: response_headers
412
412
  )
413
413
 
414
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345})
415
- .to_timeout.then
416
- .to_return(
414
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345}).
415
+ to_timeout.then.
416
+ to_return(
417
417
  body: {
418
418
  'creditors' => [{
419
419
 
@@ -430,12 +430,12 @@ describe GoCardlessPro::Services::CreditorsService do
430
430
  'postal_code' => 'postal_code-input',
431
431
  'region' => 'region-input',
432
432
  'scheme_identifiers' => 'scheme_identifiers-input',
433
- 'verification_status' => 'verification_status-input'
433
+ 'verification_status' => 'verification_status-input',
434
434
  }],
435
435
  meta: {
436
436
  limit: 2,
437
- cursors: {}
438
- }
437
+ cursors: {},
438
+ },
439
439
  }.to_json,
440
440
  headers: response_headers
441
441
  )
@@ -464,18 +464,18 @@ describe GoCardlessPro::Services::CreditorsService do
464
464
  'postal_code' => 'postal_code-input',
465
465
  'region' => 'region-input',
466
466
  'scheme_identifiers' => 'scheme_identifiers-input',
467
- 'verification_status' => 'verification_status-input'
467
+ 'verification_status' => 'verification_status-input',
468
468
  }],
469
469
  meta: {
470
470
  cursors: { after: 'AB345' },
471
- limit: 1
472
- }
471
+ limit: 1,
472
+ },
473
473
  }.to_json,
474
474
  headers: response_headers
475
475
  )
476
476
 
477
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345})
478
- .to_return(
477
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditors\?after=AB345}).
478
+ to_return(
479
479
  status: 502,
480
480
  body: '<html><body>Response from Cloudflare</body></html>',
481
481
  headers: { 'Content-Type' => 'text/html' }
@@ -496,12 +496,12 @@ describe GoCardlessPro::Services::CreditorsService do
496
496
  'postal_code' => 'postal_code-input',
497
497
  'region' => 'region-input',
498
498
  'scheme_identifiers' => 'scheme_identifiers-input',
499
- 'verification_status' => 'verification_status-input'
499
+ 'verification_status' => 'verification_status-input',
500
500
  }],
501
501
  meta: {
502
502
  limit: 2,
503
- cursors: {}
504
- }
503
+ cursors: {},
504
+ },
505
505
  }.to_json,
506
506
  headers: response_headers
507
507
  )
@@ -522,9 +522,9 @@ describe GoCardlessPro::Services::CreditorsService do
522
522
  context 'passing in a custom header' do
523
523
  let!(:stub) do
524
524
  stub_url = '/creditors/:identity'.gsub(':identity', id)
525
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
526
- .with(headers: { 'Foo' => 'Bar' })
527
- .to_return(
525
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
526
+ with(headers: { 'Foo' => 'Bar' }).
527
+ to_return(
528
528
  body: {
529
529
  'creditors' => {
530
530
 
@@ -541,8 +541,8 @@ describe GoCardlessPro::Services::CreditorsService do
541
541
  'postal_code' => 'postal_code-input',
542
542
  'region' => 'region-input',
543
543
  'scheme_identifiers' => 'scheme_identifiers-input',
544
- 'verification_status' => 'verification_status-input'
545
- }
544
+ 'verification_status' => 'verification_status-input',
545
+ },
546
546
  }.to_json,
547
547
  headers: response_headers
548
548
  )
@@ -550,7 +550,7 @@ describe GoCardlessPro::Services::CreditorsService do
550
550
 
551
551
  subject(:get_response) do
552
552
  client.creditors.get(id, headers: {
553
- 'Foo' => 'Bar'
553
+ 'Foo' => 'Bar',
554
554
  })
555
555
  end
556
556
 
@@ -580,8 +580,8 @@ describe GoCardlessPro::Services::CreditorsService do
580
580
  'postal_code' => 'postal_code-input',
581
581
  'region' => 'region-input',
582
582
  'scheme_identifiers' => 'scheme_identifiers-input',
583
- 'verification_status' => 'verification_status-input'
584
- }
583
+ 'verification_status' => 'verification_status-input',
584
+ },
585
585
  }.to_json,
586
586
  headers: response_headers
587
587
  )
@@ -620,8 +620,8 @@ describe GoCardlessPro::Services::CreditorsService do
620
620
  it 'retries timeouts' do
621
621
  stub_url = '/creditors/:identity'.gsub(':identity', id)
622
622
 
623
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
624
- .to_timeout.then.to_return(status: 200, headers: response_headers)
623
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
624
+ to_timeout.then.to_return(status: 200, headers: response_headers)
625
625
 
626
626
  get_response
627
627
  expect(stub).to have_been_requested.twice
@@ -630,11 +630,11 @@ describe GoCardlessPro::Services::CreditorsService do
630
630
  it 'retries 5XX errors' do
631
631
  stub_url = '/creditors/:identity'.gsub(':identity', id)
632
632
 
633
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
634
- .to_return(status: 502,
635
- headers: { 'Content-Type' => 'text/html' },
636
- body: '<html><body>Response from Cloudflare</body></html>')
637
- .then.to_return(status: 200, headers: response_headers)
633
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
634
+ to_return(status: 502,
635
+ headers: { 'Content-Type' => 'text/html' },
636
+ body: '<html><body>Response from Cloudflare</body></html>').
637
+ then.to_return(status: 200, headers: response_headers)
638
638
 
639
639
  get_response
640
640
  expect(stub).to have_been_requested.twice
@@ -668,8 +668,8 @@ describe GoCardlessPro::Services::CreditorsService do
668
668
  'postal_code' => 'postal_code-input',
669
669
  'region' => 'region-input',
670
670
  'scheme_identifiers' => 'scheme_identifiers-input',
671
- 'verification_status' => 'verification_status-input'
672
- }
671
+ 'verification_status' => 'verification_status-input',
672
+ },
673
673
  }.to_json,
674
674
  headers: response_headers
675
675
  )
@@ -685,8 +685,8 @@ describe GoCardlessPro::Services::CreditorsService do
685
685
 
686
686
  it 'retries timeouts' do
687
687
  stub_url = '/creditors/:identity'.gsub(':identity', id)
688
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
689
- .to_timeout.then.to_return(status: 200, headers: response_headers)
688
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
689
+ to_timeout.then.to_return(status: 200, headers: response_headers)
690
690
 
691
691
  put_update_response
692
692
  expect(stub).to have_been_requested.twice
@@ -694,11 +694,11 @@ describe GoCardlessPro::Services::CreditorsService do
694
694
 
695
695
  it 'retries 5XX errors' do
696
696
  stub_url = '/creditors/:identity'.gsub(':identity', id)
697
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
698
- .to_return(status: 502,
699
- headers: { 'Content-Type' => 'text/html' },
700
- body: '<html><body>Response from Cloudflare</body></html>')
701
- .then.to_return(status: 200, headers: response_headers)
697
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
698
+ to_return(status: 502,
699
+ headers: { 'Content-Type' => 'text/html' },
700
+ body: '<html><body>Response from Cloudflare</body></html>').
701
+ then.to_return(status: 200, headers: response_headers)
702
702
 
703
703
  put_update_response
704
704
  expect(stub).to have_been_requested.twice
@@ -24,13 +24,13 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
24
24
  'enabled' => 'enabled-input',
25
25
  'id' => 'id-input',
26
26
  'links' => 'links-input',
27
- 'metadata' => 'metadata-input'
27
+ 'metadata' => 'metadata-input',
28
28
  }
29
29
  end
30
30
 
31
31
  before do
32
- stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts})
33
- .with(
32
+ stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts}).
33
+ with(
34
34
  body: {
35
35
  'customer_bank_accounts' => {
36
36
 
@@ -43,11 +43,11 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
43
43
  'enabled' => 'enabled-input',
44
44
  'id' => 'id-input',
45
45
  'links' => 'links-input',
46
- 'metadata' => 'metadata-input'
47
- }
46
+ 'metadata' => 'metadata-input',
47
+ },
48
48
  }
49
- )
50
- .to_return(
49
+ ).
50
+ to_return(
51
51
  body: {
52
52
  'customer_bank_accounts' =>
53
53
 
@@ -62,8 +62,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
62
62
  'enabled' => 'enabled-input',
63
63
  'id' => 'id-input',
64
64
  'links' => 'links-input',
65
- 'metadata' => 'metadata-input'
66
- }
65
+ 'metadata' => 'metadata-input',
66
+ },
67
67
 
68
68
  }.to_json,
69
69
  headers: response_headers
@@ -78,19 +78,19 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
78
78
  before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
79
79
 
80
80
  it 'retries timeouts' do
81
- stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts})
82
- .to_timeout.then.to_return(status: 200, headers: response_headers)
81
+ stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts}).
82
+ to_timeout.then.to_return(status: 200, headers: response_headers)
83
83
 
84
84
  post_create_response
85
85
  expect(stub).to have_been_requested.twice
86
86
  end
87
87
 
88
88
  it 'retries 5XX errors' do
89
- stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts})
90
- .to_return(status: 502,
91
- headers: { 'Content-Type' => 'text/html' },
92
- body: '<html><body>Response from Cloudflare</body></html>')
93
- .then.to_return(status: 200, headers: response_headers)
89
+ stub = stub_request(:post, %r{.*api.gocardless.com/customer_bank_accounts}).
90
+ to_return(status: 502,
91
+ headers: { 'Content-Type' => 'text/html' },
92
+ body: '<html><body>Response from Cloudflare</body></html>').
93
+ then.to_return(status: 200, headers: response_headers)
94
94
 
95
95
  post_create_response
96
96
  expect(stub).to have_been_requested.twice
@@ -108,9 +108,9 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
108
108
  type: 'validation_failed',
109
109
  code: 422,
110
110
  errors: [
111
- { message: 'test error message', field: 'test_field' }
112
- ]
113
- }
111
+ { message: 'test error message', field: 'test_field' },
112
+ ],
113
+ },
114
114
  }.to_json,
115
115
  headers: response_headers,
116
116
  status: 422
@@ -137,7 +137,7 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
137
137
  'enabled' => 'enabled-input',
138
138
  'id' => 'id-input',
139
139
  'links' => 'links-input',
140
- 'metadata' => 'metadata-input'
140
+ 'metadata' => 'metadata-input',
141
141
  }
142
142
  end
143
143
 
@@ -152,11 +152,11 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
152
152
  message: 'A resource has already been created with this idempotency key',
153
153
  reason: 'idempotent_creation_conflict',
154
154
  links: {
155
- conflicting_resource_id: id
156
- }
157
- }
158
- ]
159
- }
155
+ conflicting_resource_id: id,
156
+ },
157
+ },
158
+ ],
159
+ },
160
160
  }.to_json,
161
161
  headers: response_headers,
162
162
  status: 409
@@ -165,8 +165,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
165
165
 
166
166
  let!(:get_stub) do
167
167
  stub_url = "/customer_bank_accounts/#{id}"
168
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
169
- .to_return(
168
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
169
+ to_return(
170
170
  body: {
171
171
  'customer_bank_accounts' => {
172
172
 
@@ -179,8 +179,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
179
179
  'enabled' => 'enabled-input',
180
180
  'id' => 'id-input',
181
181
  'links' => 'links-input',
182
- 'metadata' => 'metadata-input'
183
- }
182
+ 'metadata' => 'metadata-input',
183
+ },
184
184
  }.to_json,
185
185
  headers: response_headers
186
186
  )
@@ -211,14 +211,14 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
211
211
  'enabled' => 'enabled-input',
212
212
  'id' => 'id-input',
213
213
  'links' => 'links-input',
214
- 'metadata' => 'metadata-input'
214
+ 'metadata' => 'metadata-input',
215
215
  }],
216
216
  meta: {
217
217
  cursors: {
218
218
  before: nil,
219
- after: 'ABC123'
220
- }
221
- }
219
+ after: 'ABC123',
220
+ },
221
+ },
222
222
  }.to_json
223
223
  end
224
224
 
@@ -262,19 +262,19 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
262
262
  before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
263
263
 
264
264
  it 'retries timeouts' do
265
- stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts})
266
- .to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
265
+ stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts}).
266
+ to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
267
267
 
268
268
  get_list_response
269
269
  expect(stub).to have_been_requested.twice
270
270
  end
271
271
 
272
272
  it 'retries 5XX errors' do
273
- stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts})
274
- .to_return(status: 502,
275
- headers: { 'Content-Type' => 'text/html' },
276
- body: '<html><body>Response from Cloudflare</body></html>')
277
- .then.to_return(status: 200, headers: response_headers, body: body)
273
+ stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts}).
274
+ to_return(status: 502,
275
+ headers: { 'Content-Type' => 'text/html' },
276
+ body: '<html><body>Response from Cloudflare</body></html>').
277
+ then.to_return(status: 200, headers: response_headers, body: body)
278
278
 
279
279
  get_list_response
280
280
  expect(stub).to have_been_requested.twice
@@ -298,12 +298,12 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
298
298
  'enabled' => 'enabled-input',
299
299
  'id' => 'id-input',
300
300
  'links' => 'links-input',
301
- 'metadata' => 'metadata-input'
301
+ 'metadata' => 'metadata-input',
302
302
  }],
303
303
  meta: {
304
304
  cursors: { after: 'AB345' },
305
- limit: 1
306
- }
305
+ limit: 1,
306
+ },
307
307
  }.to_json,
308
308
  headers: response_headers
309
309
  )
@@ -323,12 +323,12 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
323
323
  'enabled' => 'enabled-input',
324
324
  'id' => 'id-input',
325
325
  'links' => 'links-input',
326
- 'metadata' => 'metadata-input'
326
+ 'metadata' => 'metadata-input',
327
327
  }],
328
328
  meta: {
329
329
  limit: 2,
330
- cursors: {}
331
- }
330
+ cursors: {},
331
+ },
332
332
  }.to_json,
333
333
  headers: response_headers
334
334
  )
@@ -357,19 +357,19 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
357
357
  'enabled' => 'enabled-input',
358
358
  'id' => 'id-input',
359
359
  'links' => 'links-input',
360
- 'metadata' => 'metadata-input'
360
+ 'metadata' => 'metadata-input',
361
361
  }],
362
362
  meta: {
363
363
  cursors: { after: 'AB345' },
364
- limit: 1
365
- }
364
+ limit: 1,
365
+ },
366
366
  }.to_json,
367
367
  headers: response_headers
368
368
  )
369
369
 
370
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345})
371
- .to_timeout.then
372
- .to_return(
370
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345}).
371
+ to_timeout.then.
372
+ to_return(
373
373
  body: {
374
374
  'customer_bank_accounts' => [{
375
375
 
@@ -382,12 +382,12 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
382
382
  'enabled' => 'enabled-input',
383
383
  'id' => 'id-input',
384
384
  'links' => 'links-input',
385
- 'metadata' => 'metadata-input'
385
+ 'metadata' => 'metadata-input',
386
386
  }],
387
387
  meta: {
388
388
  limit: 2,
389
- cursors: {}
390
- }
389
+ cursors: {},
390
+ },
391
391
  }.to_json,
392
392
  headers: response_headers
393
393
  )
@@ -412,18 +412,18 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
412
412
  'enabled' => 'enabled-input',
413
413
  'id' => 'id-input',
414
414
  'links' => 'links-input',
415
- 'metadata' => 'metadata-input'
415
+ 'metadata' => 'metadata-input',
416
416
  }],
417
417
  meta: {
418
418
  cursors: { after: 'AB345' },
419
- limit: 1
420
- }
419
+ limit: 1,
420
+ },
421
421
  }.to_json,
422
422
  headers: response_headers
423
423
  )
424
424
 
425
- second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345})
426
- .to_return(
425
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customer_bank_accounts\?after=AB345}).
426
+ to_return(
427
427
  status: 502,
428
428
  body: '<html><body>Response from Cloudflare</body></html>',
429
429
  headers: { 'Content-Type' => 'text/html' }
@@ -440,12 +440,12 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
440
440
  'enabled' => 'enabled-input',
441
441
  'id' => 'id-input',
442
442
  'links' => 'links-input',
443
- 'metadata' => 'metadata-input'
443
+ 'metadata' => 'metadata-input',
444
444
  }],
445
445
  meta: {
446
446
  limit: 2,
447
- cursors: {}
448
- }
447
+ cursors: {},
448
+ },
449
449
  }.to_json,
450
450
  headers: response_headers
451
451
  )
@@ -466,9 +466,9 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
466
466
  context 'passing in a custom header' do
467
467
  let!(:stub) do
468
468
  stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
469
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
470
- .with(headers: { 'Foo' => 'Bar' })
471
- .to_return(
469
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
470
+ with(headers: { 'Foo' => 'Bar' }).
471
+ to_return(
472
472
  body: {
473
473
  'customer_bank_accounts' => {
474
474
 
@@ -481,8 +481,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
481
481
  'enabled' => 'enabled-input',
482
482
  'id' => 'id-input',
483
483
  'links' => 'links-input',
484
- 'metadata' => 'metadata-input'
485
- }
484
+ 'metadata' => 'metadata-input',
485
+ },
486
486
  }.to_json,
487
487
  headers: response_headers
488
488
  )
@@ -490,7 +490,7 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
490
490
 
491
491
  subject(:get_response) do
492
492
  client.customer_bank_accounts.get(id, headers: {
493
- 'Foo' => 'Bar'
493
+ 'Foo' => 'Bar',
494
494
  })
495
495
  end
496
496
 
@@ -516,8 +516,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
516
516
  'enabled' => 'enabled-input',
517
517
  'id' => 'id-input',
518
518
  'links' => 'links-input',
519
- 'metadata' => 'metadata-input'
520
- }
519
+ 'metadata' => 'metadata-input',
520
+ },
521
521
  }.to_json,
522
522
  headers: response_headers
523
523
  )
@@ -556,8 +556,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
556
556
  it 'retries timeouts' do
557
557
  stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
558
558
 
559
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
560
- .to_timeout.then.to_return(status: 200, headers: response_headers)
559
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
560
+ to_timeout.then.to_return(status: 200, headers: response_headers)
561
561
 
562
562
  get_response
563
563
  expect(stub).to have_been_requested.twice
@@ -566,11 +566,11 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
566
566
  it 'retries 5XX errors' do
567
567
  stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
568
568
 
569
- stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
570
- .to_return(status: 502,
571
- headers: { 'Content-Type' => 'text/html' },
572
- body: '<html><body>Response from Cloudflare</body></html>')
573
- .then.to_return(status: 200, headers: response_headers)
569
+ stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
570
+ to_return(status: 502,
571
+ headers: { 'Content-Type' => 'text/html' },
572
+ body: '<html><body>Response from Cloudflare</body></html>').
573
+ then.to_return(status: 200, headers: response_headers)
574
574
 
575
575
  get_response
576
576
  expect(stub).to have_been_requested.twice
@@ -600,8 +600,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
600
600
  'enabled' => 'enabled-input',
601
601
  'id' => 'id-input',
602
602
  'links' => 'links-input',
603
- 'metadata' => 'metadata-input'
604
- }
603
+ 'metadata' => 'metadata-input',
604
+ },
605
605
  }.to_json,
606
606
  headers: response_headers
607
607
  )
@@ -617,8 +617,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
617
617
 
618
618
  it 'retries timeouts' do
619
619
  stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
620
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
621
- .to_timeout.then.to_return(status: 200, headers: response_headers)
620
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
621
+ to_timeout.then.to_return(status: 200, headers: response_headers)
622
622
 
623
623
  put_update_response
624
624
  expect(stub).to have_been_requested.twice
@@ -626,11 +626,11 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
626
626
 
627
627
  it 'retries 5XX errors' do
628
628
  stub_url = '/customer_bank_accounts/:identity'.gsub(':identity', id)
629
- stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
630
- .to_return(status: 502,
631
- headers: { 'Content-Type' => 'text/html' },
632
- body: '<html><body>Response from Cloudflare</body></html>')
633
- .then.to_return(status: 200, headers: response_headers)
629
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
630
+ to_return(status: 502,
631
+ headers: { 'Content-Type' => 'text/html' },
632
+ body: '<html><body>Response from Cloudflare</body></html>').
633
+ then.to_return(status: 200, headers: response_headers)
634
634
 
635
635
  put_update_response
636
636
  expect(stub).to have_been_requested.twice
@@ -660,8 +660,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
660
660
  'enabled' => 'enabled-input',
661
661
  'id' => 'id-input',
662
662
  'links' => 'links-input',
663
- 'metadata' => 'metadata-input'
664
- }
663
+ 'metadata' => 'metadata-input',
664
+ },
665
665
  }.to_json,
666
666
  headers: response_headers
667
667
  )
@@ -676,8 +676,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
676
676
  describe 'retry behaviour' do
677
677
  it "doesn't retry errors" do
678
678
  stub_url = '/customer_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
679
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
680
- .to_timeout
679
+ stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
680
+ to_timeout
681
681
 
682
682
  expect { post_response }.to raise_error(Faraday::TimeoutError)
683
683
  expect(stub).to have_been_requested
@@ -694,8 +694,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
694
694
  let!(:stub) do
695
695
  # /customer_bank_accounts/%v/actions/disable
696
696
  stub_url = '/customer_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
697
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
698
- .with(
697
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
698
+ with(
699
699
  body: { foo: 'bar' },
700
700
  headers: { 'Foo' => 'Bar' }
701
701
  ).to_return(
@@ -711,8 +711,8 @@ describe GoCardlessPro::Services::CustomerBankAccountsService do
711
711
  'enabled' => 'enabled-input',
712
712
  'id' => 'id-input',
713
713
  'links' => 'links-input',
714
- 'metadata' => 'metadata-input'
715
- }
714
+ 'metadata' => 'metadata-input',
715
+ },
716
716
  }.to_json,
717
717
  headers: response_headers
718
718
  )