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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/circle.yml +11 -3
  4. data/demo.rb +3 -3
  5. data/gocardless_pro.gemspec +6 -6
  6. data/lib/gocardless_pro.rb +2 -1
  7. data/lib/gocardless_pro/api_service.rb +3 -2
  8. data/lib/gocardless_pro/client.rb +6 -6
  9. data/lib/gocardless_pro/error.rb +4 -4
  10. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +4 -4
  11. data/lib/gocardless_pro/request.rb +2 -2
  12. data/lib/gocardless_pro/resources/bank_details_lookup.rb +1 -0
  13. data/lib/gocardless_pro/resources/creditor.rb +1 -0
  14. data/lib/gocardless_pro/resources/creditor_bank_account.rb +1 -0
  15. data/lib/gocardless_pro/resources/customer.rb +1 -0
  16. data/lib/gocardless_pro/resources/customer_bank_account.rb +1 -0
  17. data/lib/gocardless_pro/resources/event.rb +1 -0
  18. data/lib/gocardless_pro/resources/mandate.rb +1 -0
  19. data/lib/gocardless_pro/resources/mandate_pdf.rb +1 -0
  20. data/lib/gocardless_pro/resources/payment.rb +1 -0
  21. data/lib/gocardless_pro/resources/payout.rb +1 -0
  22. data/lib/gocardless_pro/resources/redirect_flow.rb +1 -0
  23. data/lib/gocardless_pro/resources/refund.rb +1 -0
  24. data/lib/gocardless_pro/resources/subscription.rb +1 -0
  25. data/lib/gocardless_pro/services/base_service.rb +1 -1
  26. data/lib/gocardless_pro/version.rb +1 -1
  27. data/spec/api_service_spec.rb +49 -49
  28. data/spec/client_spec.rb +1 -1
  29. data/spec/error_spec.rb +13 -13
  30. data/spec/middlewares/raise_gocardless_errors_spec.rb +15 -16
  31. data/spec/resources/bank_details_lookup_spec.rb +18 -18
  32. data/spec/resources/creditor_bank_account_spec.rb +46 -46
  33. data/spec/resources/creditor_spec.rb +42 -42
  34. data/spec/resources/customer_bank_account_spec.rb +48 -48
  35. data/spec/resources/customer_spec.rb +42 -42
  36. data/spec/resources/event_spec.rb +18 -18
  37. data/spec/resources/mandate_pdf_spec.rb +18 -18
  38. data/spec/resources/mandate_spec.rb +54 -54
  39. data/spec/resources/payment_spec.rb +54 -54
  40. data/spec/resources/payout_spec.rb +18 -18
  41. data/spec/resources/redirect_flow_spec.rb +36 -36
  42. data/spec/resources/refund_spec.rb +42 -42
  43. data/spec/resources/subscription_spec.rb +48 -48
  44. data/spec/response_spec.rb +1 -2
  45. data/spec/services/bank_details_lookups_service_spec.rb +25 -25
  46. data/spec/services/creditor_bank_accounts_service_spec.rb +86 -86
  47. data/spec/services/creditors_service_spec.rb +87 -87
  48. data/spec/services/customer_bank_accounts_service_spec.rb +95 -95
  49. data/spec/services/customers_service_spec.rb +87 -87
  50. data/spec/services/events_service_spec.rb +49 -49
  51. data/spec/services/mandate_pdfs_service_spec.rb +25 -25
  52. data/spec/services/mandates_service_spec.rb +103 -103
  53. data/spec/services/payments_service_spec.rb +103 -103
  54. data/spec/services/payouts_service_spec.rb +49 -49
  55. data/spec/services/redirect_flows_service_spec.rb +52 -52
  56. data/spec/services/refunds_service_spec.rb +87 -87
  57. data/spec/services/subscriptions_service_spec.rb +95 -95
  58. metadata +10 -10
@@ -27,14 +27,14 @@ describe GoCardlessPro::Resources::Payout do
27
27
  'links' => 'links-input',
28
28
  'payout_type' => 'payout_type-input',
29
29
  'reference' => 'reference-input',
30
- 'status' => 'status-input'
30
+ 'status' => 'status-input',
31
31
  }],
32
32
  meta: {
33
33
  cursors: {
34
34
  before: nil,
35
- after: 'ABC123'
36
- }
37
- }
35
+ after: 'ABC123',
36
+ },
37
+ },
38
38
  }.to_json,
