gocardless_pro 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -0
  3. data/README.md +71 -28
  4. data/gocardless_pro.gemspec +1 -1
  5. data/lib/gocardless_pro/api_service.rb +4 -2
  6. data/lib/gocardless_pro/client.rb +2 -1
  7. data/lib/gocardless_pro/error.rb +12 -1
  8. data/lib/gocardless_pro/resources/mandate.rb +3 -0
  9. data/lib/gocardless_pro/resources/payout.rb +3 -0
  10. data/lib/gocardless_pro/resources/redirect_flow.rb +15 -14
  11. data/lib/gocardless_pro/services/bank_details_lookups_service.rb +10 -0
  12. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +5 -2
  13. data/lib/gocardless_pro/services/creditors_service.rb +5 -2
  14. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +7 -3
  15. data/lib/gocardless_pro/services/customers_service.rb +5 -2
  16. data/lib/gocardless_pro/services/events_service.rb +2 -1
  17. data/lib/gocardless_pro/services/mandate_pdfs_service.rb +2 -1
  18. data/lib/gocardless_pro/services/mandates_service.rb +10 -5
  19. data/lib/gocardless_pro/services/payments_service.rb +11 -6
  20. data/lib/gocardless_pro/services/payouts_service.rb +2 -1
  21. data/lib/gocardless_pro/services/redirect_flows_service.rb +6 -3
  22. data/lib/gocardless_pro/services/refunds_service.rb +5 -2
  23. data/lib/gocardless_pro/services/subscriptions_service.rb +7 -3
  24. data/lib/gocardless_pro/version.rb +1 -1
  25. data/spec/api_response_spec.rb +4 -4
  26. data/spec/api_service_spec.rb +41 -43
  27. data/spec/client_spec.rb +2 -2
  28. data/spec/error_spec.rb +27 -18
  29. data/spec/resources/bank_details_lookup_spec.rb +19 -34
  30. data/spec/resources/creditor_bank_account_spec.rb +54 -99
  31. data/spec/resources/creditor_spec.rb +66 -115
  32. data/spec/resources/customer_bank_account_spec.rb +54 -99
  33. data/spec/resources/customer_spec.rb +71 -138
  34. data/spec/resources/event_spec.rb +74 -107
  35. data/spec/resources/mandate_pdf_spec.rb +15 -26
  36. data/spec/resources/mandate_spec.rb +54 -87
  37. data/spec/resources/payment_spec.rb +70 -119
  38. data/spec/resources/payout_spec.rb +50 -79
  39. data/spec/resources/redirect_flow_spec.rb +58 -95
  40. data/spec/resources/refund_spec.rb +42 -75
  41. data/spec/resources/subscription_spec.rb +82 -155
  42. data/spec/response_spec.rb +45 -46
  43. data/spec/services/bank_details_lookups_service_spec.rb +55 -60
  44. data/spec/services/creditor_bank_accounts_service_spec.rb +303 -347
  45. data/spec/services/creditors_service_spec.rb +290 -333
  46. data/spec/services/customer_bank_accounts_service_spec.rb +332 -380
  47. data/spec/services/customers_service_spec.rb +347 -400
  48. data/spec/services/events_service_spec.rb +154 -184
  49. data/spec/services/mandate_pdfs_service_spec.rb +52 -57
  50. data/spec/services/mandates_service_spec.rb +374 -410
  51. data/spec/services/payments_service_spec.rb +404 -461
  52. data/spec/services/payouts_service_spec.rb +161 -184
  53. data/spec/services/redirect_flows_service_spec.rb +188 -205
  54. data/spec/services/refunds_service_spec.rb +245 -280
  55. data/spec/services/subscriptions_service_spec.rb +423 -485
  56. data/spec/spec_helper.rb +46 -48
  57. metadata +22 -20
@@ -3,460 +3,407 @@ require 'spec_helper'
3
3
  describe GoCardlessPro::Services::CustomersService do
4
4
  let(:client) do
5
5
  GoCardlessPro::Client.new(
6
- access_token: "SECRET_TOKEN"
6
+ access_token: 'SECRET_TOKEN'
7
7
  )
8
8
  end
9
9
 
