gocardless_pro 2.41.0 → 2.41.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gocardless_pro/api_service.rb +4 -5
  3. data/lib/gocardless_pro/client.rb +3 -3
  4. data/lib/gocardless_pro/error/invalid_state_error.rb +1 -0
  5. data/lib/gocardless_pro/error.rb +1 -0
  6. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +7 -9
  7. data/lib/gocardless_pro/request.rb +5 -7
  8. data/lib/gocardless_pro/resources/bank_authorisation.rb +0 -2
  9. data/lib/gocardless_pro/resources/bank_details_lookup.rb +0 -2
  10. data/lib/gocardless_pro/resources/billing_request.rb +0 -2
  11. data/lib/gocardless_pro/resources/billing_request_flow.rb +0 -2
  12. data/lib/gocardless_pro/resources/billing_request_template.rb +0 -2
  13. data/lib/gocardless_pro/resources/block.rb +0 -2
  14. data/lib/gocardless_pro/resources/creditor.rb +0 -2
  15. data/lib/gocardless_pro/resources/creditor_bank_account.rb +0 -2
  16. data/lib/gocardless_pro/resources/currency_exchange_rate.rb +0 -2
  17. data/lib/gocardless_pro/resources/customer.rb +0 -2
  18. data/lib/gocardless_pro/resources/customer_bank_account.rb +0 -2
  19. data/lib/gocardless_pro/resources/customer_notification.rb +0 -2
  20. data/lib/gocardless_pro/resources/event.rb +0 -2
  21. data/lib/gocardless_pro/resources/instalment_schedule.rb +0 -2
  22. data/lib/gocardless_pro/resources/institution.rb +0 -2
  23. data/lib/gocardless_pro/resources/mandate.rb +0 -2
  24. data/lib/gocardless_pro/resources/mandate_import.rb +0 -2
  25. data/lib/gocardless_pro/resources/mandate_import_entry.rb +0 -2
  26. data/lib/gocardless_pro/resources/mandate_pdf.rb +0 -2
  27. data/lib/gocardless_pro/resources/payer_authorisation.rb +0 -2
  28. data/lib/gocardless_pro/resources/payment.rb +0 -2
  29. data/lib/gocardless_pro/resources/payout.rb +0 -2
  30. data/lib/gocardless_pro/resources/payout_item.rb +0 -2
  31. data/lib/gocardless_pro/resources/redirect_flow.rb +0 -2
  32. data/lib/gocardless_pro/resources/refund.rb +0 -2
  33. data/lib/gocardless_pro/resources/scenario_simulator.rb +0 -2
  34. data/lib/gocardless_pro/resources/scheme_identifier.rb +0 -2
  35. data/lib/gocardless_pro/resources/subscription.rb +0 -2
  36. data/lib/gocardless_pro/resources/tax_rate.rb +0 -2
  37. data/lib/gocardless_pro/resources/verification_detail.rb +0 -2
  38. data/lib/gocardless_pro/resources/webhook.rb +0 -2
  39. data/lib/gocardless_pro/services/bank_authorisations_service.rb +3 -1
  40. data/lib/gocardless_pro/services/billing_request_flows_service.rb +3 -1
  41. data/lib/gocardless_pro/services/billing_request_templates_service.rb +6 -2
  42. data/lib/gocardless_pro/services/billing_requests_service.rb +27 -9
  43. data/lib/gocardless_pro/services/blocks_service.rb +9 -3
  44. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +6 -2
  45. data/lib/gocardless_pro/services/creditors_service.rb +9 -3
  46. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +9 -3
  47. data/lib/gocardless_pro/services/customer_notifications_service.rb +3 -1
  48. data/lib/gocardless_pro/services/customers_service.rb +9 -3
  49. data/lib/gocardless_pro/services/events_service.rb +3 -1
  50. data/lib/gocardless_pro/services/instalment_schedules_service.rb +9 -3
  51. data/lib/gocardless_pro/services/mandate_imports_service.rb +9 -3
  52. data/lib/gocardless_pro/services/mandates_service.rb +12 -4
  53. data/lib/gocardless_pro/services/payer_authorisations_service.rb +12 -4
  54. data/lib/gocardless_pro/services/payments_service.rb +12 -4
  55. data/lib/gocardless_pro/services/payouts_service.rb +6 -2
  56. data/lib/gocardless_pro/services/redirect_flows_service.rb +6 -2
  57. data/lib/gocardless_pro/services/refunds_service.rb +6 -2
  58. data/lib/gocardless_pro/services/scenario_simulators_service.rb +3 -1
  59. data/lib/gocardless_pro/services/scheme_identifiers_service.rb +3 -1
  60. data/lib/gocardless_pro/services/subscriptions_service.rb +15 -5
  61. data/lib/gocardless_pro/services/tax_rates_service.rb +3 -1
  62. data/lib/gocardless_pro/services/webhooks_service.rb +6 -2
  63. data/lib/gocardless_pro/version.rb +1 -2
  64. data/lib/gocardless_pro/webhook.rb +5 -4
  65. data/lib/gocardless_pro.rb +2 -4
  66. metadata +5 -195
  67. data/.github/workflows/tests.yml +0 -40
  68. data/.gitignore +0 -1
  69. data/.rspec +0 -2
  70. data/.rubocop.yml +0 -5
  71. data/.travis.yml +0 -10
  72. data/Gemfile +0 -10
  73. data/demo.rb +0 -9
  74. data/gocardless_pro.gemspec +0 -39
  75. data/spec/api_response_spec.rb +0 -28
  76. data/spec/api_service_spec.rb +0 -188
  77. data/spec/client_spec.rb +0 -19
  78. data/spec/error_spec.rb +0 -53
  79. data/spec/middlewares/raise_gocardless_errors_spec.rb +0 -127
  80. data/spec/resources/bank_authorisation_spec.rb +0 -259
  81. data/spec/resources/bank_details_lookup_spec.rb +0 -121
  82. data/spec/resources/billing_request_flow_spec.rb +0 -257
  83. data/spec/resources/billing_request_spec.rb +0 -962
  84. data/spec/resources/billing_request_template_spec.rb +0 -515
  85. data/spec/resources/block_spec.rb +0 -577
  86. data/spec/resources/creditor_bank_account_spec.rb +0 -472
  87. data/spec/resources/creditor_spec.rb +0 -659
  88. data/spec/resources/currency_exchange_rate_spec.rb +0 -103
  89. data/spec/resources/customer_bank_account_spec.rb +0 -509
  90. data/spec/resources/customer_notification_spec.rb +0 -75
  91. data/spec/resources/customer_spec.rb +0 -616
  92. data/spec/resources/event_spec.rb +0 -210
  93. data/spec/resources/instalment_schedule_spec.rb +0 -636
  94. data/spec/resources/institution_spec.rb +0 -113
  95. data/spec/resources/mandate_import_entry_spec.rb +0 -206
  96. data/spec/resources/mandate_import_spec.rb +0 -344
  97. data/spec/resources/mandate_pdf_spec.rb +0 -117
  98. data/spec/resources/mandate_spec.rb +0 -600
  99. data/spec/resources/payer_authorisation_spec.rb +0 -422
  100. data/spec/resources/payment_spec.rb +0 -617
  101. data/spec/resources/payout_item_spec.rb +0 -101
  102. data/spec/resources/payout_spec.rb +0 -284
  103. data/spec/resources/redirect_flow_spec.rb +0 -347
  104. data/spec/resources/refund_spec.rb +0 -409
  105. data/spec/resources/scenario_simulator_spec.rb +0 -65
  106. data/spec/resources/scheme_identifier_spec.rb +0 -484
  107. data/spec/resources/subscription_spec.rb +0 -828
  108. data/spec/resources/tax_rate_spec.rb +0 -198
  109. data/spec/resources/verification_detail_spec.rb +0 -145
  110. data/spec/resources/webhook_spec.rb +0 -325
  111. data/spec/response_spec.rb +0 -34
  112. data/spec/services/bank_authorisations_service_spec.rb +0 -353
  113. data/spec/services/bank_details_lookups_service_spec.rb +0 -144
  114. data/spec/services/billing_request_flows_service_spec.rb +0 -291
  115. data/spec/services/billing_request_templates_service_spec.rb +0 -806
  116. data/spec/services/billing_requests_service_spec.rb +0 -1288
  117. data/spec/services/blocks_service_spec.rb +0 -840
  118. data/spec/services/creditor_bank_accounts_service_spec.rb +0 -725
  119. data/spec/services/creditors_service_spec.rb +0 -977
  120. data/spec/services/currency_exchange_rates_service_spec.rb +0 -223
  121. data/spec/services/customer_bank_accounts_service_spec.rb +0 -787
  122. data/spec/services/customer_notifications_service_spec.rb +0 -86
  123. data/spec/services/customers_service_spec.rb +0 -922
  124. data/spec/services/events_service_spec.rb +0 -401
  125. data/spec/services/instalment_schedules_service_spec.rb +0 -945
  126. data/spec/services/institutions_service_spec.rb +0 -241
  127. data/spec/services/mandate_import_entries_service_spec.rb +0 -345
  128. data/spec/services/mandate_imports_service_spec.rb +0 -460
  129. data/spec/services/mandate_pdfs_service_spec.rb +0 -140
  130. data/spec/services/mandates_service_spec.rb +0 -893
  131. data/spec/services/payer_authorisations_service_spec.rb +0 -563
  132. data/spec/services/payments_service_spec.rb +0 -914
  133. data/spec/services/payout_items_service_spec.rb +0 -221
  134. data/spec/services/payouts_service_spec.rb +0 -520
  135. data/spec/services/redirect_flows_service_spec.rb +0 -452
  136. data/spec/services/refunds_service_spec.rb +0 -668
  137. data/spec/services/scenario_simulators_service_spec.rb +0 -76
  138. data/spec/services/scheme_identifiers_service_spec.rb +0 -754
  139. data/spec/services/subscriptions_service_spec.rb +0 -1164
  140. data/spec/services/tax_rates_service_spec.rb +0 -381
  141. data/spec/services/verification_details_service_spec.rb +0 -168
  142. data/spec/services/webhooks_service_spec.rb +0 -547
  143. data/spec/spec_helper.rb +0 -90
  144. data/spec/webhook_spec.rb +0 -122
