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.
- 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
data/spec/client_spec.rb
CHANGED
data/spec/error_spec.rb
CHANGED
@@ -13,12 +13,12 @@ describe GoCardlessPro::Error do
|
|
13
13
|
'errors' => [
|
14
14
|
{
|
15
15
|
'message' => 'must be a number',
|
16
|
-
'field' => 'branch_code'
|
16
|
+
'field' => 'branch_code',
|
17
17
|
}, {
|
18
18
|
'message' => 'is the wrong length (should be 8 characters)',
|
19
|
-
'field' => 'branch_code'
|
19
|
+
'field' => 'branch_code',
|
20
20
|
}
|
21
|
-
]
|
21
|
+
],
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
@@ -28,8 +28,8 @@ describe GoCardlessPro::Error do
|
|
28
28
|
|
29
29
|
specify { expect(error.message).to eq('Validation failed') }
|
30
30
|
specify do
|
31
|
-
expect(error.to_s)
|
32
|
-
|
31
|
+
expect(error.to_s).
|
32
|
+
to eq('branch_code must be a number, '\
|
33
33
|
'branch_code is the wrong length (should be 8 characters)')
|
34
34
|
end
|
35
35
|
specify { expect(error.type).to eq('validation_failed') }
|
@@ -37,14 +37,14 @@ describe GoCardlessPro::Error do
|
|
37
37
|
specify { expect(error.request_id).to eq('dd50eaaf-8213-48fe-90d6-5466872efbc4') }
|
38
38
|
specify do
|
39
39
|
expect(error.errors).to eq([
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
{
|
41
|
+
'message' => 'must be a number',
|
42
|
+
'field' => 'branch_code',
|
43
|
+
}, {
|
44
|
+
'message' => 'is the wrong length (should be 8 characters)',
|
45
|
+
'field' => 'branch_code',
|
46
|
+
}
|
47
|
+
])
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'when initializing an error with a string' do
|
@@ -23,8 +23,8 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
23
23
|
let(:status) { 514 }
|
24
24
|
|
25
25
|
it 'raises an error' do
|
26
|
-
expect { connection.post('https://api.gocardless.com/widgets') }
|
27
|
-
|
26
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
27
|
+
to raise_error(GoCardlessPro::ApiError)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,8 +32,8 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
32
32
|
let(:status) { 503 }
|
33
33
|
|
34
34
|
it 'raises an error' do
|
35
|
-
expect { connection.post('https://api.gocardless.com/widgets') }
|
36
|
-
|
35
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
36
|
+
to raise_error(GoCardlessPro::ApiError)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -41,8 +41,8 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
41
41
|
let(:status) { 200 }
|
42
42
|
|
43
43
|
it "doesn't raise an error" do
|
44
|
-
expect { connection.post('https://api.gocardless.com/widgets') }
|
45
|
-
|
44
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
45
|
+
to_not raise_error(GoCardlessPro::ApiError)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -52,16 +52,15 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
52
52
|
double('response',
|
53
53
|
headers: default_headers,
|
54
54
|
status: 400,
|
55
|
-
body: { error: { type: 'validation_failed' } }.to_json
|
56
|
-
)
|
55
|
+
body: { error: { type: 'validation_failed' } }.to_json)
|
57
56
|
end
|
58
57
|
|
59
58
|
let(:status) { 422 }
|
60
59
|
let(:body) { { error: { type: 'validation_failed' } }.to_json }
|
61
60
|
|
62
61
|
it 'raises a ValidationError' do
|
63
|
-
expect { connection.post('https://api.gocardless.com/widgets') }
|
64
|
-
|
62
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
63
|
+
to raise_error(GoCardlessPro::ValidationError)
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
@@ -70,8 +69,8 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
70
69
|
let(:body) { { error: { type: 'gocardless' } }.to_json }
|
71
70
|
|
72
71
|
it 'raises a GoCardlessError' do
|
73
|
-
expect { connection.post('https://api.gocardless.com/widgets') }
|
74
|
-
|
72
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
73
|
+
to raise_error(GoCardlessPro::GoCardlessError)
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
@@ -80,8 +79,8 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
80
79
|
let(:body) { { error: { type: 'invalid_api_usage' } }.to_json }
|
81
80
|
|
82
81
|
it 'raises a InvalidApiUsageError' do
|
83
|
-
expect { connection.post('https://api.gocardless.com/widgets') }
|
84
|
-
|
82
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
83
|
+
to raise_error(GoCardlessPro::InvalidApiUsageError)
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
@@ -90,8 +89,8 @@ describe GoCardlessPro::Middlewares::RaiseGoCardlessErrors do
|
|
90
89
|
let(:body) { { error: { type: 'invalid_state' } }.to_json }
|
91
90
|
|
92
91
|
it 'raises an InvalidStateError' do
|
93
|
-
expect { connection.post('https://api.gocardless.com/widgets') }
|
94
|
-
|
92
|
+
expect { connection.post('https://api.gocardless.com/widgets') }.
|
93
|
+
to raise_error(GoCardlessPro::InvalidStateError)
|
95
94
|
end
|
96
95
|
end
|
97
96
|
end
|
@@ -17,23 +17,23 @@ describe GoCardlessPro::Resources::BankDetailsLookup 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
|
-
|
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
|
-
|
35
|
+
).
|
36
|
+
to_return(
|
37
37
|
body: {
|
38
38
|
'bank_details_lookups' =>
|
39
39
|
|
@@ -41,8 +41,8 @@ describe GoCardlessPro::Resources::BankDetailsLookup 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
|
@@ -64,9 +64,9 @@ describe GoCardlessPro::Resources::BankDetailsLookup do
|
|
64
64
|
type: 'validation_failed',
|
65
65
|
code: 422,
|
66
66
|
errors: [
|
67
|
-
{ message: 'test error message', field: 'test_field' }
|
68
|
-
]
|
69
|
-
}
|
67
|
+
{ message: 'test error message', field: 'test_field' },
|
68
|
+
],
|
69
|
+
},
|
70
70
|
}.to_json,
|
71
71
|
headers: response_headers,
|
72
72
|
status: 422
|
@@ -86,7 +86,7 @@ describe GoCardlessPro::Resources::BankDetailsLookup do
|
|
86
86
|
|
87
87
|
'available_debit_schemes' => 'available_debit_schemes-input',
|
88
88
|
'bank_name' => 'bank_name-input',
|
89
|
-
'bic' => 'bic-input'
|
89
|
+
'bic' => 'bic-input',
|
90
90
|
}
|
91
91
|
end
|
92
92
|
|
@@ -101,11 +101,11 @@ describe GoCardlessPro::Resources::BankDetailsLookup do
|
|
101
101
|
message: 'A resource has already been created with this idempotency key',
|
102
102
|
reason: 'idempotent_creation_conflict',
|
103
103
|
links: {
|
104
|
-
conflicting_resource_id: id
|
105
|
-
}
|
106
|
-
}
|
107
|
-
]
|
108
|
-
}
|
104
|
+
conflicting_resource_id: id,
|
105
|
+
},
|
106
|
+
},
|
107
|
+
],
|
108
|
+
},
|
109
109
|
}.to_json,
|
110
110
|
headers: response_headers,
|
111
111
|
status: 409
|
@@ -24,13 +24,13 @@ describe GoCardlessPro::Resources::CreditorBankAccount 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
|
-
|
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::Resources::CreditorBankAccount 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
|
-
|
49
|
+
).
|
50
|
+
to_return(
|
51
51
|
body: {
|
52
52
|
'creditor_bank_accounts' =>
|
53
53
|
|
@@ -62,8 +62,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount 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
|
@@ -85,9 +85,9 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
85
85
|
type: 'validation_failed',
|
86
86
|
code: 422,
|
87
87
|
errors: [
|
88
|
-
{ message: 'test error message', field: 'test_field' }
|
89
|
-
]
|
90
|
-
}
|
88
|
+
{ message: 'test error message', field: 'test_field' },
|
89
|
+
],
|
90
|
+
},
|
91
91
|
}.to_json,
|
92
92
|
headers: response_headers,
|
93
93
|
status: 422
|
@@ -114,7 +114,7 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
114
114
|
'enabled' => 'enabled-input',
|
115
115
|
'id' => 'id-input',
|
116
116
|
'links' => 'links-input',
|
117
|
-
'metadata' => 'metadata-input'
|
117
|
+
'metadata' => 'metadata-input',
|
118
118
|
}
|
119
119
|
end
|
120
120
|
|
@@ -129,11 +129,11 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
129
129
|
message: 'A resource has already been created with this idempotency key',
|
130
130
|
reason: 'idempotent_creation_conflict',
|
131
131
|
links: {
|
132
|
-
conflicting_resource_id: id
|
133
|
-
}
|
134
|
-
}
|
135
|
-
]
|
136
|
-
}
|
132
|
+
conflicting_resource_id: id,
|
133
|
+
},
|
134
|
+
},
|
135
|
+
],
|
136
|
+
},
|
137
137
|
}.to_json,
|
138
138
|
headers: response_headers,
|
139
139
|
status: 409
|
@@ -142,8 +142,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
142
142
|
|
143
143
|
let!(:get_stub) do
|
144
144
|
stub_url = "/creditor_bank_accounts/#{id}"
|
145
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
146
|
-
|
145
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
146
|
+
to_return(
|
147
147
|
body: {
|
148
148
|
'creditor_bank_accounts' => {
|
149
149
|
|
@@ -156,8 +156,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
156
156
|
'enabled' => 'enabled-input',
|
157
157
|
'id' => 'id-input',
|
158
158
|
'links' => 'links-input',
|
159
|
-
'metadata' => 'metadata-input'
|
160
|
-
}
|
159
|
+
'metadata' => 'metadata-input',
|
160
|
+
},
|
161
161
|
}.to_json,
|
162
162
|
headers: response_headers
|
163
163
|
)
|
@@ -189,14 +189,14 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
189
189
|
'enabled' => 'enabled-input',
|
190
190
|
'id' => 'id-input',
|
191
191
|
'links' => 'links-input',
|
192
|
-
'metadata' => 'metadata-input'
|
192
|
+
'metadata' => 'metadata-input',
|
193
193
|
}],
|
194
194
|
meta: {
|
195
195
|
cursors: {
|
196
196
|
before: nil,
|
197
|
-
after: 'ABC123'
|
198
|
-
}
|
199
|
-
}
|
197
|
+
after: 'ABC123',
|
198
|
+
},
|
199
|
+
},
|
200
200
|
}.to_json,
|
201
201
|
headers: response_headers
|
202
202
|
)
|
@@ -248,12 +248,12 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
248
248
|
'enabled' => 'enabled-input',
|
249
249
|
'id' => 'id-input',
|
250
250
|
'links' => 'links-input',
|
251
|
-
'metadata' => 'metadata-input'
|
251
|
+
'metadata' => 'metadata-input',
|
252
252
|
}],
|
253
253
|
meta: {
|
254
254
|
cursors: { after: 'AB345' },
|
255
|
-
limit: 1
|
256
|
-
}
|
255
|
+
limit: 1,
|
256
|
+
},
|
257
257
|
}.to_json,
|
258
258
|
headers: response_headers
|
259
259
|
)
|
@@ -273,12 +273,12 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
273
273
|
'enabled' => 'enabled-input',
|
274
274
|
'id' => 'id-input',
|
275
275
|
'links' => 'links-input',
|
276
|
-
'metadata' => 'metadata-input'
|
276
|
+
'metadata' => 'metadata-input',
|
277
277
|
}],
|
278
278
|
meta: {
|
279
279
|
limit: 2,
|
280
|
-
cursors: {}
|
281
|
-
}
|
280
|
+
cursors: {},
|
281
|
+
},
|
282
282
|
}.to_json,
|
283
283
|
headers: response_headers
|
284
284
|
)
|
@@ -299,9 +299,9 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
299
299
|
context 'passing in a custom header' do
|
300
300
|
let!(:stub) do
|
301
301
|
stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
|
302
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
303
|
-
|
304
|
-
|
302
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
303
|
+
with(headers: { 'Foo' => 'Bar' }).
|
304
|
+
to_return(
|
305
305
|
body: {
|
306
306
|
'creditor_bank_accounts' => {
|
307
307
|
|
@@ -314,8 +314,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
314
314
|
'enabled' => 'enabled-input',
|
315
315
|
'id' => 'id-input',
|
316
316
|
'links' => 'links-input',
|
317
|
-
'metadata' => 'metadata-input'
|
318
|
-
}
|
317
|
+
'metadata' => 'metadata-input',
|
318
|
+
},
|
319
319
|
}.to_json,
|
320
320
|
headers: response_headers
|
321
321
|
)
|
@@ -323,7 +323,7 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
323
323
|
|
324
324
|
subject(:get_response) do
|
325
325
|
client.creditor_bank_accounts.get(id, headers: {
|
326
|
-
'Foo' => 'Bar'
|
326
|
+
'Foo' => 'Bar',
|
327
327
|
})
|
328
328
|
end
|
329
329
|
|
@@ -349,8 +349,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
349
349
|
'enabled' => 'enabled-input',
|
350
350
|
'id' => 'id-input',
|
351
351
|
'links' => 'links-input',
|
352
|
-
'metadata' => 'metadata-input'
|
353
|
-
}
|
352
|
+
'metadata' => 'metadata-input',
|
353
|
+
},
|
354
354
|
}.to_json,
|
355
355
|
headers: response_headers
|
356
356
|
)
|
@@ -405,8 +405,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
405
405
|
'enabled' => 'enabled-input',
|
406
406
|
'id' => 'id-input',
|
407
407
|
'links' => 'links-input',
|
408
|
-
'metadata' => 'metadata-input'
|
409
|
-
}
|
408
|
+
'metadata' => 'metadata-input',
|
409
|
+
},
|
410
410
|
}.to_json,
|
411
411
|
headers: response_headers
|
412
412
|
)
|
@@ -428,8 +428,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
428
428
|
let!(:stub) do
|
429
429
|
# /creditor_bank_accounts/%v/actions/disable
|
430
430
|
stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
|
431
|
-
stub_request(:post, /.*api.gocardless.com#{stub_url}/)
|
432
|
-
|
431
|
+
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
432
|
+
with(
|
433
433
|
body: { foo: 'bar' },
|
434
434
|
headers: { 'Foo' => 'Bar' }
|
435
435
|
).to_return(
|
@@ -445,8 +445,8 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
445
445
|
'enabled' => 'enabled-input',
|
446
446
|
'id' => 'id-input',
|
447
447
|
'links' => 'links-input',
|
448
|
-
'metadata' => 'metadata-input'
|
449
|
-
}
|
448
|
+
'metadata' => 'metadata-input',
|
449
|
+
},
|
450
450
|
}.to_json,
|
451
451
|
headers: response_headers
|
452
452
|
)
|
@@ -28,13 +28,13 @@ describe GoCardlessPro::Resources::Creditor 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
|
-
|
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::Resources::Creditor 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
|
-
|
57
|
+
).
|
58
|
+
to_return(
|
59
59
|
body: {
|
60
60
|
'creditors' =>
|
61
61
|
|
@@ -74,8 +74,8 @@ describe GoCardlessPro::Resources::Creditor 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
|
@@ -97,9 +97,9 @@ describe GoCardlessPro::Resources::Creditor do
|
|
97
97
|
type: 'validation_failed',
|
98
98
|
code: 422,
|
99
99
|
errors: [
|
100
|
-
{ message: 'test error message', field: 'test_field' }
|
101
|
-
]
|
102
|
-
}
|
100
|
+
{ message: 'test error message', field: 'test_field' },
|
101
|
+
],
|
102
|
+
},
|
103
103
|
}.to_json,
|
104
104
|
headers: response_headers,
|
105
105
|
status: 422
|
@@ -130,7 +130,7 @@ describe GoCardlessPro::Resources::Creditor do
|
|
130
130
|
'postal_code' => 'postal_code-input',
|
131
131
|
'region' => 'region-input',
|
132
132
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
133
|
-
'verification_status' => 'verification_status-input'
|
133
|
+
'verification_status' => 'verification_status-input',
|
134
134
|
}
|
135
135
|
end
|
136
136
|
|
@@ -145,11 +145,11 @@ describe GoCardlessPro::Resources::Creditor do
|
|
145
145
|
message: 'A resource has already been created with this idempotency key',
|
146
146
|
reason: 'idempotent_creation_conflict',
|
147
147
|
links: {
|
148
|
-
conflicting_resource_id: id
|
149
|
-
}
|
150
|
-
}
|
151
|
-
]
|
152
|
-
}
|
148
|
+
conflicting_resource_id: id,
|
149
|
+
},
|
150
|
+
},
|
151
|
+
],
|
152
|
+
},
|
153
153
|
}.to_json,
|
154
154
|
headers: response_headers,
|
155
155
|
status: 409
|
@@ -158,8 +158,8 @@ describe GoCardlessPro::Resources::Creditor do
|
|
158
158
|
|
159
159
|
let!(:get_stub) do
|
160
160
|
stub_url = "/creditors/#{id}"
|
161
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
162
|
-
|
161
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
162
|
+
to_return(
|
163
163
|
body: {
|
164
164
|
'creditors' => {
|
165
165
|
|
@@ -176,8 +176,8 @@ describe GoCardlessPro::Resources::Creditor do
|
|
176
176
|
'postal_code' => 'postal_code-input',
|
177
177
|
'region' => 'region-input',
|
178
178
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
179
|
-
'verification_status' => 'verification_status-input'
|
180
|
-
}
|
179
|
+
'verification_status' => 'verification_status-input',
|
180
|
+
},
|
181
181
|
}.to_json,
|
182
182
|
headers: response_headers
|
183
183
|
)
|
@@ -213,14 +213,14 @@ describe GoCardlessPro::Resources::Creditor do
|
|
213
213
|
'postal_code' => 'postal_code-input',
|
214
214
|
'region' => 'region-input',
|
215
215
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
216
|
-
'verification_status' => 'verification_status-input'
|
216
|
+
'verification_status' => 'verification_status-input',
|
217
217
|
}],
|
218
218
|
meta: {
|
219
219
|
cursors: {
|
220
220
|
before: nil,
|
221
|
-
after: 'ABC123'
|
222
|
-
}
|
223
|
-
}
|
221
|
+
after: 'ABC123',
|
222
|
+
},
|
223
|
+
},
|
224
224
|
}.to_json,
|
225
225
|
headers: response_headers
|
226
226
|
)
|
@@ -284,12 +284,12 @@ describe GoCardlessPro::Resources::Creditor do
|
|
284
284
|
'postal_code' => 'postal_code-input',
|
285
285
|
'region' => 'region-input',
|
286
286
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
287
|
-
'verification_status' => 'verification_status-input'
|
287
|
+
'verification_status' => 'verification_status-input',
|
288
288
|
}],
|
289
289
|
meta: {
|
290
290
|
cursors: { after: 'AB345' },
|
291
|
-
limit: 1
|
292
|
-
}
|
291
|
+
limit: 1,
|
292
|
+
},
|
293
293
|
}.to_json,
|
294
294
|
headers: response_headers
|
295
295
|
)
|
@@ -313,12 +313,12 @@ describe GoCardlessPro::Resources::Creditor do
|
|
313
313
|
'postal_code' => 'postal_code-input',
|
314
314
|
'region' => 'region-input',
|
315
315
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
316
|
-
'verification_status' => 'verification_status-input'
|
316
|
+
'verification_status' => 'verification_status-input',
|
317
317
|
}],
|
318
318
|
meta: {
|
319
319
|
limit: 2,
|
320
|
-
cursors: {}
|
321
|
-
}
|
320
|
+
cursors: {},
|
321
|
+
},
|
322
322
|
}.to_json,
|
323
323
|
headers: response_headers
|
324
324
|
)
|
@@ -339,9 +339,9 @@ describe GoCardlessPro::Resources::Creditor do
|
|
339
339
|
context 'passing in a custom header' do
|
340
340
|
let!(:stub) do
|
341
341
|
stub_url = '/creditors/:identity'.gsub(':identity', id)
|
342
|
-
stub_request(:get, /.*api.gocardless.com#{stub_url}/)
|
343
|
-
|
344
|
-
|
342
|
+
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
|
343
|
+
with(headers: { 'Foo' => 'Bar' }).
|
344
|
+
to_return(
|
345
345
|
body: {
|
346
346
|
'creditors' => {
|
347
347
|
|
@@ -358,8 +358,8 @@ describe GoCardlessPro::Resources::Creditor do
|
|
358
358
|
'postal_code' => 'postal_code-input',
|
359
359
|
'region' => 'region-input',
|
360
360
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
361
|
-
'verification_status' => 'verification_status-input'
|
362
|
-
}
|
361
|
+
'verification_status' => 'verification_status-input',
|
362
|
+
},
|
363
363
|
}.to_json,
|
364
364
|
headers: response_headers
|
365
365
|
)
|
@@ -367,7 +367,7 @@ describe GoCardlessPro::Resources::Creditor do
|
|
367
367
|
|
368
368
|
subject(:get_response) do
|
369
369
|
client.creditors.get(id, headers: {
|
370
|
-
'Foo' => 'Bar'
|
370
|
+
'Foo' => 'Bar',
|
371
371
|
})
|
372
372
|
end
|
373
373
|
|
@@ -397,8 +397,8 @@ describe GoCardlessPro::Resources::Creditor do
|
|
397
397
|
'postal_code' => 'postal_code-input',
|
398
398
|
'region' => 'region-input',
|
399
399
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
400
|
-
'verification_status' => 'verification_status-input'
|
401
|
-
}
|
400
|
+
'verification_status' => 'verification_status-input',
|
401
|
+
},
|
402
402
|
}.to_json,
|
403
403
|
headers: response_headers
|
404
404
|
)
|
@@ -458,8 +458,8 @@ describe GoCardlessPro::Resources::Creditor do
|
|
458
458
|
'postal_code' => 'postal_code-input',
|
459
459
|
'region' => 'region-input',
|
460
460
|
'scheme_identifiers' => 'scheme_identifiers-input',
|
461
|
-
'verification_status' => 'verification_status-input'
|
462
|
-
}
|
461
|
+
'verification_status' => 'verification_status-input',
|
462
|
+
},
|
463
463
|
}.to_json,
|
464
464
|
headers: response_headers
|
465
465
|
)
|