39
39
  headers: response_headers
40
40
  )
@@ -86,12 +86,12 @@ describe GoCardlessPro::Resources::Payout do
86
86
  'links' => 'links-input',
87
87
  'payout_type' => 'payout_type-input',
88
88
  'reference' => 'reference-input',
89
- 'status' => 'status-input'
89
+ 'status' => 'status-input',
90
90
  }],
91
91
  meta: {
92
92
  cursors: { after: 'AB345' },
93
- limit: 1
94
- }
93
+ limit: 1,
94
+ },
95
95
  }.to_json,
96
96
  headers: response_headers
97
97
  )
@@ -111,12 +111,12 @@ describe GoCardlessPro::Resources::Payout do
111
111
  'links' => 'links-input',
112
112
  'payout_type' => 'payout_type-input',
113
113
  'reference' => 'reference-input',
114
- 'status' => 'status-input'
114
+ 'status' => 'status-input',
115
115
  }],
116
116
  meta: {
117
117
  limit: 2,
118
- cursors: {}
119
- }
118
+ cursors: {},
119
+ },
120
120
  }.to_json,
121
121
  headers: response_headers
122
122
  )
@@ -137,9 +137,9 @@ describe GoCardlessPro::Resources::Payout do
137
137
  context 'passing in a custom header' do
138
138
  let!(:stub) do
139
139
  stub_url = '/payouts/:identity'.gsub(':identity', id)
140
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
141
- .with(headers: { 'Foo' => 'Bar' })
142
- .to_return(
140
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
141
+ with(headers: { 'Foo' => 'Bar' }).
142
+ to_return(
143
143
  body: {
144
144
  'payouts' => {
145
145
 
@@ -152,8 +152,8 @@ describe GoCardlessPro::Resources::Payout do
152
152
  'links' => 'links-input',
153
153
  'payout_type' => 'payout_type-input',
154
154
  'reference' => 'reference-input',
155
- 'status' => 'status-input'
156
- }
155
+ 'status' => 'status-input',
156
+ },
157
157
  }.to_json,
158
158
  headers: response_headers
159
159
  )
@@ -161,7 +161,7 @@ describe GoCardlessPro::Resources::Payout do
161
161
 
162
162
  subject(:get_response) do
163
163
  client.payouts.get(id, headers: {
164
- 'Foo' => 'Bar'
164
+ 'Foo' => 'Bar',
165
165
  })
166
166
  end
167
167
 
@@ -187,8 +187,8 @@ describe GoCardlessPro::Resources::Payout do
187
187
  'links' => 'links-input',
188
188
  'payout_type' => 'payout_type-input',
189
189
  'reference' => 'reference-input',
190
- 'status' => 'status-input'
191
- }
190
+ 'status' => 'status-input',
191
+ },
192
192
  }.to_json,
193
193
  headers: response_headers
194
194
  )
@@ -22,13 +22,13 @@ describe GoCardlessPro::Resources::RedirectFlow do
22
22
  'redirect_url' => 'redirect_url-input',
23
23
  'scheme' => 'scheme-input',
24
24
  'session_token' => 'session_token-input',
25
- 'success_redirect_url' => 'success_redirect_url-input'
25
+ 'success_redirect_url' => 'success_redirect_url-input',
26
26
  }
27
27
  end
28
28
 
29
29
  before do
30
- stub_request(:post, %r{.*api.gocardless.com/redirect_flows})
31
- .with(
30
+ stub_request(:post, %r{.*api.gocardless.com/redirect_flows}).
31
+ with(
32
32
  body: {
33
33
  'redirect_flows' => {
34
34
 
@@ -39,11 +39,11 @@ describe GoCardlessPro::Resources::RedirectFlow do
39
39
  'redirect_url' => 'redirect_url-input',
40
40
  'scheme' => 'scheme-input',
41
41
  'session_token' => 'session_token-input',
42
- 'success_redirect_url' => 'success_redirect_url-input'
43
- }
42
+ 'success_redirect_url' => 'success_redirect_url-input',
43
+ },
44
44
  }
45
- )
46
- .to_return(
45
+ ).
46
+ to_return(
47
47
  body: {
48
48
  'redirect_flows' =>
49
49
 
@@ -56,8 +56,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
56
56
  'redirect_url' => 'redirect_url-input',
57
57
  'scheme' => 'scheme-input',
58
58
  'session_token' => 'session_token-input',
59
- 'success_redirect_url' => 'success_redirect_url-input'
60
- }
59
+ 'success_redirect_url' => 'success_redirect_url-input',
60
+ },
61
61
 