@@ -1,472 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GoCardlessPro::Resources::CreditorBankAccount do
4
- let(:client) do
5
- GoCardlessPro::Client.new(
6
- access_token: 'SECRET_TOKEN'
7
- )
8
- end
9
-
10
- let(:response_headers) { { 'Content-Type' => 'application/json' } }
11
-
12
- describe '#create' do
13
- subject(:post_create_response) { client.creditor_bank_accounts.create(params: new_resource) }
14
- context 'with a valid request' do
15
- let(:new_resource) do
16
- {
17
-
18
- 'account_holder_name' => 'account_holder_name-input',
19
- 'account_number_ending' => 'account_number_ending-input',
20
- 'account_type' => 'account_type-input',
21
- 'bank_name' => 'bank_name-input',
22
- 'country_code' => 'country_code-input',
23
- 'created_at' => 'created_at-input',
24
- 'currency' => 'currency-input',
25
- 'enabled' => 'enabled-input',
26
- 'id' => 'id-input',
27
- 'links' => 'links-input',
28
- 'metadata' => 'metadata-input',
29
- }
30
- end
31
-
32
- before do
33
- stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).
34
- with(
35
- body: {
36
- 'creditor_bank_accounts' => {
37
-
38
- 'account_holder_name' => 'account_holder_name-input',
39
- 'account_number_ending' => 'account_number_ending-input',
40
- 'account_type' => 'account_type-input',
41
- 'bank_name' => 'bank_name-input',
42
- 'country_code' => 'country_code-input',
43
- 'created_at' => 'created_at-input',
44
- 'currency' => 'currency-input',
45
- 'enabled' => 'enabled-input',
46
- 'id' => 'id-input',
47
- 'links' => 'links-input',
48
- 'metadata' => 'metadata-input',
49
- },
50
- }
51
- ).
52
- to_return(
53
- body: {
54
- 'creditor_bank_accounts' =>
55
-
56
- {
57
-
58
- 'account_holder_name' => 'account_holder_name-input',
59
- 'account_number_ending' => 'account_number_ending-input',
60
- 'account_type' => 'account_type-input',
61
- 'bank_name' => 'bank_name-input',
62
- 'country_code' => 'country_code-input',
63
- 'created_at' => 'created_at-input',
64
- 'currency' => 'currency-input',
65
- 'enabled' => 'enabled-input',
66
- 'id' => 'id-input',
67
- 'links' => 'links-input',
68
- 'metadata' => 'metadata-input',
69
- },
70
-
71
- }.to_json,
72
- headers: response_headers
73
- )
74
- end
75
-
76
- it 'creates and returns the resource' do
77
- expect(post_create_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount)
78
- end
79
- end
80
-
81
- context 'with a request that returns a validation error' do
82
- let(:new_resource) { {} }
83
-
84
- before do
85
- stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).to_return(
86
- body: {
87
- error: {
88
- type: 'validation_failed',
89
- code: 422,
90
- errors: [
91
- { message: 'test error message', field: 'test_field' },
92
- ],
93
- },
94
- }.to_json,
95
- headers: response_headers,
96
- status: 422
97
- )
98
- end
99
-
100
- it 'throws the correct error' do
101
- expect { post_create_response }.to raise_error(GoCardlessPro::ValidationError)
102
- end
103
- end
104
-
105
- context 'with a request that returns an idempotent creation conflict error' do
106
- let(:id) { 'ID123' }
107
-
108
- let(:new_resource) do
109
- {
110
-
111
- 'account_holder_name' => 'account_holder_name-input',
112
- 'account_number_ending' => 'account_number_ending-input',
113
- 'account_type' => 'account_type-input',
114
- 'bank_name' => 'bank_name-input',
115
- 'country_code' => 'country_code-input',
116
- 'created_at' => 'created_at-input',
117
- 'currency' => 'currency-input',
118
- 'enabled' => 'enabled-input',
119
- 'id' => 'id-input',
120
- 'links' => 'links-input',
121
- 'metadata' => 'metadata-input',
122
- }
123
- end
124
-
125
- let!(:post_stub) do
126
- stub_request(:post, %r{.*api.gocardless.com/creditor_bank_accounts}).to_return(
127
- body: {
128
- error: {
129
- type: 'invalid_state',
130
- code: 409,
131
- errors: [
132
- {
133
- message: 'A resource has already been created with this idempotency key',
134
- reason: 'idempotent_creation_conflict',
135
- links: {
136
- conflicting_resource_id: id,
137
- },
138
- },
139
- ],
140
- },
141
- }.to_json,
142
- headers: response_headers,
143
- status: 409
144
- )
145
- end
146
-
147
- let!(:get_stub) do
148
- stub_url = "/creditor_bank_accounts/#{id}"
149
- stub_request(:get, /.*api.gocardless.com#{stub_url}/).
150
- to_return(
151
- body: {
152
- 'creditor_bank_accounts' => {
153
-
154
- 'account_holder_name' => 'account_holder_name-input',
155
- 'account_number_ending' => 'account_number_ending-input',
156
- 'account_type' => 'account_type-input',
157
- 'bank_name' => 'bank_name-input',
158
- 'country_code' => 'country_code-input',
159
- 'created_at' => 'created_at-input',
160
- 'currency' => 'currency-input',
161
- 'enabled' => 'enabled-input',
162
- 'id' => 'id-input',
163
- 'links' => 'links-input',
164
- 'metadata' => 'metadata-input',
165
- },
166
- }.to_json,
167
- headers: response_headers
168
- )
169
- end
170
-
171
- it 'fetches the already-created resource' do
172
- post_create_response
173
- expect(post_stub).to have_been_requested
174
- expect(get_stub).to have_been_requested
175
- end
176
- end
177
- end
178
-
179
- describe '#list' do
180
- describe 'with no filters' do
181
- subject(:get_list_response) { client.creditor_bank_accounts.list }
182
-
183
- before do
184
- stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts}).to_return(
185
- body: {
186
- 'creditor_bank_accounts' => [{
187
-
188
- 'account_holder_name' => 'account_holder_name-input',
189
- 'account_number_ending' => 'account_number_ending-input',
190
- 'account_type' => 'account_type-input',
191
- 'bank_name' => 'bank_name-input',
192
- 'country_code' => 'country_code-input',
193
- 'created_at' => 'created_at-input',
194
- 'currency' => 'currency-input',
195
- 'enabled' => 'enabled-input',
196
- 'id' => 'id-input',
197
- 'links' => 'links-input',
198
- 'metadata' => 'metadata-input',
199
- }],
200
- meta: {
201
- cursors: {
202
- before: nil,
203
- after: 'ABC123',
204
- },
205
- },
206
- }.to_json,
207
- headers: response_headers
208
- )
209
- end
210
-
211
- it 'wraps each item in the resource class' do
212
- expect(get_list_response.records.map(&:class).uniq.first).to eq(GoCardlessPro::Resources::CreditorBankAccount)
213
-
214
- expect(get_list_response.records.first.account_holder_name).to eq('account_holder_name-input')
215
-
216
- expect(get_list_response.records.first.account_number_ending).to eq('account_number_ending-input')
217
-
218
- expect(get_list_response.records.first.account_type).to eq('account_type-input')
219
-
220
- expect(get_list_response.records.first.bank_name).to eq('bank_name-input')
221
-
222
- expect(get_list_response.records.first.country_code).to eq('country_code-input')
223
-
224
- expect(get_list_response.records.first.created_at).to eq('created_at-input')
225
-
226
- expect(get_list_response.records.first.currency).to eq('currency-input')
227
-
228
- expect(get_list_response.records.first.enabled).to eq('enabled-input')
229
-
230
- expect(get_list_response.records.first.id).to eq('id-input')
231
-
232
- expect(get_list_response.records.first.metadata).to eq('metadata-input')
233
- end
234
-
235
- it 'exposes the cursors for before and after' do
236
- expect(get_list_response.before).to eq(nil)
237
- expect(get_list_response.after).to eq('ABC123')
238
- end
239
-
240
- specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
241
- end
242
- end
243
-
244
- describe '#all' do
245
- let!(:first_response_stub) do
246
- stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts$}).to_return(
247
- body: {
248
- 'creditor_bank_accounts' => [{
249
-
250
- 'account_holder_name' => 'account_holder_name-input',
251
- 'account_number_ending' => 'account_number_ending-input',
252
- 'account_type' => 'account_type-input',
253
- 'bank_name' => 'bank_name-input',
254
- 'country_code' => 'country_code-input',
255
- 'created_at' => 'created_at-input',
256
- 'currency' => 'currency-input',
257
- 'enabled' => 'enabled-input',
258
- 'id' => 'id-input',
259
- 'links' => 'links-input',
260
- 'metadata' => 'metadata-input',
261
- }],
262
- meta: {
263
- cursors: { after: 'AB345' },
264
- limit: 1,
265
- },
266
- }.to_json,
267
- headers: response_headers
268
- )
269
- end
270
-
271
- let!(:second_response_stub) do
272
- stub_request(:get, %r{.*api.gocardless.com/creditor_bank_accounts\?after=AB345}).to_return(
273
- body: {
274
- 'creditor_bank_accounts' => [{
275
-
276
- 'account_holder_name' => 'account_holder_name-input',
277
- 'account_number_ending' => 'account_number_ending-input',
278
- 'account_type' => 'account_type-input',
279
- 'bank_name' => 'bank_name-input',
280
- 'country_code' => 'country_code-input',
281
- 'created_at' => 'created_at-input',
282
- 'currency' => 'currency-input',
283
- 'enabled' => 'enabled-input',
284
- 'id' => 'id-input',
285
- 'links' => 'links-input',
286
- 'metadata' => 'metadata-input',
287
- }],
288
- meta: {
289
- limit: 2,
290
- cursors: {},
291
- },
292
- }.to_json,
293
- headers: response_headers
294
- )
295
- end
296
-
297
- it 'automatically makes the extra requests' do
298
- expect(client.creditor_bank_accounts.all.to_a.length).to eq(2)
299
- expect(first_response_stub).to have_been_requested
300
- expect(second_response_stub).to have_been_requested
301
- end
302
- end
303
-
304
- describe '#get' do
305
- let(:id) { 'ID123' }
306
-
307
- subject(:get_response) { client.creditor_bank_accounts.get(id) }
308
-
309
- context 'passing in a custom header' do
310
- let!(:stub) do
311
- stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
312
- stub_request(:get, /.*api.gocardless.com#{stub_url}/).
313
- with(headers: { 'Foo' => 'Bar' }).
314
- to_return(
315
- body: {
316
- 'creditor_bank_accounts' => {
317
-
318
- 'account_holder_name' => 'account_holder_name-input',
319
- 'account_number_ending' => 'account_number_ending-input',
320
- 'account_type' => 'account_type-input',
321
- 'bank_name' => 'bank_name-input',
322
- 'country_code' => 'country_code-input',
323
- 'created_at' => 'created_at-input',
324
- 'currency' => 'currency-input',
325
- 'enabled' => 'enabled-input',
326
- 'id' => 'id-input',
327
- 'links' => 'links-input',
328
- 'metadata' => 'metadata-input',
329
- },
330
- }.to_json,
331
- headers: response_headers
332
- )
333
- end
334
-
335
- subject(:get_response) do
336
- client.creditor_bank_accounts.get(id, headers: {
337
- 'Foo' => 'Bar',
338
- })
339
- end
340
-
341
- it 'includes the header' do
342
- get_response
343
- expect(stub).to have_been_requested
344
- end
345
- end
346
-
347
- context 'when there is a creditor_bank_account to return' do
348
- before do
349
- stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
350
- stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
351
- body: {
352
- 'creditor_bank_accounts' => {
353
-
354
- 'account_holder_name' => 'account_holder_name-input',
355
- 'account_number_ending' => 'account_number_ending-input',
356
- 'account_type' => 'account_type-input',
357
- 'bank_name' => 'bank_name-input',
358
- 'country_code' => 'country_code-input',
359
- 'created_at' => 'created_at-input',
360
- 'currency' => 'currency-input',
361
- 'enabled' => 'enabled-input',
362
- 'id' => 'id-input',
363
- 'links' => 'links-input',
364
- 'metadata' => 'metadata-input',
365
- },
366
- }.to_json,
367
- headers: response_headers
368
- )
369
- end
370
-
371
- it 'wraps the response in a resource' do
372
- expect(get_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount)
373
- end
374
- end
375
-
376
- context 'when nothing is returned' do
377
- before do
378
- stub_url = '/creditor_bank_accounts/:identity'.gsub(':identity', id)
379
- stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
380
- body: '',
381
- headers: response_headers
382
- )
383
- end
384
-
385
- it 'returns nil' do
386
- expect(get_response).to be_nil
387
- end
388
- end
389
-
390
- context "when an ID is specified which can't be included in a valid URI" do
391
- let(:id) { '`' }
392
-
393
- it "doesn't raise an error" do
394
- expect { get_response }.to_not raise_error(/bad URI/)
395
- end
396
- end
397
- end
398
-
399
- describe '#disable' do
400
- subject(:post_response) { client.creditor_bank_accounts.disable(resource_id) }
401
-
402
- let(:resource_id) { 'ABC123' }
403
-
404
- let!(:stub) do
405
- # /creditor_bank_accounts/%v/actions/disable
406
- stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
407
- stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
408
-
409
- body: {
410
- 'creditor_bank_accounts' => {
411
-
412
- 'account_holder_name' => 'account_holder_name-input',
413
- 'account_number_ending' => 'account_number_ending-input',
414
- 'account_type' => 'account_type-input',
415
- 'bank_name' => 'bank_name-input',
416
- 'country_code' => 'country_code-input',
417
- 'created_at' => 'created_at-input',
418
- 'currency' => 'currency-input',
419
- 'enabled' => 'enabled-input',
420
- 'id' => 'id-input',
421
- 'links' => 'links-input',
422
- 'metadata' => 'metadata-input',
423
- },
424
- }.to_json,
425
-
426
- headers: response_headers
427
- )
428
- end
429
-
430
- it 'wraps the response and calls the right endpoint' do
431
- expect(post_response).to be_a(GoCardlessPro::Resources::CreditorBankAccount)
432
-
433
- expect(stub).to have_been_requested
434
- end
435
-
436
- context 'when the request needs a body and custom header' do
437
- let(:body) { { foo: 'bar' } }
438
- let(:headers) { { 'Foo' => 'Bar' } }
439
- subject(:post_response) { client.creditor_bank_accounts.disable(resource_id, body, headers) }
440
-
441
- let(:resource_id) { 'ABC123' }
442
-
443
- let!(:stub) do
444
- # /creditor_bank_accounts/%v/actions/disable
445
- stub_url = '/creditor_bank_accounts/:identity/actions/disable'.gsub(':identity', resource_id)
446
- stub_request(:post, /.*api.gocardless.com#{stub_url}/).
447
- with(
448
- body: { foo: 'bar' },
449
- headers: { 'Foo' => 'Bar' }
450
- ).to_return(
451
- body: {
452
- 'creditor_bank_accounts' => {
453
-
454
- 'account_holder_name' => 'account_holder_name-input',
455
- 'account_number_ending' => 'account_number_ending-input',
456
- 'account_type' => 'account_type-input',
457
- 'bank_name' => 'bank_name-input',
458
- 'country_code' => 'country_code-input',
459
- 'created_at' => 'created_at-input',
460
- 'currency' => 'currency-input',
461
- 'enabled' => 'enabled-input',
462
- 'id' => 'id-input',
463
- 'links' => 'links-input',
464
- 'metadata' => 'metadata-input',
465
- },
466
- }.to_json,
467
- headers: response_headers
468
- )
469
- end
470
- end
471
- end
472
- end