10
-
11
-
12
-
13
-
14
-
15
-
16
- describe "#create" do
10
+ describe '#create' do
17
11
  subject(:post_create_response) { client.customers.create(params: new_resource) }
18
- context "with a valid request" do
19
- let(:new_resource) do
20
- {
21
-
22
- "address_line1" => "address_line1-input",
23
- "address_line2" => "address_line2-input",
24
- "address_line3" => "address_line3-input",
25
- "city" => "city-input",
26
- "company_name" => "company_name-input",
27
- "country_code" => "country_code-input",
28
- "created_at" => "created_at-input",
29
- "email" => "email-input",
30
- "family_name" => "family_name-input",
31
- "given_name" => "given_name-input",
32
- "id" => "id-input",
33
- "language" => "language-input",
34
- "metadata" => "metadata-input",
35
- "postal_code" => "postal_code-input",
36
- "region" => "region-input",
37
- "swedish_identity_number" => "swedish_identity_number-input",
38
- }
39
- end
12
+ context 'with a valid request' do
13
+ let(:new_resource) do
14
+ {
15
+
16
+ 'address_line1' => 'address_line1-input',
17
+ 'address_line2' => 'address_line2-input',
18
+ 'address_line3' => 'address_line3-input',
19
+ 'city' => 'city-input',
20
+ 'company_name' => 'company_name-input',
21
+ 'country_code' => 'country_code-input',
22
+ 'created_at' => 'created_at-input',
23
+ 'email' => 'email-input',
24
+ 'family_name' => 'family_name-input',
25
+ 'given_name' => 'given_name-input',
26
+ 'id' => 'id-input',
27
+ 'language' => 'language-input',
28
+ 'metadata' => 'metadata-input',
29
+ 'postal_code' => 'postal_code-input',
30
+ 'region' => 'region-input',
31
+ 'swedish_identity_number' => 'swedish_identity_number-input'
32
+ }
33
+ end
40
34
 