62
62
  }.to_json,
63
63
  headers: response_headers
@@ -79,9 +79,9 @@ describe GoCardlessPro::Resources::RedirectFlow do
79
79
  type: 'validation_failed',
80
80
  code: 422,
81
81
  errors: [
82
- { message: 'test error message', field: 'test_field' }
83
- ]
84
- }
82
+ { message: 'test error message', field: 'test_field' },
83
+ ],
84
+ },
85
85
  }.to_json,
86
86
  headers: response_headers,
87
87
  status: 422
@@ -106,7 +106,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
106
106
  'redirect_url' => 'redirect_url-input',
107
107
  'scheme' => 'scheme-input',
108
108
  'session_token' => 'session_token-input',
109
- 'success_redirect_url' => 'success_redirect_url-input'
109
+ 'success_redirect_url' => 'success_redirect_url-input',
110
110
  }
111
111
  end
112
112
 
@@ -121,11 +121,11 @@ describe GoCardlessPro::Resources::RedirectFlow do
121
121
  message: 'A resource has already been created with this idempotency key',
122
122
  reason: 'idempotent_creation_conflict',
123
123
  links: {
124
- conflicting_resource_id: id
125
- }
126
- }
127
- ]
128
- }
124
+ conflicting_resource_id: id,
125
+ },
126
+ },
127
+ ],
128
+ },
129
129
  }.to_json,
130
130
  headers: response_headers,
131
131
  status: 409
@@ -134,8 +134,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
134
134
 
135
135
  let!(:get_stub) do
136
136
  stub_url = "/redirect_flows/#{id}"
137
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
138
- .to_return(
137
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
138
+ to_return(
139
139
  body: {
140
140
  'redirect_flows' => {
141
141
 
@@ -146,8 +146,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
146
146
  'redirect_url' => 'redirect_url-input',
147
147
  'scheme' => 'scheme-input',
148
148
  'session_token' => 'session_token-input',
149
- 'success_redirect_url' => 'success_redirect_url-input'
150
- }
149
+ 'success_redirect_url' => 'success_redirect_url-input',
150
+ },
151
151
  }.to_json,
152
152
  headers: response_headers
153
153
  )
@@ -169,9 +169,9 @@ describe GoCardlessPro::Resources::RedirectFlow do
169
169
  context 'passing in a custom header' do
170
170
  let!(:stub) do
171
171
  stub_url = '/redirect_flows/:identity'.gsub(':identity', id)
172
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
173
- .with(headers: { 'Foo' => 'Bar' })
174
- .to_return(
172
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
173
+ with(headers: { 'Foo' => 'Bar' }).
174
+ to_return(
175
175
  body: {
176
176
  'redirect_flows' => {
177
177
 
@@ -182,8 +182,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
182
182
  'redirect_url' => 'redirect_url-input',
183
183
  'scheme' => 'scheme-input',
184
184
  'session_token' => 'session_token-input',
185
- 'success_redirect_url' => 'success_redirect_url-input'
186
- }
185
+ 'success_redirect_url' => 'success_redirect_url-input',
186
+ },
187
187
  }.to_json,
188
188
  headers: response_headers
189
189
  )
@@ -191,7 +191,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
191
191
 
192
192
  subject(:get_response) do
193
193
  client.redirect_flows.get(id, headers: {
194
- 'Foo' => 'Bar'
194
+ 'Foo' => 'Bar',
195
195
  })
196
196
  end
197
197
 
@@ -215,8 +215,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
215
215
  'redirect_url' => 'redirect_url-input',
216
216
  'scheme' => 'scheme-input',
217
217
  'session_token' => 'session_token-input',
218
- 'success_redirect_url' => 'success_redirect_url-input'
219
- }
218
+ 'success_redirect_url' => 'success_redirect_url-input',
219
+ },
220
220
  }.to_json,
221
221
  headers: response_headers
222
222
  )
@@ -269,8 +269,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
269
269
  'redirect_url' => 'redirect_url-input',
270
270
  'scheme' => 'scheme-input',
271
271
  'session_token' => 'session_token-input',
