gocardless_pro 2.1.0 → 2.2.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 (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
@@ -30,13 +30,13 @@ describe GoCardlessPro::Resources::Subscription do
30
30
  'payment_reference' => 'payment_reference-input',
31
31
  'start_date' => 'start_date-input',
32
32
  'status' => 'status-input',
33
- 'upcoming_payments' => 'upcoming_payments-input'
33
+ 'upcoming_payments' => 'upcoming_payments-input',
34
34
  }
35
35
  end
36
36
 
37
37
  before do
38
- stub_request(:post, %r{.*api.gocardless.com/subscriptions})
39
- .with(
38
+ stub_request(:post, %r{.*api.gocardless.com/subscriptions}).
39
+ with(
40
40
  body: {
41
41
  'subscriptions' => {
42
42
 
@@ -55,11 +55,11 @@ describe GoCardlessPro::Resources::Subscription do
55
55
  'payment_reference' => 'payment_reference-input',
56
56
  'start_date' => 'start_date-input',
57
57
  'status' => 'status-input',
58
- 'upcoming_payments' => 'upcoming_payments-input'
59
- }
58
+ 'upcoming_payments' => 'upcoming_payments-input',
59
+ },
60
60
  }
61
- )
62
- .to_return(
61
+ ).
62
+ to_return(
63
63
  body: {
64
64
  'subscriptions' =>
65
65
 
@@ -80,8 +80,8 @@ describe GoCardlessPro::Resources::Subscription do
80
80
  'payment_reference' => 'payment_reference-input',
81
81
  'start_date' => 'start_date-input',
82
82
  'status' => 'status-input',
83
- 'upcoming_payments' => 'upcoming_payments-input'
84
- }
83
+ 'upcoming_payments' => 'upcoming_payments-input',
84
+ },
85
85
 
86
86
  }.to_json,
87
87
  headers: response_headers
@@ -103,9 +103,9 @@ describe GoCardlessPro::Resources::Subscription do
103
103
  type: 'validation_failed',
104
104
  code: 422,
105
105
  errors: [
106
- { message: 'test error message', field: 'test_field' }
107
- ]
108
- }
106
+ { message: 'test error message', field: 'test_field' },
107
+ ],
108
+ },
109
109
  }.to_json,
110
110
  headers: response_headers,
111
111
  status: 422
@@ -138,7 +138,7 @@ describe GoCardlessPro::Resources::Subscription do
138
138
  'payment_reference' => 'payment_reference-input',
139
139
  'start_date' => 'start_date-input',
140
140
  'status' => 'status-input',
141
- 'upcoming_payments' => 'upcoming_payments-input'
141
+ 'upcoming_payments' => 'upcoming_payments-input',
142
142
  }
143
143
  end
144
144
 
@@ -153,11 +153,11 @@ describe GoCardlessPro::Resources::Subscription do
153
153
  message: 'A resource has already been created with this idempotency key',
154
154
  reason: 'idempotent_creation_conflict',
155
155
  links: {
156
- conflicting_resource_id: id
157
- }
158
- }
159
- ]
160
- }
156
+ conflicting_resource_id: id,
157
+ },
158
+ },
159
+ ],
160
+ },
161
161
  }.to_json,
162
162
  headers: response_headers,
163
163
  status: 409
@@ -166,8 +166,8 @@ describe GoCardlessPro::Resources::Subscription do
166
166
 
167
167
  let!(:get_stub) do
168
168
  stub_url = "/subscriptions/#{id}"
169
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
170
- .to_return(
169
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
170
+ to_return(
171
171
  body: {
172
172
  'subscriptions' => {
173
173
 
@@ -186,8 +186,8 @@ describe GoCardlessPro::Resources::Subscription do
186
186
  'payment_reference' => 'payment_reference-input',
187
187
  'start_date' => 'start_date-input',
188
188
  'status' => 'status-input',
189
- 'upcoming_payments' => 'upcoming_payments-input'
190
- }
189
+ 'upcoming_payments' => 'upcoming_payments-input',
190
+ },
191
191
  }.to_json,
192
192
  headers: response_headers
193
193
  )
@@ -225,14 +225,14 @@ describe GoCardlessPro::Resources::Subscription do
225
225
  'payment_reference' => 'payment_reference-input',
226
226
  'start_date' => 'start_date-input',
227
227
  'status' => 'status-input',
228
- 'upcoming_payments' => 'upcoming_payments-input'
228
+ 'upcoming_payments' => 'upcoming_payments-input',
229
229
  }],
