gocardless_pro 2.18.1 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +25 -43
  3. data/Gemfile +7 -0
  4. data/gocardless_pro.gemspec +2 -2
  5. data/lib/gocardless_pro/api_service.rb +1 -1
  6. data/lib/gocardless_pro/client.rb +1 -1
  7. data/lib/gocardless_pro/resources/payout.rb +2 -0
  8. data/lib/gocardless_pro/services/bank_details_lookups_service.rb +0 -10
  9. data/lib/gocardless_pro/services/base_service.rb +11 -0
  10. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +0 -10
  11. data/lib/gocardless_pro/services/creditors_service.rb +0 -10
  12. data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +0 -10
  13. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +0 -10
  14. data/lib/gocardless_pro/services/customer_notifications_service.rb +0 -10
  15. data/lib/gocardless_pro/services/customers_service.rb +0 -10
  16. data/lib/gocardless_pro/services/events_service.rb +0 -10
  17. data/lib/gocardless_pro/services/instalment_schedules_service.rb +21 -10
  18. data/lib/gocardless_pro/services/mandate_import_entries_service.rb +0 -10
  19. data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -10
  20. data/lib/gocardless_pro/services/mandate_pdfs_service.rb +0 -10
  21. data/lib/gocardless_pro/services/mandates_service.rb +0 -10
  22. data/lib/gocardless_pro/services/payments_service.rb +0 -10
  23. data/lib/gocardless_pro/services/payout_items_service.rb +0 -10
  24. data/lib/gocardless_pro/services/payouts_service.rb +21 -10
  25. data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -10
  26. data/lib/gocardless_pro/services/refunds_service.rb +6 -11
  27. data/lib/gocardless_pro/services/subscriptions_service.rb +21 -16
  28. data/lib/gocardless_pro/version.rb +1 -1
  29. data/spec/resources/instalment_schedule_spec.rb +35 -0
  30. data/spec/resources/payout_spec.rb +45 -0
  31. data/spec/services/creditor_bank_accounts_service_spec.rb +1 -1
  32. data/spec/services/customer_bank_accounts_service_spec.rb +1 -1
  33. data/spec/services/customer_notifications_service_spec.rb +1 -1
  34. data/spec/services/customers_service_spec.rb +1 -1
  35. data/spec/services/instalment_schedules_service_spec.rb +61 -1
  36. data/spec/services/mandate_imports_service_spec.rb +2 -2
  37. data/spec/services/mandates_service_spec.rb +2 -2
  38. data/spec/services/payments_service_spec.rb +2 -2
  39. data/spec/services/payouts_service_spec.rb +74 -0
  40. data/spec/services/redirect_flows_service_spec.rb +1 -1
  41. data/spec/services/subscriptions_service_spec.rb +3 -3
  42. metadata +7 -7
@@ -363,7 +363,7 @@ describe GoCardlessPro::Services::MandateImportsService do
363
363
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
364
364
  to_timeout
365
365
 
366
- expect { post_response }.to raise_error(Faraday::TimeoutError)
366
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
367
367
  expect(stub).to have_been_requested
368
368
  end
369
369
  end
@@ -432,7 +432,7 @@ describe GoCardlessPro::Services::MandateImportsService do
432
432
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
433
433
  to_timeout
434
434
 
435
- expect { post_response }.to raise_error(Faraday::TimeoutError)
435
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
436
436
  expect(stub).to have_been_requested
437
437
  end
438
438
  end
@@ -718,7 +718,7 @@ describe GoCardlessPro::Services::MandatesService do
718
718
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
719
719
  to_timeout
720
720
 
721
- expect { post_response }.to raise_error(Faraday::TimeoutError)
721
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
722
722
  expect(stub).to have_been_requested
723
723
  end
724
724
  end
@@ -797,7 +797,7 @@ describe GoCardlessPro::Services::MandatesService do
797
797
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
798
798
  to_timeout
799
799
 
800
- expect { post_response }.to raise_error(Faraday::TimeoutError)
800
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
801
801
  expect(stub).to have_been_requested
802
802
  end
803
803
  end
@@ -790,7 +790,7 @@ describe GoCardlessPro::Services::PaymentsService do
790
790
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
791
791
  to_timeout
792
792
 
793
- expect { post_response }.to raise_error(Faraday::TimeoutError)
793
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
794
794
  expect(stub).to have_been_requested
795
795
  end
796
796
  end