272
- 'success_redirect_url' => 'success_redirect_url-input'
273
- }
272
+ 'success_redirect_url' => 'success_redirect_url-input',
273
+ },
274
274
  }.to_json,
275
275
  headers: response_headers
276
276
  )
@@ -292,8 +292,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
292
292
  let!(:stub) do
293
293
  # /redirect_flows/%v/actions/complete
294
294
  stub_url = '/redirect_flows/:identity/actions/complete'.gsub(':identity', resource_id)
295
- stub_request(:post, /.*api.gocardless.com#{stub_url}/)
296
- .with(
295
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
296
+ with(
297
297
  body: { foo: 'bar' },
298
298
  headers: { 'Foo' => 'Bar' }
299
299
  ).to_return(
@@ -307,8 +307,8 @@ describe GoCardlessPro::Resources::RedirectFlow do
307
307
  'redirect_url' => 'redirect_url-input',
308
308
  'scheme' => 'scheme-input',
309
309
  'session_token' => 'session_token-input',
310
- 'success_redirect_url' => 'success_redirect_url-input'
311
- }
310
+ 'success_redirect_url' => 'success_redirect_url-input',
311
+ },
312
312
  }.to_json,
313
313
  headers: response_headers
314
314
  )
@@ -21,13 +21,13 @@ describe GoCardlessPro::Resources::Refund do
21
21
  'id' => 'id-input',
22
22
  'links' => 'links-input',
23
23
  'metadata' => 'metadata-input',
24
- 'reference' => 'reference-input'
24
+ 'reference' => 'reference-input',
25
25
  }
26
26
  end
27
27
 
28
28
  before do
29
- stub_request(:post, %r{.*api.gocardless.com/refunds})
30
- .with(
29
+ stub_request(:post, %r{.*api.gocardless.com/refunds}).
30
+ with(
31
31
  body: {
32
32
  'refunds' => {
33
33
 
@@ -37,11 +37,11 @@ describe GoCardlessPro::Resources::Refund do
37
37
  'id' => 'id-input',
38
38
  'links' => 'links-input',
39
39
  'metadata' => 'metadata-input',
40
- 'reference' => 'reference-input'
41
- }
40
+ 'reference' => 'reference-input',
41
+ },
42
42
  }
43
- )
44
- .to_return(
43
+ ).
44
+ to_return(
45
45
  body: {
46
46
  'refunds' =>
47
47
 
@@ -53,8 +53,8 @@ describe GoCardlessPro::Resources::Refund do
53
53
  'id' => 'id-input',
54
54
  'links' => 'links-input',
55
55
  'metadata' => 'metadata-input',
56
- 'reference' => 'reference-input'
57
- }
56
+ 'reference' => 'reference-input',
57
+ },
58
58
 
59
59
  }.to_json,
60
60
  headers: response_headers
@@ -76,9 +76,9 @@ describe GoCardlessPro::Resources::Refund do
76
76
  type: 'validation_failed',
77
77
  code: 422,
78
78
  errors: [
79
- { message: 'test error message', field: 'test_field' }
80
- ]
81
- }
79
+ { message: 'test error message', field: 'test_field' },
80
+ ],
81
+ },
82
82
  }.to_json,
83
83
  headers: response_headers,
84
84
  status: 422
@@ -102,7 +102,7 @@ describe GoCardlessPro::Resources::Refund do
102
102
  'id' => 'id-input',
103
103
  'links' => 'links-input',
104
104
  'metadata' => 'metadata-input',
105
- 'reference' => 'reference-input'
105
+ 'reference' => 'reference-input',
106
106
  }
107
107
  end
108
108
 
@@ -117,11 +117,11 @@ describe GoCardlessPro::Resources::Refund do
117
117
  message: 'A resource has already been created with this idempotency key',
118
118
  reason: 'idempotent_creation_conflict',
119
119
  links: {
120
- conflicting_resource_id: id
121
- }
122
- }
123
- ]
124
- }
120
+ conflicting_resource_id: id,
121
+ },
122
+ },
123
+ ],
124
+ },
125
125
  }.to_json,
126
126
  headers: response_headers,
127
127
  status: 409
@@ -130,8 +130,8 @@ describe GoCardlessPro::Resources::Refund do
130
130
 
131
131
  let!(:get_stub) do
132
132
  stub_url = "/refunds/#{id}"