230
230
  meta: {
231
231
  cursors: {
232
232
  before: nil,
233
- after: 'ABC123'
234
- }
235
- }
233
+ after: 'ABC123',
234
+ },
235
+ },
236
236
  }.to_json,
237
237
  headers: response_headers
238
238
  )
@@ -302,12 +302,12 @@ describe GoCardlessPro::Resources::Subscription do
302
302
  'payment_reference' => 'payment_reference-input',
303
303
  'start_date' => 'start_date-input',
304
304
  'status' => 'status-input',
305
- 'upcoming_payments' => 'upcoming_payments-input'
305
+ 'upcoming_payments' => 'upcoming_payments-input',
306
306
  }],
307
307
  meta: {
308
308
  cursors: { after: 'AB345' },
309
- limit: 1
310
- }
309
+ limit: 1,
310
+ },
311
311
  }.to_json,
312
312
  headers: response_headers
313
313
  )
@@ -333,12 +333,12 @@ describe GoCardlessPro::Resources::Subscription do
333
333
  'payment_reference' => 'payment_reference-input',
334
334
  'start_date' => 'start_date-input',
335
335
  'status' => 'status-input',
336
- 'upcoming_payments' => 'upcoming_payments-input'
336
+ 'upcoming_payments' => 'upcoming_payments-input',
337
337
  }],
338
338
  meta: {
339
339
  limit: 2,
340
- cursors: {}
341
- }
340
+ cursors: {},
341
+ },
342
342
  }.to_json,
343
343
  headers: response_headers
344
344
  )
@@ -359,9 +359,9 @@ describe GoCardlessPro::Resources::Subscription do
359
359
  context 'passing in a custom header' do
360
360
  let!(:stub) do
361
361
  stub_url = '/subscriptions/:identity'.gsub(':identity', id)
362
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
363
- .with(headers: { 'Foo' => 'Bar' })
364
- .to_return(
362
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
363
+ with(headers: { 'Foo' => 'Bar' }).
364
+ to_return(
365
365
  body: {
366
366
  'subscriptions' => {
367
367
 
@@ -380,8 +380,8 @@ describe GoCardlessPro::Resources::Subscription do
380
380
  'payment_reference' => 'payment_reference-input',
381
381
  'start_date' => 'start_date-input',
382
382
  'status' => 'status-input',
383
- 'upcoming_payments' => 'upcoming_payments-input'
384
- }
383
+ 'upcoming_payments' => 'upcoming_payments-input',
384
+ },
385
385
  }.to_json,
386
386
  headers: response_headers
387
387
  )
@@ -389,7 +389,7 @@ describe GoCardlessPro::Resources::Subscription do
389
389
 
390
390
  subject(:get_response) do
391
391
  client.subscriptions.get(id, headers: {
392
- 'Foo' => 'Bar'
392
+ 'Foo' => 'Bar',
393
393
  })
394
394
  end
395
395
 
@@ -421,8 +421,8 @@ describe GoCardlessPro::Resources::Subscription do
421
421
  'payment_reference' => 'payment_reference-input',
422
422
  'start_date' => 'start_date-input',
423
423
  'status' => 'status-input',
424
- 'upcoming_payments' => 'upcoming_payments-input'
425
- }
424
+ 'upcoming_payments' => 'upcoming_payments-input',
425
+ },
426
426
  }.to_json,
427
427
  headers: response_headers
428
428
  )
@@ -484,8 +484,8 @@ describe GoCardlessPro::Resources::Subscription do
484
484
  'payment_reference' => 'payment_reference-input',
485
485
  'start_date' => 'start_date-input',
486
486
  'status' => 'status-input',
487
- 'upcoming_payments' => 'upcoming_payments-input'
488
- }
487
+ 'upcoming_payments' => 'upcoming_payments-input',
488
+ },
489
489
  }.to_json,
490
490
  headers: response_headers
491
491
  )
@@ -525,8 +525,8 @@ describe GoCardlessPro::Resources::Subscription do
525
525
  'payment_reference' => 'payment_reference-input',
526
526
  'start_date' => 'start_date-input',
527
527
  'status' => 'status-input',
528
- 'upcoming_payments' => 'upcoming_payments-input'
529
- }
528
+ 'upcoming_payments' => 'upcoming_payments-input',
529
+ },
530
530
  }.to_json,
531
531
  headers: response_headers
532
532
  )
@@ -548,8 +548,8 @@ describe GoCardlessPro::Resources::Subscription do
548
548
  let!(:stub) do