@@ -877,7 +877,7 @@ describe GoCardlessPro::Services::PaymentsService do
877
877
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
878
878
  to_timeout
879
879
 
880
- expect { post_response }.to raise_error(Faraday::TimeoutError)
880
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
881
881
  expect(stub).to have_been_requested
882
882
  end
883
883
  end
@@ -25,6 +25,7 @@ describe GoCardlessPro::Services::PayoutsService do
25
25
  'fx' => 'fx-input',
26
26
  'id' => 'id-input',
27
27
  'links' => 'links-input',
28
+ 'metadata' => 'metadata-input',
28
29
  'payout_type' => 'payout_type-input',
29
30
  'reference' => 'reference-input',
30
31
  'status' => 'status-input',
@@ -62,6 +63,8 @@ describe GoCardlessPro::Services::PayoutsService do
62
63
 
63
64
  expect(get_list_response.records.first.id).to eq('id-input')
64
65
 
66
+ expect(get_list_response.records.first.metadata).to eq('metadata-input')
67
+
65
68
  expect(get_list_response.records.first.payout_type).to eq('payout_type-input')
66
69
 
67
70
  expect(get_list_response.records.first.reference).to eq('reference-input')
@@ -115,6 +118,7 @@ describe GoCardlessPro::Services::PayoutsService do
115
118
  'fx' => 'fx-input',
116
119
  'id' => 'id-input',
117
120
  'links' => 'links-input',
121
+ 'metadata' => 'metadata-input',
118
122
  'payout_type' => 'payout_type-input',
119
123
  'reference' => 'reference-input',
120
124
  'status' => 'status-input',
@@ -141,6 +145,7 @@ describe GoCardlessPro::Services::PayoutsService do
141
145
  'fx' => 'fx-input',
142
146
  'id' => 'id-input',
143
147
  'links' => 'links-input',
148
+ 'metadata' => 'metadata-input',
144
149
  'payout_type' => 'payout_type-input',
145
150
  'reference' => 'reference-input',
146
151
  'status' => 'status-input',
@@ -176,6 +181,7 @@ describe GoCardlessPro::Services::PayoutsService do
176
181
  'fx' => 'fx-input',
177
182
  'id' => 'id-input',
178
183
  'links' => 'links-input',
184
+ 'metadata' => 'metadata-input',
179
185
  'payout_type' => 'payout_type-input',
180
186
  'reference' => 'reference-input',
181
187
  'status' => 'status-input',
@@ -202,6 +208,7 @@ describe GoCardlessPro::Services::PayoutsService do
202
208
  'fx' => 'fx-input',
203
209
  'id' => 'id-input',
204
210
  'links' => 'links-input',
211
+ 'metadata' => 'metadata-input',
205
212
  'payout_type' => 'payout_type-input',
206
213
  'reference' => 'reference-input',
207
214
  'status' => 'status-input',
@@ -233,6 +240,7 @@ describe GoCardlessPro::Services::PayoutsService do
233
240
  'fx' => 'fx-input',
234
241
  'id' => 'id-input',
235
242
  'links' => 'links-input',
243
+ 'metadata' => 'metadata-input',
236
244
  'payout_type' => 'payout_type-input',
237
245
  'reference' => 'reference-input',
238
246
  'status' => 'status-input',
@@ -262,6 +270,7 @@ describe GoCardlessPro::Services::PayoutsService do
262
270
  'fx' => 'fx-input',
263
271
  'id' => 'id-input',
264
272
  'links' => 'links-input',
273
+ 'metadata' => 'metadata-input',
265
274
  'payout_type' => 'payout_type-input',
266
275
  'reference' => 'reference-input',
267
276
  'status' => 'status-input',
@@ -304,6 +313,7 @@ describe GoCardlessPro::Services::PayoutsService do
304
313
  'fx' => 'fx-input',
305
314
  'id' => 'id-input',
306
315
  'links' => 'links-input',
316
+ 'metadata' => 'metadata-input',
307
317
  'payout_type' => 'payout_type-input',
308
318
  'reference' => 'reference-input',
309
319
  'status' => 'status-input',
@@ -340,6 +350,7 @@ describe GoCardlessPro::Services::PayoutsService do
340
350
  'fx' => 'fx-input',
341
351
  'id' => 'id-input',
342
352
  'links' => 'links-input',
353
+ 'metadata' => 'metadata-input',
343
354
  'payout_type' => 'payout_type-input',