133
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
134
- .to_return(
133
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
134
+ to_return(
135
135
  body: {
136
136
  'refunds' => {
137
137
 
@@ -141,8 +141,8 @@ describe GoCardlessPro::Resources::Refund do
141
141
  'id' => 'id-input',
142
142
  'links' => 'links-input',
143
143
  'metadata' => 'metadata-input',
144
- 'reference' => 'reference-input'
145
- }
144
+ 'reference' => 'reference-input',
145
+ },
146
146
  }.to_json,
147
147
  headers: response_headers
148
148
  )
@@ -171,14 +171,14 @@ describe GoCardlessPro::Resources::Refund do
171
171
  'id' => 'id-input',
172
172
  'links' => 'links-input',
173
173
  'metadata' => 'metadata-input',
174
- 'reference' => 'reference-input'
174
+ 'reference' => 'reference-input',
175
175
  }],
176
176
  meta: {
177
177
  cursors: {
178
178
  before: nil,
179
- after: 'ABC123'
180
- }
181
- }
179
+ after: 'ABC123',
180
+ },
181
+ },
182
182
  }.to_json,
183
183
  headers: response_headers
184
184
  )
@@ -221,12 +221,12 @@ describe GoCardlessPro::Resources::Refund do
221
221
  'id' => 'id-input',
222
222
  'links' => 'links-input',
223
223
  'metadata' => 'metadata-input',
224
- 'reference' => 'reference-input'
224
+ 'reference' => 'reference-input',
225
225
  }],
226
226
  meta: {
227
227
  cursors: { after: 'AB345' },
228
- limit: 1
229
- }
228
+ limit: 1,
229
+ },
230
230
  }.to_json,
231
231
  headers: response_headers
232
232
  )
@@ -243,12 +243,12 @@ describe GoCardlessPro::Resources::Refund do
243
243
  'id' => 'id-input',
244
244
  'links' => 'links-input',
245
245
  'metadata' => 'metadata-input',
246
- 'reference' => 'reference-input'
246
+ 'reference' => 'reference-input',
247
247
  }],
248
248
  meta: {
249
249
  limit: 2,
250
- cursors: {}
251
- }
250
+ cursors: {},
251
+ },
252
252
  }.to_json,
253
253
  headers: response_headers
254
254
  )
@@ -269,9 +269,9 @@ describe GoCardlessPro::Resources::Refund do
269
269
  context 'passing in a custom header' do
270
270
  let!(:stub) do
271
271
  stub_url = '/refunds/:identity'.gsub(':identity', id)
272
- stub_request(:get, /.*api.gocardless.com#{stub_url}/)
273
- .with(headers: { 'Foo' => 'Bar' })
274
- .to_return(
272
+ stub_request(:get, /.*api.gocardless.com#{stub_url}/).
273
+ with(headers: { 'Foo' => 'Bar' }).
274
+ to_return(
275
275
  body: {
276
276
  'refunds' => {
277
277
 
@@ -281,8 +281,8 @@ describe GoCardlessPro::Resources::Refund do
281
281
  'id' => 'id-input',
282
282
  'links' => 'links-input',
283
283
  'metadata' => 'metadata-input',
284
- 'reference' => 'reference-input'
285
- }
284
+ 'reference' => 'reference-input',
285
+ },
286
286
  }.to_json,
287
287
  headers: response_headers
288
288
  )
@@ -290,7 +290,7 @@ describe GoCardlessPro::Resources::Refund do
290
290
 
291
291
  subject(:get_response) do
292
292
  client.refunds.get(id, headers: {
293
- 'Foo' => 'Bar'
293
+ 'Foo' => 'Bar',
294
294
  })
295
295
  end
296
296
 
@@ -313,8 +313,8 @@ describe GoCardlessPro::Resources::Refund do
313
313
  'id' => 'id-input',
314
314
  'links' => 'links-input',
315
315
  'metadata' => 'metadata-input',
316
- 'reference' => 'reference-input'
317
- }
316
+ 'reference' => 'reference-input',
317
+ },
318
318
  }.to_json,
319
319
  headers: response_headers
320
320
  )
@@ -367,8 +367,8 @@ describe GoCardlessPro::Resources::Refund do
367
367
  'id' => 'id-input',
368
368
  'links' => 'links-input',
369
369
  'metadata' => 'metadata-input',
370
- 'reference' => 'reference-input'
371
- }
370
+ 'reference' => 'reference-input',
371
+ },
372
372
  }.to_json,
373
373
  headers: response_headers
374
374
  )