549
549
  # /subscriptions/%v/actions/cancel
550
550
  stub_url = '/subscriptions/:identity/actions/cancel'.gsub(':identity', resource_id)
551
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
552
- .with(
551
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
552
+ with(
553
553
  body: { foo: 'bar' },
554
554
  headers: { 'Foo' => 'Bar' }
555
555
  ).to_return(
@@ -571,8 +571,8 @@ describe GoCardlessPro::Resources::Subscription do
571
571
  'payment_reference' => 'payment_reference-input',
572
572
  'start_date' => 'start_date-input',
573
573
  'status' => 'status-input',
574
- 'upcoming_payments' => 'upcoming_payments-input'
575
- }
574
+ 'upcoming_payments' => 'upcoming_payments-input',
575
+ },
576
576
  }.to_json,
577
577
  headers: response_headers
578
578
  )
@@ -14,8 +14,7 @@ describe GoCardlessPro::Response do
14
14
  double('response',
15
15
  headers: default_headers,
16
16
  status: 200,
17
- body: { customers: [] }.to_json
18
- )
17
+ body: { customers: [] }.to_json)
19
18
  end
20
19
 
21
20
  it 'returns the body parsed into a hash' do
@@ -17,23 +17,23 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
17
17
 
18
18
  'available_debit_schemes' => 'available_debit_schemes-input',
19
19
  'bank_name' => 'bank_name-input',
20
- 'bic' => 'bic-input'
20
+ 'bic' => 'bic-input',
21
21
  }
22
22
  end
23
23
 
24
24
  before do
25
- stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups})
26
- .with(
25
+ stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups}).
26
+ with(
27
27
  body: {
28
28
  'bank_details_lookups' => {
29
29
 
30
30
  'available_debit_schemes' => 'available_debit_schemes-input',
31
31
  'bank_name' => 'bank_name-input',
32
- 'bic' => 'bic-input'
33
- }
32
+ 'bic' => 'bic-input',
33
+ },
34
34
  }
35
- )
36
- .to_return(
35
+ ).
36
+ to_return(
37
37
  body: {
38
38
  'bank_details_lookups' =>
39
39
 
@@ -41,8 +41,8 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
41
41
 
42
42
  'available_debit_schemes' => 'available_debit_schemes-input',
43
43
  'bank_name' => 'bank_name-input',
44
- 'bic' => 'bic-input'
45
- }
44
+ 'bic' => 'bic-input',
45
+ },
46
46
 
47
47
  }.to_json,
48
48
  headers: response_headers
@@ -57,19 +57,19 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
57
57
  before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
58
58
 
59
59
  it 'retries timeouts' do
60
- stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups})
61
- .to_timeout.then.to_return(status: 200, headers: response_headers)
60
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups}).
61
+ to_timeout.then.to_return(status: 200, headers: response_headers)
62
62
 
63
63
  post_create_response
64
64
  expect(stub).to have_been_requested.twice
65
65
  end
66
66
 
67
67
  it 'retries 5XX errors' do
68
- stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups})
69
- .to_return(status: 502,
70
- headers: { 'Content-Type' => 'text/html' },
71
- body: '<html><body>Response from Cloudflare</body></html>')
72
- .then.to_return(status: 200, headers: response_headers)
68
+ stub = stub_request(:post, %r{.*api.gocardless.com/bank_details_lookups}).
69
+ to_return(status: 502,
70
+ headers: { 'Content-Type' => 'text/html' },
71
+ body: '<html><body>Response from Cloudflare</body></html>').
72
+ then.to_return(status: 200, headers: response_headers)
73
73
 
74
74
  post_create_response
75
75
  expect(stub).to have_been_requested.twice
@@ -87,9 +87,9 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
87
87
  type: 'validation_failed',
88
88
  code: 422,
89
89
  errors: [
90
- { message: 'test error message', field: 'test_field' }
91
- ]
92
- }
90
+ { message: 'test error message', field: 'test_field' },
91
+ ],
92
+ },
93
93
  }.to_json,
94
94
  headers: response_headers,
95
95
  status: 422
@@ -109,7 +109,7 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
109
109
 
110
110
  'available_debit_schemes' => 'available_debit_schemes-input',
111
111
  'bank_name' => 'bank_name-input',
112
- 'bic' => 'bic-input'
112
+ 'bic' => 'bic-input',
113
113
  }
114
114
  end
115
115
 
@@ -124,11 +124,11 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
124
124
  message: 'A resource has already been created with this idempotency key',
125
125
  reason: 'idempotent_creation_conflict',