344
355
  'reference' => 'reference-input',
345
356
  'status' => 'status-input',
@@ -431,4 +442,67 @@ describe GoCardlessPro::Services::PayoutsService do
431
442
  end
432
443
  end
433
444
  end
445
+
446
+ describe '#update' do
447
+ subject(:put_update_response) { client.payouts.update(id, params: update_params) }
448
+ let(:id) { 'ABC123' }
449
+
450
+ context 'with a valid request' do
451
+ let(:update_params) { { 'hello' => 'world' } }
452
+
453
+ let!(:stub) do
454
+ stub_url = '/payouts/:identity'.gsub(':identity', id)
455
+ stub_request(:put, /.*api.gocardless.com#{stub_url}/).to_return(
456
+ body: {
457
+ 'payouts' => {
458
+
459
+ 'amount' => 'amount-input',
460
+ 'arrival_date' => 'arrival_date-input',
461
+ 'created_at' => 'created_at-input',
462
+ 'currency' => 'currency-input',
463
+ 'deducted_fees' => 'deducted_fees-input',
464
+ 'fx' => 'fx-input',
465
+ 'id' => 'id-input',
466
+ 'links' => 'links-input',
467
+ 'metadata' => 'metadata-input',
468
+ 'payout_type' => 'payout_type-input',
469
+ 'reference' => 'reference-input',
470
+ 'status' => 'status-input',
471
+ },
472
+ }.to_json,
473
+ headers: response_headers
474
+ )
475
+ end
476
+
477
+ it 'updates and returns the resource' do
478
+ expect(put_update_response).to be_a(GoCardlessPro::Resources::Payout)
479
+ expect(stub).to have_been_requested
480
+ end
481
+
482
+ describe 'retry behaviour' do
483
+ before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
484
+
485
+ it 'retries timeouts' do
486
+ stub_url = '/payouts/:identity'.gsub(':identity', id)
487
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
488
+ to_timeout.then.to_return(status: 200, headers: response_headers)
489
+
490
+ put_update_response
491
+ expect(stub).to have_been_requested.twice
492
+ end
493
+
494
+ it 'retries 5XX errors' do
495
+ stub_url = '/payouts/:identity'.gsub(':identity', id)
496
+ stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
497
+ to_return(status: 502,
498
+ headers: { 'Content-Type' => 'text/html' },
499
+ body: '<html><body>Response from Cloudflare</body></html>').
500
+ then.to_return(status: 200, headers: response_headers)
501
+
502
+ put_update_response
503
+ expect(stub).to have_been_requested.twice
504
+ end
505
+ end
506
+ end
507
+ end
434
508
  end
@@ -411,7 +411,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
411
411
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
412
412
  to_timeout
413
413
 
414
- expect { post_response }.to raise_error(Faraday::TimeoutError)
414
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
415
415
  expect(stub).to have_been_requested
416
416
  end
417
417
  end
@@ -916,7 +916,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
916
916
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
917
917
  to_timeout
918
918
 
919
- expect { post_response }.to raise_error(Faraday::TimeoutError)
919
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
920
920
  expect(stub).to have_been_requested
921
921
  end
922
922
  end
@@ -1017,7 +1017,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
1017
1017
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
1018
1018
  to_timeout
1019
1019
 
1020
- expect { post_response }.to raise_error(Faraday::TimeoutError)
1020
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
1021
1021
  expect(stub).to have_been_requested
1022
1022
  end
1023
1023
  end
@@ -1118,7 +1118,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
1118
1118
  stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
1119
1119
  to_timeout
1120
1120
 
1121
- expect { post_response }.to raise_error(Faraday::TimeoutError)
1121
+ expect { post_response }.to raise_error(Faraday::ConnectionFailed)
1122
1122
  expect(stub).to have_been_requested
1123
1123
  end
1124
1124
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gocardless_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.1
4
+ version: 2.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 0.9.2
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '1.0'
22
+ version: '2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 0.9.2
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '1.0'
32
+ version: '2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.18'
53
+ version: 3.8.3
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.18'
60
+ version: 3.8.3
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rubocop
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  - !ruby/object:Gem::Version
267
267
  version: '0'
268
268
  requirements: []
269
- rubygems_version: 3.0.3
269
+ rubygems_version: 3.0.8
270
270
  signing_key:
271
271
  specification_version: 4
272
272
  summary: A gem for calling the GoCardless Pro API