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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/circle.yml +11 -3
- data/demo.rb +3 -3
- data/gocardless_pro.gemspec +6 -6
- data/lib/gocardless_pro.rb +2 -1
- data/lib/gocardless_pro/api_service.rb +3 -2
- data/lib/gocardless_pro/client.rb +6 -6
- data/lib/gocardless_pro/error.rb +4 -4
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +4 -4
- data/lib/gocardless_pro/request.rb +2 -2
- data/lib/gocardless_pro/resources/bank_details_lookup.rb +1 -0
- data/lib/gocardless_pro/resources/creditor.rb +1 -0
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +1 -0
- data/lib/gocardless_pro/resources/customer.rb +1 -0
- data/lib/gocardless_pro/resources/customer_bank_account.rb +1 -0
- data/lib/gocardless_pro/resources/event.rb +1 -0
- data/lib/gocardless_pro/resources/mandate.rb +1 -0
- data/lib/gocardless_pro/resources/mandate_pdf.rb +1 -0
- data/lib/gocardless_pro/resources/payment.rb +1 -0
- data/lib/gocardless_pro/resources/payout.rb +1 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +1 -0
- data/lib/gocardless_pro/resources/refund.rb +1 -0
- data/lib/gocardless_pro/resources/subscription.rb +1 -0
- data/lib/gocardless_pro/services/base_service.rb +1 -1
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/api_service_spec.rb +49 -49
- data/spec/client_spec.rb +1 -1
- data/spec/error_spec.rb +13 -13
- data/spec/middlewares/raise_gocardless_errors_spec.rb +15 -16
- data/spec/resources/bank_details_lookup_spec.rb +18 -18
- data/spec/resources/creditor_bank_account_spec.rb +46 -46
- data/spec/resources/creditor_spec.rb +42 -42
- data/spec/resources/customer_bank_account_spec.rb +48 -48
- data/spec/resources/customer_spec.rb +42 -42
- data/spec/resources/event_spec.rb +18 -18
- data/spec/resources/mandate_pdf_spec.rb +18 -18
- data/spec/resources/mandate_spec.rb +54 -54
- data/spec/resources/payment_spec.rb +54 -54
- data/spec/resources/payout_spec.rb +18 -18
- data/spec/resources/redirect_flow_spec.rb +36 -36
- data/spec/resources/refund_spec.rb +42 -42
- data/spec/resources/subscription_spec.rb +48 -48
- data/spec/response_spec.rb +1 -2
- data/spec/services/bank_details_lookups_service_spec.rb +25 -25
- data/spec/services/creditor_bank_accounts_service_spec.rb +86 -86
- data/spec/services/creditors_service_spec.rb +87 -87
- data/spec/services/customer_bank_accounts_service_spec.rb +95 -95
- data/spec/services/customers_service_spec.rb +87 -87
- data/spec/services/events_service_spec.rb +49 -49
- data/spec/services/mandate_pdfs_service_spec.rb +25 -25
- data/spec/services/mandates_service_spec.rb +103 -103
- data/spec/services/payments_service_spec.rb +103 -103
- data/spec/services/payouts_service_spec.rb +49 -49
- data/spec/services/redirect_flows_service_spec.rb +52 -52
- data/spec/services/refunds_service_spec.rb +87 -87
- data/spec/services/subscriptions_service_spec.rb +95 -95
- metadata +10 -10
@@ -30,13 +30,13 @@ describe GoCardlessPro::Services::CustomersService do
|
|
30
30
|
'metadata' => 'metadata-input',
|
31
31
|
'postal_code' => 'postal_code-input',
|
32
32
|
'region' => 'region-input',
|
33
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
33
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
37
|
before do
|
38
|
-
stub_request(:post, %r{.*api.gocardless.com/customers})
|
39
|
-
|
38
|
+
stub_request(:post, %r{.*api.gocardless.com/customers}).
|
39
|
+
with(
|
40
40
|
body: {
|
41
41
|
'customers' => {
|
42
42
|
|
@@ -55,11 +55,11 @@ describe GoCardlessPro::Services::CustomersService do
|
|
55
55
|
'metadata' => 'metadata-input',
|
56
56
|
'postal_code' => 'postal_code-input',
|
57
57
|
'region' => 'region-input',
|
58
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
59
|
-
}
|
58
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
59
|
+
},
|
60
60
|
}
|
61
|
-
)
|
62
|
-
|
61
|
+
).
|
62
|
+
to_return(
|
63
63
|
body: {
|
64
64
|
'customers' =>
|
65
65
|
|
@@ -80,8 +80,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
80
80
|
'metadata' => 'metadata-input',
|
81
81
|
'postal_code' => 'postal_code-input',
|
82
82
|
'region' => 'region-input',
|
83
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
84
|
-
}
|
83
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
84
|
+
},
|
85
85
|
|
86
86
|
}.to_json,
|
87
87
|
headers: response_headers
|
@@ -96,19 +96,19 @@ describe GoCardlessPro::Services::CustomersService do
|
|
96
96
|
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
|
97
97
|
|
98
98
|
it 'retries timeouts' do
|
99
|
-
stub = stub_request(:post, %r{.*api.gocardless.com/customers})
|
100
|
-
|
99
|
+
stub = stub_request(:post, %r{.*api.gocardless.com/customers}).
|
100
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
101
101
|
|
102
102
|
post_create_response
|
103
103
|
expect(stub).to have_been_requested.twice
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'retries 5XX errors' do
|
107
|
-
stub = stub_request(:post, %r{.*api.gocardless.com/customers})
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
stub = stub_request(:post, %r{.*api.gocardless.com/customers}).
|
108
|
+
to_return(status: 502,
|
109
|
+
headers: { 'Content-Type' => 'text/html' },
|
110
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
111
|
+
then.to_return(status: 200, headers: response_headers)
|
112
112
|
|
113
113
|
post_create_response
|
114
114
|
expect(stub).to have_been_requested.twice
|
@@ -126,9 +126,9 @@ describe GoCardlessPro::Services::CustomersService do
|
|
126
126
|
type: 'validation_failed',
|
127
127
|
code: 422,
|
128
128
|
errors: [
|
129
|
-
{ message: 'test error message', field: 'test_field' }
|
130
|
-
]
|
131
|
-
}
|
129
|
+
{ message: 'test error message', field: 'test_field' },
|
130
|
+
],
|
131
|
+
},
|
132
132
|
}.to_json,
|
133
133
|
headers: response_headers,
|
134
134
|
status: 422
|
@@ -161,7 +161,7 @@ describe GoCardlessPro::Services::CustomersService do
|
|
161
161
|
'metadata' => 'metadata-input',
|
162
162
|
'postal_code' => 'postal_code-input',
|
163
163
|
'region' => 'region-input',
|
164
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
164
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
165
165
|
}
|
166
166
|
end
|
167
167
|
|
@@ -176,11 +176,11 @@ describe GoCardlessPro::Services::CustomersService do
|
|
176
176
|
message: 'A resource has already been created with this idempotency key',
|
177
177
|
reason: 'idempotent_creation_conflict',
|
178
178
|
links: {
|
179
|
-
conflicting_resource_id: id
|
180
|
-
}
|
181
|
-
}
|
182
|
-
]
|
183
|
-
}
|
179
|
+
conflicting_resource_id: id,
|
180
|
+
},
|
181
|
+
},
|
182
|
+
],
|
183
|
+
},
|
184
184
|
}.to_json,
|
185
185
|
headers: response_headers,
|
186
186
|
status: 409
|
@@ -189,8 +189,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
189
189
|
|
190
190
|
let!(:get_stub) do
|
191
191
|
stub_url = "/customers/#{id}"
|
192
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
193
|
-
|
192
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
193
|
+
to_return(
|
194
194
|
body: {
|
195
195
|
'customers' => {
|
196
196
|
|
@@ -209,8 +209,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
209
209
|
'metadata' => 'metadata-input',
|
210
210
|
'postal_code' => 'postal_code-input',
|
211
211
|
'region' => 'region-input',
|
212
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
213
|
-
}
|
212
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
213
|
+
},
|
214
214
|
}.to_json,
|
215
215
|
headers: response_headers
|
216
216
|
)
|
@@ -247,14 +247,14 @@ describe GoCardlessPro::Services::CustomersService do
|
|
247
247
|
'metadata' => 'metadata-input',
|
248
248
|
'postal_code' => 'postal_code-input',
|
249
249
|
'region' => 'region-input',
|
250
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
250
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
251
251
|
}],
|
252
252
|
meta: {
|
253
253
|
cursors: {
|
254
254
|
before: nil,
|
255
|
-
after: 'ABC123'
|
256
|
-
}
|
257
|
-
}
|
255
|
+
after: 'ABC123',
|
256
|
+
},
|
257
|
+
},
|
258
258
|
}.to_json
|
259
259
|
end
|
260
260
|
|
@@ -312,19 +312,19 @@ describe GoCardlessPro::Services::CustomersService do
|
|
312
312
|
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
|
313
313
|
|
314
314
|
it 'retries timeouts' do
|
315
|
-
stub = stub_request(:get, %r{.*api.gocardless.com/customers})
|
316
|
-
|
315
|
+
stub = stub_request(:get, %r{.*api.gocardless.com/customers}).
|
316
|
+
to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
|
317
317
|
|
318
318
|
get_list_response
|
319
319
|
expect(stub).to have_been_requested.twice
|
320
320
|
end
|
321
321
|
|
322
322
|
it 'retries 5XX errors' do
|
323
|
-
stub = stub_request(:get, %r{.*api.gocardless.com/customers})
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
323
|
+
stub = stub_request(:get, %r{.*api.gocardless.com/customers}).
|
324
|
+
to_return(status: 502,
|
325
|
+
headers: { 'Content-Type' => 'text/html' },
|
326
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
327
|
+
then.to_return(status: 200, headers: response_headers, body: body)
|
328
328
|
|
329
329
|
get_list_response
|
330
330
|
expect(stub).to have_been_requested.twice
|
@@ -354,12 +354,12 @@ describe GoCardlessPro::Services::CustomersService do
|
|
354
354
|
'metadata' => 'metadata-input',
|
355
355
|
'postal_code' => 'postal_code-input',
|
356
356
|
'region' => 'region-input',
|
357
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
357
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
358
358
|
}],
|
359
359
|
meta: {
|
360
360
|
cursors: { after: 'AB345' },
|
361
|
-
limit: 1
|
362
|
-
}
|
361
|
+
limit: 1,
|
362
|
+
},
|
363
363
|
}.to_json,
|
364
364
|
headers: response_headers
|
365
365
|
)
|
@@ -385,12 +385,12 @@ describe GoCardlessPro::Services::CustomersService do
|
|
385
385
|
'metadata' => 'metadata-input',
|
386
386
|
'postal_code' => 'postal_code-input',
|
387
387
|
'region' => 'region-input',
|
388
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
388
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
389
389
|
}],
|
390
390
|
meta: {
|
391
391
|
limit: 2,
|
392
|
-
cursors: {}
|
393
|
-
}
|
392
|
+
cursors: {},
|
393
|
+
},
|
394
394
|
}.to_json,
|
395
395
|
headers: response_headers
|
396
396
|
)
|
@@ -425,19 +425,19 @@ describe GoCardlessPro::Services::CustomersService do
|
|
425
425
|
'metadata' => 'metadata-input',
|
426
426
|
'postal_code' => 'postal_code-input',
|
427
427
|
'region' => 'region-input',
|
428
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
428
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
429
429
|
}],
|
430
430
|
meta: {
|
431
431
|
cursors: { after: 'AB345' },
|
432
|
-
limit: 1
|
433
|
-
}
|
432
|
+
limit: 1,
|
433
|
+
},
|
434
434
|
}.to_json,
|
435
435
|
headers: response_headers
|
436
436
|
)
|
437
437
|
|
438
|
-
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345})
|
439
|
-
|
440
|
-
|
438
|
+
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345}).
|
439
|
+
to_timeout.then.
|
440
|
+
to_return(
|
441
441
|
body: {
|
442
442
|
'customers' => [{
|
443
443
|
|
@@ -456,12 +456,12 @@ describe GoCardlessPro::Services::CustomersService do
|
|
456
456
|
'metadata' => 'metadata-input',
|
457
457
|
'postal_code' => 'postal_code-input',
|
458
458
|
'region' => 'region-input',
|
459
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
459
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
460
460
|
}],
|
461
461
|
meta: {
|
462
462
|
limit: 2,
|
463
|
-
cursors: {}
|
464
|
-
}
|
463
|
+
cursors: {},
|
464
|
+
},
|
465
465
|
}.to_json,
|
466
466
|
headers: response_headers
|
467
467
|
)
|
@@ -492,18 +492,18 @@ describe GoCardlessPro::Services::CustomersService do
|
|
492
492
|
'metadata' => 'metadata-input',
|
493
493
|
'postal_code' => 'postal_code-input',
|
494
494
|
'region' => 'region-input',
|
495
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
495
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
496
496
|
}],
|
497
497
|
meta: {
|
498
498
|
cursors: { after: 'AB345' },
|
499
|
-
limit: 1
|
500
|
-
}
|
499
|
+
limit: 1,
|
500
|
+
},
|
501
501
|
}.to_json,
|
502
502
|
headers: response_headers
|
503
503
|
)
|
504
504
|
|
505
|
-
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345})
|
506
|
-
|
505
|
+
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345}).
|
506
|
+
to_return(
|
507
507
|
status: 502,
|
508
508
|
body: '<html><body>Response from Cloudflare</body></html>',
|
509
509
|
headers: { 'Content-Type' => 'text/html' }
|
@@ -526,12 +526,12 @@ describe GoCardlessPro::Services::CustomersService do
|
|
526
526
|
'metadata' => 'metadata-input',
|
527
527
|
'postal_code' => 'postal_code-input',
|
528
528
|
'region' => 'region-input',
|
529
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
529
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
530
530
|
}],
|
531
531
|
meta: {
|
532
532
|
limit: 2,
|
533
|
-
cursors: {}
|
534
|
-
}
|
533
|
+
cursors: {},
|
534
|
+
},
|
535
535
|
}.to_json,
|
536
536
|
headers: response_headers
|
537
537
|
)
|
@@ -552,9 +552,9 @@ describe GoCardlessPro::Services::CustomersService do
|
|
552
552
|
context 'passing in a custom header' do
|
553
553
|
let!(:stub) do
|
554
554
|
stub_url = '/customers/:identity'.gsub(':identity', id)
|
555
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
556
|
-
|
557
|
-
|
555
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
556
|
+
with(headers: { 'Foo' => 'Bar' }).
|
557
|
+
to_return(
|
558
558
|
body: {
|
559
559
|
'customers' => {
|
560
560
|
|
@@ -573,8 +573,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
573
573
|
'metadata' => 'metadata-input',
|
574
574
|
'postal_code' => 'postal_code-input',
|
575
575
|
'region' => 'region-input',
|
576
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
577
|
-
}
|
576
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
577
|
+
},
|
578
578
|
}.to_json,
|
579
579
|
headers: response_headers
|
580
580
|
)
|
@@ -582,7 +582,7 @@ describe GoCardlessPro::Services::CustomersService do
|
|
582
582
|
|
583
583
|
subject(:get_response) do
|
584
584
|
client.customers.get(id, headers: {
|
585
|
-
'Foo' => 'Bar'
|
585
|
+
'Foo' => 'Bar',
|
586
586
|
})
|
587
587
|
end
|
588
588
|
|
@@ -614,8 +614,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
614
614
|
'metadata' => 'metadata-input',
|
615
615
|
'postal_code' => 'postal_code-input',
|
616
616
|
'region' => 'region-input',
|
617
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
618
|
-
}
|
617
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
618
|
+
},
|
619
619
|
}.to_json,
|
620
620
|
headers: response_headers
|
621
621
|
)
|
@@ -654,8 +654,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
654
654
|
it 'retries timeouts' do
|
655
655
|
stub_url = '/customers/:identity'.gsub(':identity', id)
|
656
656
|
|
657
|
-
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
658
|
-
|
657
|
+
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
658
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
659
659
|
|
660
660
|
get_response
|
661
661
|
expect(stub).to have_been_requested.twice
|
@@ -664,11 +664,11 @@ describe GoCardlessPro::Services::CustomersService do
|
|
664
664
|
it 'retries 5XX errors' do
|
665
665
|
stub_url = '/customers/:identity'.gsub(':identity', id)
|
666
666
|
|
667
|
-
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
667
|
+
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
668
|
+
to_return(status: 502,
|
669
|
+
headers: { 'Content-Type' => 'text/html' },
|
670
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
671
|
+
then.to_return(status: 200, headers: response_headers)
|
672
672
|
|
673
673
|
get_response
|
674
674
|
expect(stub).to have_been_requested.twice
|
@@ -704,8 +704,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
704
704
|
'metadata' => 'metadata-input',
|
705
705
|
'postal_code' => 'postal_code-input',
|
706
706
|
'region' => 'region-input',
|
707
|
-
'swedish_identity_number' => 'swedish_identity_number-input'
|
708
|
-
}
|
707
|
+
'swedish_identity_number' => 'swedish_identity_number-input',
|
708
|
+
},
|
709
709
|
}.to_json,
|
710
710
|
headers: response_headers
|
711
711
|
)
|
@@ -721,8 +721,8 @@ describe GoCardlessPro::Services::CustomersService do
|
|
721
721
|
|
722
722
|
it 'retries timeouts' do
|
723
723
|
stub_url = '/customers/:identity'.gsub(':identity', id)
|
724
|
-
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
|
725
|
-
|
724
|
+
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
|
725
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
726
726
|
|
727
727
|
put_update_response
|
728
728
|
expect(stub).to have_been_requested.twice
|
@@ -730,11 +730,11 @@ describe GoCardlessPro::Services::CustomersService do
|
|
730
730
|
|
731
731
|
it 'retries 5XX errors' do
|
732
732
|
stub_url = '/customers/:identity'.gsub(':identity', id)
|
733
|
-
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/)
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
733
|
+
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
|
734
|
+
to_return(status: 502,
|
735
|
+
headers: { 'Content-Type' => 'text/html' },
|
736
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
737
|
+
then.to_return(status: 200, headers: response_headers)
|
738
738
|
|
739
739
|
put_update_response
|
740
740
|
expect(stub).to have_been_requested.twice
|
@@ -23,14 +23,14 @@ describe GoCardlessPro::Services::EventsService do
|
|
23
23
|
'id' => 'id-input',
|
24
24
|
'links' => 'links-input',
|
25
25
|
'metadata' => 'metadata-input',
|
26
|
-
'resource_type' => 'resource_type-input'
|
26
|
+
'resource_type' => 'resource_type-input',
|
27
27
|
}],
|
28
28
|
meta: {
|
29
29
|
cursors: {
|
30
30
|
before: nil,
|
31
|
-
after: 'ABC123'
|
32
|
-
}
|
33
|
-
}
|
31
|
+
after: 'ABC123',
|
32
|
+
},
|
33
|
+
},
|
34
34
|
}.to_json
|
35
35
|
end
|
36
36
|
|
@@ -68,19 +68,19 @@ describe GoCardlessPro::Services::EventsService do
|
|
68
68
|
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
|
69
69
|
|
70
70
|
it 'retries timeouts' do
|
71
|
-
stub = stub_request(:get, %r{.*api.gocardless.com/events})
|
72
|
-
|
71
|
+
stub = stub_request(:get, %r{.*api.gocardless.com/events}).
|
72
|
+
to_timeout.then.to_return(status: 200, headers: response_headers, body: body)
|
73
73
|
|
74
74
|
get_list_response
|
75
75
|
expect(stub).to have_been_requested.twice
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'retries 5XX errors' do
|
79
|
-
stub = stub_request(:get, %r{.*api.gocardless.com/events})
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
stub = stub_request(:get, %r{.*api.gocardless.com/events}).
|
80
|
+
to_return(status: 502,
|
81
|
+
headers: { 'Content-Type' => 'text/html' },
|
82
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
83
|
+
then.to_return(status: 200, headers: response_headers, body: body)
|
84
84
|
|
85
85
|
get_list_response
|
86
86
|
expect(stub).to have_been_requested.twice
|
@@ -101,12 +101,12 @@ describe GoCardlessPro::Services::EventsService do
|
|
101
101
|
'id' => 'id-input',
|
102
102
|
'links' => 'links-input',
|
103
103
|
'metadata' => 'metadata-input',
|
104
|
-
'resource_type' => 'resource_type-input'
|
104
|
+
'resource_type' => 'resource_type-input',
|
105
105
|
}],
|
106
106
|
meta: {
|
107
107
|
cursors: { after: 'AB345' },
|
108
|
-
limit: 1
|
109
|
-
}
|
108
|
+
limit: 1,
|
109
|
+
},
|
110
110
|
}.to_json,
|
111
111
|
headers: response_headers
|
112
112
|
)
|
@@ -123,12 +123,12 @@ describe GoCardlessPro::Services::EventsService do
|
|
123
123
|
'id' => 'id-input',
|
124
124
|
'links' => 'links-input',
|
125
125
|
'metadata' => 'metadata-input',
|
126
|
-
'resource_type' => 'resource_type-input'
|
126
|
+
'resource_type' => 'resource_type-input',
|
127
127
|
}],
|
128
128
|
meta: {
|
129
129
|
limit: 2,
|
130
|
-
cursors: {}
|
131
|
-
}
|
130
|
+
cursors: {},
|
131
|
+
},
|
132
132
|
}.to_json,
|
133
133
|
headers: response_headers
|
134
134
|
)
|
@@ -154,19 +154,19 @@ describe GoCardlessPro::Services::EventsService do
|
|
154
154
|
'id' => 'id-input',
|
155
155
|
'links' => 'links-input',
|
156
156
|
'metadata' => 'metadata-input',
|
157
|
-
'resource_type' => 'resource_type-input'
|
157
|
+
'resource_type' => 'resource_type-input',
|
158
158
|
}],
|
159
159
|
meta: {
|
160
160
|
cursors: { after: 'AB345' },
|
161
|
-
limit: 1
|
162
|
-
}
|
161
|
+
limit: 1,
|
162
|
+
},
|
163
163
|
}.to_json,
|
164
164
|
headers: response_headers
|
165
165
|
)
|
166
166
|
|
167
|
-
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345})
|
168
|
-
|
169
|
-
|
167
|
+
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345}).
|
168
|
+
to_timeout.then.
|
169
|
+
to_return(
|
170
170
|
body: {
|
171
171
|
'events' => [{
|
172
172
|
|
@@ -176,12 +176,12 @@ describe GoCardlessPro::Services::EventsService do
|
|
176
176
|
'id' => 'id-input',
|
177
177
|
'links' => 'links-input',
|
178
178
|
'metadata' => 'metadata-input',
|
179
|
-
'resource_type' => 'resource_type-input'
|
179
|
+
'resource_type' => 'resource_type-input',
|
180
180
|
}],
|
181
181
|
meta: {
|
182
182
|
limit: 2,
|
183
|
-
cursors: {}
|
184
|
-
}
|
183
|
+
cursors: {},
|
184
|
+
},
|
185
185
|
}.to_json,
|
186
186
|
headers: response_headers
|
187
187
|
)
|
@@ -203,18 +203,18 @@ describe GoCardlessPro::Services::EventsService do
|
|
203
203
|
'id' => 'id-input',
|
204
204
|
'links' => 'links-input',
|
205
205
|
'metadata' => 'metadata-input',
|
206
|
-
'resource_type' => 'resource_type-input'
|
206
|
+
'resource_type' => 'resource_type-input',
|
207
207
|
}],
|
208
208
|
meta: {
|
209
209
|
cursors: { after: 'AB345' },
|
210
|
-
limit: 1
|
211
|
-
}
|
210
|
+
limit: 1,
|
211
|
+
},
|
212
212
|
}.to_json,
|
213
213
|
headers: response_headers
|
214
214
|
)
|
215
215
|
|
216
|
-
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345})
|
217
|
-
|
216
|
+
second_response_stub = stub_request(:get, %r{.*api.gocardless.com/events\?after=AB345}).
|
217
|
+
to_return(
|
218
218
|
status: 502,
|
219
219
|
body: '<html><body>Response from Cloudflare</body></html>',
|
220
220
|
headers: { 'Content-Type' => 'text/html' }
|
@@ -228,12 +228,12 @@ describe GoCardlessPro::Services::EventsService do
|
|
228
228
|
'id' => 'id-input',
|
229
229
|
'links' => 'links-input',
|
230
230
|
'metadata' => 'metadata-input',
|
231
|
-
'resource_type' => 'resource_type-input'
|
231
|
+
'resource_type' => 'resource_type-input',
|
232
232
|
}],
|
233
233
|
meta: {
|
234
234
|
limit: 2,
|
235
|
-
cursors: {}
|
236
|
-
}
|
235
|
+
cursors: {},
|
236
|
+
},
|
237
237
|
}.to_json,
|
238
238
|
headers: response_headers
|
239
239
|
)
|
@@ -254,9 +254,9 @@ describe GoCardlessPro::Services::EventsService do
|
|
254
254
|
context 'passing in a custom header' do
|
255
255
|
let!(:stub) do
|
256
256
|
stub_url = '/events/:identity'.gsub(':identity', id)
|
257
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
258
|
-
|
259
|
-
|
257
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
258
|
+
with(headers: { 'Foo' => 'Bar' }).
|
259
|
+
to_return(
|
260
260
|
body: {
|
261
261
|
'events' => {
|
262
262
|
|
@@ -266,8 +266,8 @@ describe GoCardlessPro::Services::EventsService do
|
|
266
266
|
'id' => 'id-input',
|
267
267
|
'links' => 'links-input',
|
268
268
|
'metadata' => 'metadata-input',
|
269
|
-
'resource_type' => 'resource_type-input'
|
270
|
-
}
|
269
|
+
'resource_type' => 'resource_type-input',
|
270
|
+
},
|
271
271
|
}.to_json,
|
272
272
|
headers: response_headers
|
273
273
|
)
|
@@ -275,7 +275,7 @@ describe GoCardlessPro::Services::EventsService do
|
|
275
275
|
|
276
276
|
subject(:get_response) do
|
277
277
|
client.events.get(id, headers: {
|
278
|
-
'Foo' => 'Bar'
|
278
|
+
'Foo' => 'Bar',
|
279
279
|
})
|
280
280
|
end
|
281
281
|
|
@@ -298,8 +298,8 @@ describe GoCardlessPro::Services::EventsService do
|
|
298
298
|
'id' => 'id-input',
|
299
299
|
'links' => 'links-input',
|
300
300
|
'metadata' => 'metadata-input',
|
301
|
-
'resource_type' => 'resource_type-input'
|
302
|
-
}
|
301
|
+
'resource_type' => 'resource_type-input',
|
302
|
+
},
|
303
303
|
}.to_json,
|
304
304
|
headers: response_headers
|
305
305
|
)
|
@@ -338,8 +338,8 @@ describe GoCardlessPro::Services::EventsService do
|
|
338
338
|
it 'retries timeouts' do
|
339
339
|
stub_url = '/events/:identity'.gsub(':identity', id)
|
340
340
|
|
341
|
-
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
342
|
-
|
341
|
+
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
342
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
343
343
|
|
344
344
|
get_response
|
345
345
|
expect(stub).to have_been_requested.twice
|
@@ -348,11 +348,11 @@ describe GoCardlessPro::Services::EventsService do
|
|
348
348
|
it 'retries 5XX errors' do
|
349
349
|
stub_url = '/events/:identity'.gsub(':identity', id)
|
350
350
|
|
351
|
-
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
351
|
+
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
352
|
+
to_return(status: 502,
|
353
|
+
headers: { 'Content-Type' => 'text/html' },
|
354
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
355
|
+
then.to_return(status: 200, headers: response_headers)
|
356
356
|
|
357
357
|
get_response
|
358
358
|
expect(stub).to have_been_requested.twice
|