126
126
  links: {
127
- conflicting_resource_id: id
128
- }
129
- }
130
- ]
131
- }
127
+ conflicting_resource_id: id,
128
+ },
129
+ },
130
+ ],
131
+ },
132
132
  }.to_json,
133
133
  headers: response_headers,
134
134
  status: 409
@@ -24,13 +24,13 @@ describe GoCardlessPro::Services::CreditorBankAccountsService 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/creditor_bank_accounts})
33
- .with(
32
+ stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).
33
+ with(
34
34
  body: {
35
35
  'creditor_bank_accounts' => {
36
36
 
@@ -43,11 +43,11 @@ describe GoCardlessPro::Services::CreditorBankAccountsService 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
  'creditor_bank_accounts' =>
53
53
 
@@ -62,8 +62,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService 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::CreditorBankAccountsService 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/creditor_bank_accounts})
82
- .to_timeout.then.to_return(status: 200, headers: response_headers)
81
+ stub = stub_request(:post, %r{.*api.gocardless.com/creditor_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/creditor_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/creditor_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::CreditorBankAccountsService 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::CreditorBankAccountsService 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::CreditorBankAccountsService 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::CreditorBankAccountsService do
165
165
 
166
166
  let!(:get_stub) do
167
167
  stub_url = "/creditor_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
  'creditor_bank_accounts' => {
172
172
 
@@ -179,8 +179,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService 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::CreditorBankAccountsService 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::CreditorBankAccountsService 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/creditor_bank_accounts})
266
- .to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
265
+ stub = stub_request(:get, %r{.*api.gocardless.com/creditor_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/creditor_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/creditor_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::CreditorBankAccountsService 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::CreditorBankAccountsService 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::CreditorBankAccountsService 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/creditor_bank_accounts\?after=AB345})
371
- .to_timeout.then
372
- .to_return(
370
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts\?after=AB345}).
371
+ to_timeout.then.
372
+ to_return(
373
373
  body: {
374
374
  'creditor_bank_accounts' => [{
375
375
 
@@ -382,12 +382,12 @@ describe GoCardlessPro::Services::CreditorBankAccountsService 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::CreditorBankAccountsService 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/creditor_bank_accounts\?after=AB345})
426
- .to_return(
425
+ second_response_stub = stub_request(:get, %r{.*api.gocardless.com/creditor_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::CreditorBankAccountsService 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::CreditorBankAccountsService do
466
466
  context 'passing in a custom header' do
467
467
  let!(:stub) do
468
468
  stub_url = '/creditor_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
  'creditor_bank_accounts' => {
474
474
 
@@ -481,8 +481,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService 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::CreditorBankAccountsService do
490
490
 
491
491
  subject(:get_response) do
492
492
  client.creditor_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::CreditorBankAccountsService 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::CreditorBankAccountsService do
556
556
  it 'retries timeouts' do
557
557
  stub_url = '/creditor_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::CreditorBankAccountsService do
566
566
  it 'retries 5XX errors' do
567
567
  stub_url = '/creditor_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
@@ -599,8 +599,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
599
599
  'enabled' => 'enabled-input',
600
600
  'id' => 'id-input',
601
601
  'links' => 'links-input',
602
- 'metadata' => 'metadata-input'
603
- }
602
+ 'metadata' => 'metadata-input',
603
+ },
604
604
  }.to_json,
605
605
  headers: response_headers
606
606
  )
@@ -615,8 +615,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
615
615
  describe 'retry behaviour' do
616
616
  it "doesn't retry errors" do
617
617
  stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
618
- stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/)
619
- .to_timeout
618
+ stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
619
+ to_timeout
620
620
 
621
621
  expect { post_response }.to raise_error(Faraday::TimeoutError)
622
622
  expect(stub).to have_been_requested
@@ -633,8 +633,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
633
633
  let!(:stub) do
634
634
  # /creditor_bank_accounts/%v/actions/disable
635
635
  stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
636
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
637
- .with(
636
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
637
+ with(
638
638
  body: { foo: 'bar' },
639
639
  headers: { 'Foo' => 'Bar' }
640
640
  ).to_return(
@@ -650,8 +650,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
650
650
  'enabled' => 'enabled-input',
651
651
  'id' => 'id-input',
652
652
  'links' => 'links-input',
653
- 'metadata' => 'metadata-input'
654
- }
653
+ 'metadata' => 'metadata-input',
654
+ },
655
655
  }.to_json,
656
656
  headers: response_headers
657
657
  )