41
- before do
42
- stub_request(:post, %r(.*api.gocardless.com/customers)).
43
- with(
35
+ before do
36
+ stub_request(:post, %r{.*api.gocardless.com/customers})
37
+ .with(
44
38
  body: {
45
- "customers" => {
46
-
47
- "address_line1" => "address_line1-input",
48
- "address_line2" => "address_line2-input",
49
- "address_line3" => "address_line3-input",
50
- "city" => "city-input",
51
- "company_name" => "company_name-input",
52
- "country_code" => "country_code-input",
53
- "created_at" => "created_at-input",
54
- "email" => "email-input",
55
- "family_name" => "family_name-input",
56
- "given_name" => "given_name-input",
57
- "id" => "id-input",
58
- "language" => "language-input",
59
- "metadata" => "metadata-input",
60
- "postal_code" => "postal_code-input",
61
- "region" => "region-input",
62
- "swedish_identity_number" => "swedish_identity_number-input",
63
- }
39
+ 'customers' => {
40
+
41
+ 'address_line1' => 'address_line1-input',
42
+ 'address_line2' => 'address_line2-input',
43
+ 'address_line3' => 'address_line3-input',
44
+ 'city' => 'city-input',
45
+ 'company_name' => 'company_name-input',
46
+ 'country_code' => 'country_code-input',
47
+ 'created_at' => 'created_at-input',
48
+ 'email' => 'email-input',
49
+ 'family_name' => 'family_name-input',
50
+ 'given_name' => 'given_name-input',
51
+ 'id' => 'id-input',
52
+ 'language' => 'language-input',
53
+ 'metadata' => 'metadata-input',
54
+ 'postal_code' => 'postal_code-input',
55
+ 'region' => 'region-input',
56
+ 'swedish_identity_number' => 'swedish_identity_number-input'
57
+ }
64
58
  }
65
- ).
66
- to_return(
59
+ )
60
+ .to_return(
67
61
  body: {
68
- "customers" => {
69
-
70
- "address_line1" => "address_line1-input",
71
- "address_line2" => "address_line2-input",
72
- "address_line3" => "address_line3-input",
73
- "city" => "city-input",
74
- "company_name" => "company_name-input",
75
- "country_code" => "country_code-input",
76
- "created_at" => "created_at-input",
77
- "email" => "email-input",
78
- "family_name" => "family_name-input",
79
- "given_name" => "given_name-input",
80
- "id" => "id-input",
81
- "language" => "language-input",
82
- "metadata" => "metadata-input",
83
- "postal_code" => "postal_code-input",
84
- "region" => "region-input",
85
- "swedish_identity_number" => "swedish_identity_number-input",
62
+ 'customers' =>
63
+
64
+ {
65
+
66
+ 'address_line1' => 'address_line1-input',
67
+ 'address_line2' => 'address_line2-input',
68
+ 'address_line3' => 'address_line3-input',
69
+ 'city' => 'city-input',
70
+ 'company_name' => 'company_name-input',
71
+ 'country_code' => 'country_code-input',
72
+ 'created_at' => 'created_at-input',
73
+ 'email' => 'email-input',
74
+ 'family_name' => 'family_name-input',
75
+ 'given_name' => 'given_name-input',
76
+ 'id' => 'id-input',
77
+ 'language' => 'language-input',
78
+ 'metadata' => 'metadata-input',
79
+ 'postal_code' => 'postal_code-input',
80
+ 'region' => 'region-input',
81
+ 'swedish_identity_number' => 'swedish_identity_number-input'
86
82
  }
87
- }.to_json,
88
- :headers => {'Content-Type' => 'application/json'}
89
- )
90
- end
91
-
92
- it "creates and returns the resource" do
93
- expect(post_create_response).to be_a(GoCardlessPro::Resources::Customer)
94
- end
95
- end
96
-
97
- context "with a request that returns a validation error" do
98
- let(:new_resource) { {} }
99
83
 
100
- before do
101
- stub_request(:post, %r(.*api.gocardless.com/customers)).to_return(
102
- body: {
103
- error: {
104
- type: 'validation_failed',
105
- code: 422,
106
- errors: [
107
- { message: 'test error message', field: 'test_field' }
108
- ]
109
- }
110
84
  }.to_json,
111
- headers: {'Content-Type' => 'application/json'},
112
- status: 422
85
+ headers: { 'Content-Type' => 'application/json' }
113
86
  )
114
- end
115
-
116
- it "throws the correct error" do
117
- expect { post_create_response }.to raise_error(GoCardlessPro::ValidationError)
118
- end
119
87
  end
120
- end
121
-
122
-
123
-
124
-
125
-
126
- describe "#list" do
127
- describe "with no filters" do
128
- subject(:get_list_response) { client.customers.list }
129
88
 
130
- before do
131
- stub_request(:get, %r(.*api.gocardless.com/customers)).to_return(
132
- body: {
133
- "customers" => [{
134
-
135
- "address_line1" => "address_line1-input",
136
- "address_line2" => "address_line2-input",
137
- "address_line3" => "address_line3-input",
138
- "city" => "city-input",
139
- "company_name" => "company_name-input",
140
- "country_code" => "country_code-input",
141
- "created_at" => "created_at-input",
142
- "email" => "email-input",
143
- "family_name" => "family_name-input",
144
- "given_name" => "given_name-input",
145
- "id" => "id-input",
146
- "language" => "language-input",
147
- "metadata" => "metadata-input",
148
- "postal_code" => "postal_code-input",
149
- "region" => "region-input",
150
- "swedish_identity_number" => "swedish_identity_number-input",
151
- }],
152
- meta: {
153
- cursors: {
154
- before: nil,
155
- after: "ABC123"
156
- }
157
- }
158
- }.to_json,
159
- :headers => {'Content-Type' => 'application/json'}
160
- )
161
- end
162
-
163
- it "wraps each item in the resource class" do
164
- expect(get_list_response.records.map { |x| x.class }.uniq.first).to eq(GoCardlessPro::Resources::Customer)
165
-
166
-
167
-
168
- expect(get_list_response.records.first.address_line1).to eq("address_line1-input")
169
-
170
-
171
-
172
- expect(get_list_response.records.first.address_line2).to eq("address_line2-input")
173
-
174
-
175
-
176
- expect(get_list_response.records.first.address_line3).to eq("address_line3-input")
177
-
178
-
179
-
180
- expect(get_list_response.records.first.city).to eq("city-input")
181
-
182
-
183
-
184
- expect(get_list_response.records.first.company_name).to eq("company_name-input")
185
-
186
-
187
-
188
- expect(get_list_response.records.first.country_code).to eq("country_code-input")
189
-
190
-
191
-
192
- expect(get_list_response.records.first.created_at).to eq("created_at-input")
193
-
194
-
195
-
196
- expect(get_list_response.records.first.email).to eq("email-input")
197
-
198
-
199
-
200
- expect(get_list_response.records.first.family_name).to eq("family_name-input")
201
-
202
-
203
-
204
- expect(get_list_response.records.first.given_name).to eq("given_name-input")
205
-
206
-
207
-
208
- expect(get_list_response.records.first.id).to eq("id-input")
209
-
210
-
211
-
212
- expect(get_list_response.records.first.language).to eq("language-input")
213
-
214
-
215
-
216
- expect(get_list_response.records.first.metadata).to eq("metadata-input")
217
-
218
-
219
-
220
- expect(get_list_response.records.first.postal_code).to eq("postal_code-input")
221
-
222
-
223
-
224
- expect(get_list_response.records.first.region).to eq("region-input")
225
-
226
-
227
-
228
- expect(get_list_response.records.first.swedish_identity_number).to eq("swedish_identity_number-input")
229
-
230
-
231
- end
232
-
233
- it "exposes the cursors for before and after" do
234
- expect(get_list_response.before).to eq(nil)
235
- expect(get_list_response.after).to eq("ABC123")
236
- end
237
-
238
- specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
89
+ it 'creates and returns the resource' do
90
+ expect(post_create_response).to be_a(GoCardlessPro::Resources::Customer)
239
91
  end
240
92
  end
241
93
 
242
- describe "#all" do
243
- let!(:first_response_stub) do
244
- stub_request(:get, %r(.*api.gocardless.com/customers$)).to_return(
94
+ context 'with a request that returns a validation error' do
95
+ let(:new_resource) { {} }
96
+
97
+ before do
98
+ stub_request(:post, %r{.*api.gocardless.com/customers}).to_return(
245
99
  body: {
246
- "customers" => [{
247
-
248
- "address_line1" => "address_line1-input",
249
- "address_line2" => "address_line2-input",
250
- "address_line3" => "address_line3-input",
251
- "city" => "city-input",
252
- "company_name" => "company_name-input",
253
- "country_code" => "country_code-input",
254
- "created_at" => "created_at-input",
255
- "email" => "email-input",
256
- "family_name" => "family_name-input",
257
- "given_name" => "given_name-input",
258
- "id" => "id-input",
259
- "language" => "language-input",
260
- "metadata" => "metadata-input",
261
- "postal_code" => "postal_code-input",
262
- "region" => "region-input",
263
- "swedish_identity_number" => "swedish_identity_number-input",
264
- }],
265
- meta: {
266
- cursors: { after: 'AB345' },
267
- limit: 1
100
+ error: {
101
+ type: 'validation_failed',
102
+ code: 422,
103
+ errors: [
104
+ { message: 'test error message', field: 'test_field' }
105
+ ]
268
106
  }
269
107
  }.to_json,
270
- :headers => {'Content-Type' => 'application/json'}
108
+ headers: { 'Content-Type' => 'application/json' },
109
+ status: 422
271
110
  )
272
111
  end
273
112
 
274
- let!(:second_response_stub) do
275
- stub_request(:get, %r(.*api.gocardless.com/customers\?after=AB345)).to_return(
113
+ it 'throws the correct error' do
114
+ expect { post_create_response }.to raise_error(GoCardlessPro::ValidationError)
115
+ end
116
+ end
117
+ end
118
+
119
+ describe '#list' do
120
+ describe 'with no filters' do
121
+ subject(:get_list_response) { client.customers.list }
122
+
123
+ before do
124
+ stub_request(:get, %r{.*api.gocardless.com/customers}).to_return(
276
125
  body: {
277
- "customers" => [{
278
-
279
- "address_line1" => "address_line1-input",
280
- "address_line2" => "address_line2-input",
281
- "address_line3" => "address_line3-input",
282
- "city" => "city-input",
283
- "company_name" => "company_name-input",
284
- "country_code" => "country_code-input",
285
- "created_at" => "created_at-input",
286
- "email" => "email-input",
287
- "family_name" => "family_name-input",
288
- "given_name" => "given_name-input",
289
- "id" => "id-input",
290
- "language" => "language-input",
291
- "metadata" => "metadata-input",
292
- "postal_code" => "postal_code-input",
293
- "region" => "region-input",
294
- "swedish_identity_number" => "swedish_identity_number-input",
126
+ 'customers' => [{
127
+
128
+ 'address_line1' => 'address_line1-input',
129
+ 'address_line2' => 'address_line2-input',
130
+ 'address_line3' => 'address_line3-input',
131
+ 'city' => 'city-input',
132
+ 'company_name' => 'company_name-input',
133
+ 'country_code' => 'country_code-input',
134
+ 'created_at' => 'created_at-input',
135
+ 'email' => 'email-input',
136
+ 'family_name' => 'family_name-input',
137
+ 'given_name' => 'given_name-input',
138
+ 'id' => 'id-input',
139
+ 'language' => 'language-input',
140
+ 'metadata' => 'metadata-input',
141
+ 'postal_code' => 'postal_code-input',
142
+ 'region' => 'region-input',
143
+ 'swedish_identity_number' => 'swedish_identity_number-input'
295
144
  }],
296
145
  meta: {
297
- limit: 2,
298
- cursors: {}
146
+ cursors: {
147
+ before: nil,
148
+ after: 'ABC123'
149
+ }
299
150
  }
300
151
  }.to_json,
301
- :headers => {'Content-Type' => 'application/json'}
152
+ headers: { 'Content-Type' => 'application/json' }
302
153
  )
303
154
  end
304
155
 
305
- it "automatically makes the extra requests" do
306
- expect(client.customers.all.to_a.length).to eq(2)
307
- expect(first_response_stub).to have_been_requested
308
- expect(second_response_stub).to have_been_requested
156
+ it 'wraps each item in the resource class' do
157
+ expect(get_list_response.records.map(&:class).uniq.first).to eq(GoCardlessPro::Resources::Customer)
158
+
159
+ expect(get_list_response.records.first.address_line1).to eq('address_line1-input')
160
+
161
+ expect(get_list_response.records.first.address_line2).to eq('address_line2-input')
162
+
163
+ expect(get_list_response.records.first.address_line3).to eq('address_line3-input')
164
+
165
+ expect(get_list_response.records.first.city).to eq('city-input')
166
+
167
+ expect(get_list_response.records.first.company_name).to eq('company_name-input')
168
+
169
+ expect(get_list_response.records.first.country_code).to eq('country_code-input')
170
+
171
+ expect(get_list_response.records.first.created_at).to eq('created_at-input')
172
+
173
+ expect(get_list_response.records.first.email).to eq('email-input')
174
+
175
+ expect(get_list_response.records.first.family_name).to eq('family_name-input')
176
+
177
+ expect(get_list_response.records.first.given_name).to eq('given_name-input')
178
+
179
+ expect(get_list_response.records.first.id).to eq('id-input')
180
+
181
+ expect(get_list_response.records.first.language).to eq('language-input')
182
+
183
+ expect(get_list_response.records.first.metadata).to eq('metadata-input')
184
+
185
+ expect(get_list_response.records.first.postal_code).to eq('postal_code-input')
186
+
187
+ expect(get_list_response.records.first.region).to eq('region-input')
188
+
189
+ expect(get_list_response.records.first.swedish_identity_number).to eq('swedish_identity_number-input')
190
+ end
191
+
192
+ it 'exposes the cursors for before and after' do
193
+ expect(get_list_response.before).to eq(nil)
194
+ expect(get_list_response.after).to eq('ABC123')
309
195
  end
196
+
197
+ specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
198
+ end
199
+ end
200
+
201
+ describe '#all' do
202
+ let!(:first_response_stub) do
203
+ stub_request(:get, %r{.*api.gocardless.com/customers$}).to_return(
204
+ body: {
205
+ 'customers' => [{
206
+
207
+ 'address_line1' => 'address_line1-input',
208
+ 'address_line2' => 'address_line2-input',
209
+ 'address_line3' => 'address_line3-input',
210
+ 'city' => 'city-input',
211
+ 'company_name' => 'company_name-input',
212
+ 'country_code' => 'country_code-input',
213
+ 'created_at' => 'created_at-input',
214
+ 'email' => 'email-input',
215
+ 'family_name' => 'family_name-input',
216
+ 'given_name' => 'given_name-input',
217
+ 'id' => 'id-input',
218
+ 'language' => 'language-input',
219
+ 'metadata' => 'metadata-input',
220
+ 'postal_code' => 'postal_code-input',
221
+ 'region' => 'region-input',
222
+ 'swedish_identity_number' => 'swedish_identity_number-input'
223
+ }],
224
+ meta: {
225
+ cursors: { after: 'AB345' },
226
+ limit: 1
227
+ }
228
+ }.to_json,
229
+ headers: { 'Content-Type' => 'application/json' }
230
+ )
231
+ end
232
+
233
+ let!(:second_response_stub) do
234
+ stub_request(:get, %r{.*api.gocardless.com/customers\?after=AB345}).to_return(
235
+ body: {
236
+ 'customers' => [{
237
+
238
+ 'address_line1' => 'address_line1-input',
239
+ 'address_line2' => 'address_line2-input',
240
+ 'address_line3' => 'address_line3-input',
241
+ 'city' => 'city-input',
242
+ 'company_name' => 'company_name-input',
243
+ 'country_code' => 'country_code-input',
244
+ 'created_at' => 'created_at-input',
245
+ 'email' => 'email-input',
246
+ 'family_name' => 'family_name-input',
247
+ 'given_name' => 'given_name-input',
248
+ 'id' => 'id-input',
249
+ 'language' => 'language-input',
250
+ 'metadata' => 'metadata-input',
251
+ 'postal_code' => 'postal_code-input',
252
+ 'region' => 'region-input',
253
+ 'swedish_identity_number' => 'swedish_identity_number-input'
254
+ }],
255
+ meta: {
256
+ limit: 2,
257
+ cursors: {}
258
+ }
259
+ }.to_json,
260
+ headers: { 'Content-Type' => 'application/json' }
261
+ )
310
262
  end
311
263
 
312
-
313
-
314
-
264
+ it 'automatically makes the extra requests' do
265
+ expect(client.customers.all.to_a.length).to eq(2)
266
+ expect(first_response_stub).to have_been_requested
267
+ expect(second_response_stub).to have_been_requested
268
+ end
269
+ end
315
270
 
316
-
317
- describe "#get" do
318
- let(:id) { "ID123" }
271
+ describe '#get' do
272
+ let(:id) { 'ID123' }
319
273
 
320
- subject(:get_response) { client.customers.get(id) }
274
+ subject(:get_response) { client.customers.get(id) }
321
275
 
322
- context "passing in a custom header" do
323
- let!(:stub) do
324
- stub_url = "/customers/:identity".gsub(':identity', id)
325
- stub_request(:get, %r(.*api.gocardless.com#{stub_url})).
326
- with(headers: { 'Foo' => 'Bar' }).
327
- to_return(
276
+ context 'passing in a custom header' do
277
+ let!(:stub) do
278
+ stub_url = '/customers/:identity'.gsub(':identity', id)
279
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/)
280
+ .with(headers: { 'Foo' => 'Bar' })
281
+ .to_return(
328
282
  body: {
329
- "customers" => {
330
-
331
- "address_line1" => "address_line1-input",
332
- "address_line2" => "address_line2-input",
333
- "address_line3" => "address_line3-input",
334
- "city" => "city-input",
335
- "company_name" => "company_name-input",
336
- "country_code" => "country_code-input",
337
- "created_at" => "created_at-input",
338
- "email" => "email-input",
339
- "family_name" => "family_name-input",
340
- "given_name" => "given_name-input",
341
- "id" => "id-input",
342
- "language" => "language-input",
343
- "metadata" => "metadata-input",
344
- "postal_code" => "postal_code-input",
345
- "region" => "region-input",
346
- "swedish_identity_number" => "swedish_identity_number-input",
283
+ 'customers' => {
284
+
285
+ 'address_line1' => 'address_line1-input',
286
+ 'address_line2' => 'address_line2-input',
287
+ 'address_line3' => 'address_line3-input',
288
+ 'city' => 'city-input',
289
+ 'company_name' => 'company_name-input',
290
+ 'country_code' => 'country_code-input',
291
+ 'created_at' => 'created_at-input',
292
+ 'email' => 'email-input',
293
+ 'family_name' => 'family_name-input',
294
+ 'given_name' => 'given_name-input',
295
+ 'id' => 'id-input',
296
+ 'language' => 'language-input',
297
+ 'metadata' => 'metadata-input',
298
+ 'postal_code' => 'postal_code-input',
299
+ 'region' => 'region-input',
300
+ 'swedish_identity_number' => 'swedish_identity_number-input'
347
301
  }
348
302
  }.to_json,
349
- :headers => {'Content-Type' => 'application/json'}
303
+ headers: { 'Content-Type' => 'application/json' }
350
304
  )
351
- end
352
-
353
- subject(:get_response) do
354
- client.customers.get(id, headers: {
355
- 'Foo' => 'Bar'
356
- })
357
- end
358
-
359
- it "includes the header" do
360
- get_response
361
- expect(stub).to have_been_requested
362
- end
363
305
  end
364
306
 
365
- context "when there is a customer to return" do
366
- before do
367
- stub_url = "/customers/:identity".gsub(':identity', id)
368
- stub_request(:get, %r(.*api.gocardless.com#{stub_url})).to_return(
369
- body: {
370
- "customers" => {
371
-
372
- "address_line1" => "address_line1-input",
373
- "address_line2" => "address_line2-input",
374
- "address_line3" => "address_line3-input",
375
- "city" => "city-input",
376
- "company_name" => "company_name-input",
377
- "country_code" => "country_code-input",
378
- "created_at" => "created_at-input",
379
- "email" => "email-input",
380
- "family_name" => "family_name-input",
381
- "given_name" => "given_name-input",
382
- "id" => "id-input",
383
- "language" => "language-input",
384
- "metadata" => "metadata-input",
385
- "postal_code" => "postal_code-input",
386
- "region" => "region-input",
387
- "swedish_identity_number" => "swedish_identity_number-input",
388
- }
389
- }.to_json,
390
- :headers => {'Content-Type' => 'application/json'}
391
- )
392
- end
307
+ subject(:get_response) do
308
+ client.customers.get(id, headers: {
309
+ 'Foo' => 'Bar'
310
+ })
311
+ end
393
312
 
394
- it "wraps the response in a resource" do
395
- expect(get_response).to be_a(GoCardlessPro::Resources::Customer)
396
- end
313
+ it 'includes the header' do
314
+ get_response
315
+ expect(stub).to have_been_requested
397
316
  end
317
+ end
398
318
 
399
- context "when nothing is returned" do
400
- before do
401
- stub_url = "/customers/:identity".gsub(':identity', id)
402
- stub_request(:get, %r(.*api.gocardless.com#{stub_url})).to_return(
403
- body: "",
404
- headers: { 'Content-Type' => 'application/json' }
405
- )
406
- end
319
+ context 'when there is a customer to return' do
320
+ before do
321
+ stub_url = '/customers/:identity'.gsub(':identity', id)
322
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
323
+ body: {
324
+ 'customers' => {
325
+
326
+ 'address_line1' => 'address_line1-input',
327
+ 'address_line2' => 'address_line2-input',
328
+ 'address_line3' => 'address_line3-input',
329
+ 'city' => 'city-input',
330
+ 'company_name' => 'company_name-input',
331
+ 'country_code' => 'country_code-input',
332
+ 'created_at' => 'created_at-input',
333
+ 'email' => 'email-input',
334
+ 'family_name' => 'family_name-input',
335
+ 'given_name' => 'given_name-input',
336
+ 'id' => 'id-input',
337
+ 'language' => 'language-input',
338
+ 'metadata' => 'metadata-input',
339
+ 'postal_code' => 'postal_code-input',
340
+ 'region' => 'region-input',
341
+ 'swedish_identity_number' => 'swedish_identity_number-input'
342
+ }
343
+ }.to_json,
344
+ headers: { 'Content-Type' => 'application/json' }
345
+ )
346
+ end
407
347
 
408
- it "returns nil" do
409
- expect(get_response).to be_nil
410
- end
348
+ it 'wraps the response in a resource' do
349
+ expect(get_response).to be_a(GoCardlessPro::Resources::Customer)
411
350
  end
412
351
  end
413
352
 
414
-
415
-
416
-
353
+ context 'when nothing is returned' do
354
+ before do
355
+ stub_url = '/customers/:identity'.gsub(':identity', id)
356
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
357
+ body: '',
358
+ headers: { 'Content-Type' => 'application/json' }
359
+ )
360
+ end
361
+
362
+ it 'returns nil' do
363
+ expect(get_response).to be_nil
364
+ end
365
+ end
366
+ end
417
367
 
418
-
419
- describe "#update" do
420
- subject(:put_update_response) { client.customers.update(id, params: update_params) }
421
- let(:id) { "ABC123" }
368
+ describe '#update' do
369
+ subject(:put_update_response) { client.customers.update(id, params: update_params) }
370
+ let(:id) { 'ABC123' }
422
371
 
423
- context "with a valid request" do
424
- let(:update_params) { { "hello" => "world" } }
372
+ context 'with a valid request' do
373
+ let(:update_params) { { 'hello' => 'world' } }
425
374
 
426
- let!(:stub) do
427
- stub_url = "/customers/:identity".gsub(':identity', id)
428
- stub_request(:put, %r(.*api.gocardless.com#{stub_url})).to_return(
429
- body: {
430
- "customers" => {
431
-
432
- "address_line1" => "address_line1-input",
433
- "address_line2" => "address_line2-input",
434
- "address_line3" => "address_line3-input",
435
- "city" => "city-input",
436
- "company_name" => "company_name-input",
437
- "country_code" => "country_code-input",
438
- "created_at" => "created_at-input",
439
- "email" => "email-input",
440
- "family_name" => "family_name-input",
441
- "given_name" => "given_name-input",
442
- "id" => "id-input",
443
- "language" => "language-input",
444
- "metadata" => "metadata-input",
445
- "postal_code" => "postal_code-input",
446
- "region" => "region-input",
447
- "swedish_identity_number" => "swedish_identity_number-input",
448
- }
449
- }.to_json,
450
- :headers => {'Content-Type' => 'application/json'}
451
- )
452
- end
375
+ let!(:stub) do
376
+ stub_url = '/customers/:identity'.gsub(':identity', id)
377
+ stub_request(:put, /.*api.gocardless.com#{stub_url}/).to_return(
378
+ body: {
379
+ 'customers' => {
380
+
381
+ 'address_line1' => 'address_line1-input',
382
+ 'address_line2' => 'address_line2-input',
383
+ 'address_line3' => 'address_line3-input',
384
+ 'city' => 'city-input',
385
+ 'company_name' => 'company_name-input',
386
+ 'country_code' => 'country_code-input',
387
+ 'created_at' => 'created_at-input',
388
+ 'email' => 'email-input',
389
+ 'family_name' => 'family_name-input',
390
+ 'given_name' => 'given_name-input',
391
+ 'id' => 'id-input',
392
+ 'language' => 'language-input',
393
+ 'metadata' => 'metadata-input',
394
+ 'postal_code' => 'postal_code-input',
395
+ 'region' => 'region-input',
396
+ 'swedish_identity_number' => 'swedish_identity_number-input'
397
+ }
398
+ }.to_json,
399
+ headers: { 'Content-Type' => 'application/json' }
400
+ )
401
+ end
453
402
 
454
- it "updates and returns the resource" do
455
- expect(put_update_response).to be_a(GoCardlessPro::Resources::Customer)
456
- expect(stub).to have_been_requested
457
- end
403
+ it 'updates and returns the resource' do
404
+ expect(put_update_response).to be_a(GoCardlessPro::Resources::Customer)
405
+ expect(stub).to have_been_requested
458
406
  end
459
407
  end
460
-
461
-
408
+ end
462
409
  end