gocardless_pro 2.18.0 → 2.18.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 250fed25fc74cb084ad988286e20f8dd2c679fcb62e0de5a1fc3bfca71b67c43
4
- data.tar.gz: af02087f4d85aafa9337d51219c467bc195c6c9eff6d03b2f9c5dbf209956680
3
+ metadata.gz: 56e422f17e5916ab4eac449f5d12f138bac13589a481b1da75ca70e2da1ceae6
4
+ data.tar.gz: 9df2ae977e5988ab8660062884644b8fdd14051d1866d940a3bd61957cd3436f
5
5
  SHA512:
6
- metadata.gz: a3bd1149c2936dfd1ba6d8b60e7183c279d105046c4c02ab497e2d11da3c3f93c363a56ce5a2c1133138ad9acd421bbfb4c479c1da3970afb4c6b650a0197965
7
- data.tar.gz: '07951005f59ae4328b34342bb24c9b06bfb9f0221a87630751d21b9755354fb3daaf7f0b34bb51d98811f2e1199479be08745afdb66c888953bfad50fc8bc099'
6
+ metadata.gz: 99e3c28948e6b35328daf3744b44ea934644ed64666f2e2887c44057e03b6fb4e66475c97b53a2ace80f41558864142dcbaee49f07f44217a8224360bd47b13f
7
+ data.tar.gz: 1451294c75349cb5342388b69d2676ab61785fe6d4bf5b8b8df88c91295e30e67c209c0c24e9e997e2fb4ef808b97fa3b576f92c4509b2b8132929320cb2f9ac
@@ -148,7 +148,7 @@ module GoCardlessPro
148
148
  'User-Agent' => user_agent.to_s,
149
149
  'Content-Type' => 'application/json',
150
150
  'GoCardless-Client-Library' => 'gocardless-pro-ruby',
151
- 'GoCardless-Client-Version' => '2.18.0',
151
+ 'GoCardless-Client-Version' => '2.18.1',
152
152
  },
153
153
  }
154
154
  end
@@ -23,8 +23,7 @@ module GoCardlessPro
23
23
  # `links[creditor_bank_account]` in the error response.
24
24
  #
25
25
  # <p class="restricted-notice"><strong>Restricted</strong>: This API is not
26
- # available for
27
- # partner integrations.</p>
26
+ # available for partner integrations.</p>
28
27
  class CreditorBankAccount
29
28
  attr_reader :account_holder_name
30
29
  attr_reader :account_number_ending
@@ -23,11 +23,9 @@ module GoCardlessPro
23
23
  # way, it is no longer visible using this API.
24
24
  #
25
25
  # <p class="restricted-notice"><strong>Restricted</strong>: This API is
26
- # currently
27
- # only available for approved integrators - please <a
28
- # href="mailto:help@gocardless.com">get
29
- # in touch</a> if you would like to use this API.</p>
30
- #
26
+ # currently only available for approved integrators - please <a
27
+ # href="mailto:help@gocardless.com">get in touch</a> if you would like to
28
+ # use this API.</p>
31
29
  class CustomerNotification
32
30
  attr_reader :action_taken
33
31
  attr_reader :action_taken_at
@@ -14,7 +14,8 @@ module GoCardlessPro
14
14
 
15
15
  # Events are stored for all webhooks. An event refers to a resource which
16
16
  # has been updated, for example a payment which has been collected, or a
17
- # mandate which has been transferred.
17
+ # mandate which has been transferred. See [here](#event-actions) for a
18
+ # complete list of event types.
18
19
  class Event
19
20
  attr_reader :action
20
21
  attr_reader :created_at
@@ -47,16 +47,13 @@ module GoCardlessPro
47
47
  # system](#mandate-import-entries-list-all-mandate-import-entries).
48
48
  #
49
49
  # <p class="notice">Note that all Mandate Imports have an upper limit of
50
- # 30,000 entries, so
51
- # we recommend you split your import into several smaller imports if you're
52
- # planning to
53
- # exceed this threshold.</p>
50
+ # 30,000 entries, so we recommend you split your import into several smaller
51
+ # imports if you're planning to exceed this threshold.</p>
54
52
  #
55
53
  # <p class="restricted-notice"><strong>Restricted</strong>: This API is
56
- # currently
57
- # only available for approved integrators - please <a
58
- # href="mailto:help@gocardless.com">get
59
- # in touch</a> if you would like to use this API.</p>
54
+ # currently only available for approved integrators - please <a
55
+ # href="mailto:help@gocardless.com">get in touch</a> if you would like to
56
+ # use this API.</p>
60
57
  class MandateImport
61
58
  attr_reader :created_at
62
59
  attr_reader :id
@@ -39,11 +39,9 @@ module GoCardlessPro
39
39
  # been imported.
40
40
  #
41
41
  # <p class="restricted-notice"><strong>Restricted</strong>: This API is
42
- # currently
43
- # only available for approved integrators - please <a
44
- # href="mailto:help@gocardless.com">get
45
- # in touch</a> if you would like to use this API.</p>
46
- #
42
+ # currently only available for approved integrators - please <a
43
+ # href="mailto:help@gocardless.com">get in touch</a> if you would like to
44
+ # use this API.</p>
47
45
  class MandateImportEntry
48
46
  attr_reader :created_at
49
47
  attr_reader :record_identifier
@@ -49,6 +49,7 @@ module GoCardlessPro
49
49
  attr_reader :created_at
50
50
  attr_reader :description
51
51
  attr_reader :id
52
+ attr_reader :metadata
52
53
  attr_reader :redirect_url
53
54
  attr_reader :scheme
54
55
  attr_reader :session_token
@@ -64,6 +65,7 @@ module GoCardlessPro
64
65
  @description = object['description']
65
66
  @id = object['id']
66
67
  @links = object['links']
68
+ @metadata = object['metadata']
67
69
  @redirect_url = object['redirect_url']
68
70
  @scheme = object['scheme']
69
71
  @session_token = object['session_token']
@@ -20,40 +20,45 @@ module GoCardlessPro
20
20
  # The following rules apply when specifying recurrence:
21
21
  #
22
22
  # - The first payment must be charged within 1 year.
23
- # - When neither `month` nor `day_of_month` are present, the subscription
24
- # will recur from the `start_date` based on the `interval_unit`.
25
- # - If `month` or `day_of_month` are present, the recurrence rules will be
26
- # applied from the `start_date`, and the following validations apply:
23
+ # - If `day_of_month` and `start_date` are not provided `start_date` will be
24
+ # the [mandate](#core-endpoints-mandates)'s `next_possible_charge_date` and
25
+ # the subscription will then recur based on the `interval` & `interval_unit`
26
+ # - If `month` or `day_of_month` are present the following validations
27
+ # apply:
27
28
  #
28
- # | interval_unit | month |
29
- # day_of_month |
30
- # | :-------------- | :--------------------------------------------- |
31
- # :-------------------------------------- |
32
- # | yearly | optional (required if `day_of_month` provided) |
33
- # optional (required if `month` provided) |
34
- # | monthly | invalid |
35
- # required |
36
- # | weekly | invalid |
37
- # invalid |
29
+ # | __interval_unit__ | __month__ |
30
+ # __day_of_month__ |
31
+ # | :---------------- | :--------------------------------------------- |
32
+ # :----------------------------------------- |
33
+ # | yearly | optional (required if `day_of_month` provided) |
34
+ # optional (invalid if `month` not provided) |
35
+ # | monthly | invalid |
36
+ # optional |
37
+ # | weekly | invalid |
38
+ # invalid |
38
39
  #
39
40
  # Examples:
40
41
  #
41
- # | interval_unit | interval | month | day_of_month | valid?
42
- # |
43
- # | :-------------- | :--------- | :------ | :------------- |
42
+ # | __interval_unit__ | __interval__ | __month__ | __day_of_month__ | valid?
43
+ # |
44
+ # | :---------------- | :----------- | :-------- | :--------------- |
44
45
  # :------------------------------------------------- |
45
- # | yearly | 1 | january | -1 | valid
46
- # |
47
- # | yearly | 1 | march | | invalid -
48
- # missing `day_of_month` |
49
- # | monthly | 6 | | 12 | valid
50
- # |
51
- # | monthly | 6 | august | 12 | invalid -
52
- # `month` must be blank |
53
- # | weekly | 2 | | | valid
54
- # |
55
- # | weekly | 2 | october | 10 | invalid -
56
- # `month` and `day_of_month` must be blank |
46
+ # | yearly | 1 | january | -1 | valid
47
+ # |
48
+ # | monthly | 6 | | | valid
49
+ # |
50
+ # | monthly | 6 | | 12 | valid
51
+ # |
52
+ # | weekly | 2 | | | valid
53
+ # |
54
+ # | yearly | 1 | march | |
55
+ # invalid - missing `day_of_month` |
56
+ # | yearly | 1 | | 2 |
57
+ # invalid - missing `month` |
58
+ # | monthly | 6 | august | 12 |
59
+ # invalid - `month` must be blank |
60
+ # | weekly | 2 | october | 10 |
61
+ # invalid - `month` and `day_of_month` must be blank |
57
62
  #
58
63
  # ### Rolling dates
59
64
  #
@@ -73,6 +78,7 @@ module GoCardlessPro
73
78
  attr_reader :created_at
74
79
  attr_reader :currency
75
80
  attr_reader :day_of_month
81
+ attr_reader :earliest_charge_date_after_resume
76
82
  attr_reader :end_date
77
83
  attr_reader :id
78
84
  attr_reader :interval
@@ -97,6 +103,7 @@ module GoCardlessPro
97
103
  @created_at = object['created_at']
98
104
  @currency = object['currency']
99
105
  @day_of_month = object['day_of_month']
106
+ @earliest_charge_date_after_resume = object['earliest_charge_date_after_resume']
100
107
  @end_date = object['end_date']
101
108
  @id = object['id']
102
109
  @interval = object['interval']
@@ -123,8 +123,7 @@ module GoCardlessPro
123
123
  # ID.
124
124
  #
125
125
  # <p class="restricted-notice"><strong>The action of removing a customer cannot
126
- # be
127
- # reversed, so please use with care.</strong></p>
126
+ # be reversed, so please use with care.</strong></p>
128
127
  # Example URL: /customers/:identity
129
128
  #
130
129
  # @param identity # Unique identifier, beginning with "CU".
@@ -172,7 +172,7 @@ module GoCardlessPro
172
172
  # This will fail with a `mandate_not_inactive` error if the mandate is already
173
173
  # being submitted, or is active.
174
174
  #
175
- # Mandates can be resubmitted up to 3 times.
175
+ # Mandates can be resubmitted up to 10 times.
176
176
  # Example URL: /mandates/:identity/actions/reinstate
177
177
  #
178
178
  # @param identity # Unique identifier, beginning with "MD". Note that this prefix may not
@@ -138,6 +138,120 @@ module GoCardlessPro
138
138
  Resources::Subscription.new(unenvelope_body(response.body), response)
139
139
  end
140
140
 
141
+ # Pause a subscription object.
142
+ # No payments will be created until it is resumed.
143
+ #
144
+ # This can only be used with subscriptions created with `count` or
145
+ # subscriptions without `count` and `end_date`
146
+ # If the subscription has `count` its `end_date` will be `null` after pausing.
147
+ #
148
+ # This fails with:
149
+ #
150
+ # - `forbidden` if the subscription was created by an app and you are not
151
+ # authenticated as that app, or if the subscription was not created by an app
152
+ # and you are authenticated as an app
153
+ #
154
+ # - `validation_failed` if invalid data is provided when attempting to pause a
155
+ # subscription.
156
+ #
157
+ # - `subscription_not_active` if the subscription is no longer active.
158
+ #
159
+ # - `subscription_already_ended` if the subscription has taken all payments.
160
+ #
161
+ # Example URL: /subscriptions/:identity/actions/pause
162
+ #
163
+ # @param identity # Unique identifier, beginning with "SB".
164
+ # @param options [Hash] parameters as a hash, under a params key.
165
+ def pause(identity, options = {})
166
+ path = sub_url('/subscriptions/:identity/actions/pause', 'identity' => identity)
167
+
168
+ params = options.delete(:params) || {}
169
+ options[:params] = {}
170
+ options[:params]['data'] = params
171
+
172
+ options[:retry_failures] = false
173
+
174
+ begin
175
+ response = make_request(:post, path, options)
176
+
177
+ # Response doesn't raise any errors until #body is called
178
+ response.tap(&:body)
179
+ rescue InvalidStateError => e
180
+ if e.idempotent_creation_conflict?
181
+ case @api_service.on_idempotency_conflict
182
+ when :raise
183
+ raise IdempotencyConflict, e.error
184
+ when :fetch
185
+ return get(e.conflicting_resource_id)
186
+ else
187
+ raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
188
+ end
189
+ end
190
+
191
+ raise e
192
+ end
193
+
194
+ return if response.body.nil?
195
+
196
+ Resources::Subscription.new(unenvelope_body(response.body), response)
197
+ end
198
+
199
+ # Resume a subscription object.
200
+ # Payments will start to be created again based on the subscriptions recurrence
201
+ # rules.
202
+ #
203
+ # This fails with:
204
+ #
205
+ # - `forbidden` if the subscription was created by an app and you are not
206
+ # authenticated as that app, or if the subscription was not created by an app
207
+ # and you are authenticated as an app
208
+ #
209
+ # - `validation_failed` if invalid data is provided when attempting to resume a
210
+ # subscription.
211
+ #
212
+ # - `subscription_not_paused` if the subscription is not paused.
213
+ #
214
+ # - `subscription_already_scheduled_to_resume` if a subscription already has a
215
+ # scheduled resume date.
216
+ #
217
+ # Example URL: /subscriptions/:identity/actions/resume
218
+ #
219
+ # @param identity # Unique identifier, beginning with "SB".
220
+ # @param options [Hash] parameters as a hash, under a params key.
221
+ def resume(identity, options = {})
222
+ path = sub_url('/subscriptions/:identity/actions/resume', 'identity' => identity)
223
+
224
+ params = options.delete(:params) || {}
225
+ options[:params] = {}
226
+ options[:params]['data'] = params
227
+
228
+ options[:retry_failures] = false
229
+
230
+ begin
231
+ response = make_request(:post, path, options)
232
+
233
+ # Response doesn't raise any errors until #body is called
234
+ response.tap(&:body)
235
+ rescue InvalidStateError => e
236
+ if e.idempotent_creation_conflict?
237
+ case @api_service.on_idempotency_conflict
238
+ when :raise
239
+ raise IdempotencyConflict, e.error
240
+ when :fetch
241
+ return get(e.conflicting_resource_id)
242
+ else
243
+ raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
244
+ end
245
+ end
246
+
247
+ raise e
248
+ end
249
+
250
+ return if response.body.nil?
251
+
252
+ Resources::Subscription.new(unenvelope_body(response.body), response)
253
+ end
254
+
141
255
  # Immediately cancels a subscription; no more payments will be created under it.
142
256
  # Any metadata supplied to this endpoint will be stored on the payment
143
257
  # cancellation event it causes.
@@ -4,5 +4,5 @@ end
4
4
 
5
5
  module GoCardlessPro
6
6
  # Current version of the GC gem
7
- VERSION = '2.18.0'.freeze
7
+ VERSION = '2.18.1'.freeze
8
8
  end
@@ -20,6 +20,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
20
20
  'description' => 'description-input',
21
21
  'id' => 'id-input',
22
22
  'links' => 'links-input',
23
+ 'metadata' => 'metadata-input',
23
24
  'redirect_url' => 'redirect_url-input',
24
25
  'scheme' => 'scheme-input',
25
26
  'session_token' => 'session_token-input',
@@ -38,6 +39,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
38
39
  'description' => 'description-input',
39
40
  'id' => 'id-input',
40
41
  'links' => 'links-input',
42
+ 'metadata' => 'metadata-input',
41
43
  'redirect_url' => 'redirect_url-input',
42
44
  'scheme' => 'scheme-input',
43
45
  'session_token' => 'session_token-input',
@@ -56,6 +58,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
56
58
  'description' => 'description-input',
57
59
  'id' => 'id-input',
58
60
  'links' => 'links-input',
61
+ 'metadata' => 'metadata-input',
59
62
  'redirect_url' => 'redirect_url-input',
60
63
  'scheme' => 'scheme-input',
61
64
  'session_token' => 'session_token-input',
@@ -107,6 +110,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
107
110
  'description' => 'description-input',
108
111
  'id' => 'id-input',
109
112
  'links' => 'links-input',
113
+ 'metadata' => 'metadata-input',
110
114
  'redirect_url' => 'redirect_url-input',
111
115
  'scheme' => 'scheme-input',
112
116
  'session_token' => 'session_token-input',
@@ -148,6 +152,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
148
152
  'description' => 'description-input',
149
153
  'id' => 'id-input',
150
154
  'links' => 'links-input',
155
+ 'metadata' => 'metadata-input',
151
156
  'redirect_url' => 'redirect_url-input',
152
157
  'scheme' => 'scheme-input',
153
158
  'session_token' => 'session_token-input',
@@ -185,6 +190,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
185
190
  'description' => 'description-input',
186
191
  'id' => 'id-input',
187
192
  'links' => 'links-input',
193
+ 'metadata' => 'metadata-input',
188
194
  'redirect_url' => 'redirect_url-input',
189
195
  'scheme' => 'scheme-input',
190
196
  'session_token' => 'session_token-input',
@@ -219,6 +225,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
219
225
  'description' => 'description-input',
220
226
  'id' => 'id-input',
221
227
  'links' => 'links-input',
228
+ 'metadata' => 'metadata-input',
222
229
  'redirect_url' => 'redirect_url-input',
223
230
  'scheme' => 'scheme-input',
224
231
  'session_token' => 'session_token-input',
@@ -274,6 +281,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
274
281
  'description' => 'description-input',
275
282
  'id' => 'id-input',
276
283
  'links' => 'links-input',
284
+ 'metadata' => 'metadata-input',
277
285
  'redirect_url' => 'redirect_url-input',
278
286
  'scheme' => 'scheme-input',
279
287
  'session_token' => 'session_token-input',
@@ -313,6 +321,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
313
321
  'description' => 'description-input',
314
322
  'id' => 'id-input',
315
323
  'links' => 'links-input',
324
+ 'metadata' => 'metadata-input',
316
325
  'redirect_url' => 'redirect_url-input',
317
326
  'scheme' => 'scheme-input',
318
327
  'session_token' => 'session_token-input',
@@ -21,6 +21,7 @@ describe GoCardlessPro::Resources::Subscription do
21
21
  'created_at' => 'created_at-input',
22
22
  'currency' => 'currency-input',
23
23
  'day_of_month' => 'day_of_month-input',
24
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
24
25
  'end_date' => 'end_date-input',
25
26
  'id' => 'id-input',
26
27
  'interval' => 'interval-input',
@@ -49,6 +50,7 @@ describe GoCardlessPro::Resources::Subscription do
49
50
  'created_at' => 'created_at-input',
50
51
  'currency' => 'currency-input',
51
52
  'day_of_month' => 'day_of_month-input',
53
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
52
54
  'end_date' => 'end_date-input',
53
55
  'id' => 'id-input',
54
56
  'interval' => 'interval-input',
@@ -77,6 +79,7 @@ describe GoCardlessPro::Resources::Subscription do
77
79
  'created_at' => 'created_at-input',
78
80
  'currency' => 'currency-input',
79
81
  'day_of_month' => 'day_of_month-input',
82
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
80
83
  'end_date' => 'end_date-input',
81
84
  'id' => 'id-input',
82
85
  'interval' => 'interval-input',
@@ -138,6 +141,7 @@ describe GoCardlessPro::Resources::Subscription do
138
141
  'created_at' => 'created_at-input',
139
142
  'currency' => 'currency-input',
140
143
  'day_of_month' => 'day_of_month-input',
144
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
141
145
  'end_date' => 'end_date-input',
142
146
  'id' => 'id-input',
143
147
  'interval' => 'interval-input',
@@ -189,6 +193,7 @@ describe GoCardlessPro::Resources::Subscription do
189
193
  'created_at' => 'created_at-input',
190
194
  'currency' => 'currency-input',
191
195
  'day_of_month' => 'day_of_month-input',
196
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
192
197
  'end_date' => 'end_date-input',
193
198
  'id' => 'id-input',
194
199
  'interval' => 'interval-input',
@@ -231,6 +236,7 @@ describe GoCardlessPro::Resources::Subscription do
231
236
  'created_at' => 'created_at-input',
232
237
  'currency' => 'currency-input',
233
238
  'day_of_month' => 'day_of_month-input',
239
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
234
240
  'end_date' => 'end_date-input',
235
241
  'id' => 'id-input',
236
242
  'interval' => 'interval-input',
@@ -271,6 +277,8 @@ describe GoCardlessPro::Resources::Subscription do
271
277
 
272
278
  expect(get_list_response.records.first.day_of_month).to eq('day_of_month-input')
273
279
 
280
+ expect(get_list_response.records.first.earliest_charge_date_after_resume).to eq('earliest_charge_date_after_resume-input')
281
+
274
282
  expect(get_list_response.records.first.end_date).to eq('end_date-input')
275
283
 
276
284
  expect(get_list_response.records.first.id).to eq('id-input')
@@ -317,6 +325,7 @@ describe GoCardlessPro::Resources::Subscription do
317
325
  'created_at' => 'created_at-input',
318
326
  'currency' => 'currency-input',
319
327
  'day_of_month' => 'day_of_month-input',
328
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
320
329
  'end_date' => 'end_date-input',
321
330
  'id' => 'id-input',
322
331
  'interval' => 'interval-input',
@@ -351,6 +360,7 @@ describe GoCardlessPro::Resources::Subscription do
351
360
  'created_at' => 'created_at-input',
352
361
  'currency' => 'currency-input',
353
362
  'day_of_month' => 'day_of_month-input',
363
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
354
364
  'end_date' => 'end_date-input',
355
365
  'id' => 'id-input',
356
366
  'interval' => 'interval-input',
@@ -401,6 +411,7 @@ describe GoCardlessPro::Resources::Subscription do
401
411
  'created_at' => 'created_at-input',
402
412
  'currency' => 'currency-input',
403
413
  'day_of_month' => 'day_of_month-input',
414
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
404
415
  'end_date' => 'end_date-input',
405
416
  'id' => 'id-input',
406
417
  'interval' => 'interval-input',
@@ -445,6 +456,7 @@ describe GoCardlessPro::Resources::Subscription do
445
456
  'created_at' => 'created_at-input',
446
457
  'currency' => 'currency-input',
447
458
  'day_of_month' => 'day_of_month-input',
459
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
448
460
  'end_date' => 'end_date-input',
449
461
  'id' => 'id-input',
450
462
  'interval' => 'interval-input',
@@ -511,6 +523,7 @@ describe GoCardlessPro::Resources::Subscription do
511
523
  'created_at' => 'created_at-input',
512
524
  'currency' => 'currency-input',
513
525
  'day_of_month' => 'day_of_month-input',
526
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
514
527
  'end_date' => 'end_date-input',
515
528
  'id' => 'id-input',
516
529
  'interval' => 'interval-input',
@@ -537,6 +550,186 @@ describe GoCardlessPro::Resources::Subscription do
537
550
  end
538
551
  end
539
552
 
553
+ describe '#pause' do
554
+ subject(:post_response) { client.subscriptions.pause(resource_id) }
555
+
556
+ let(:resource_id) { 'ABC123' }
557
+
558
+ let!(:stub) do
559
+ # /subscriptions/%v/actions/pause
560
+ stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
561
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
562
+ body: {
563
+ 'subscriptions' => {
564
+
565
+ 'amount' => 'amount-input',
566
+ 'app_fee' => 'app_fee-input',
567
+ 'count' => 'count-input',
568
+ 'created_at' => 'created_at-input',
569
+ 'currency' => 'currency-input',
570
+ 'day_of_month' => 'day_of_month-input',
571
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
572
+ 'end_date' => 'end_date-input',
573
+ 'id' => 'id-input',
574
+ 'interval' => 'interval-input',
575
+ 'interval_unit' => 'interval_unit-input',
576
+ 'links' => 'links-input',
577
+ 'metadata' => 'metadata-input',
578
+ 'month' => 'month-input',
579
+ 'name' => 'name-input',
580
+ 'payment_reference' => 'payment_reference-input',
581
+ 'retry_if_possible' => 'retry_if_possible-input',
582
+ 'start_date' => 'start_date-input',
583
+ 'status' => 'status-input',
584
+ 'upcoming_payments' => 'upcoming_payments-input',
585
+ },
586
+ }.to_json,
587
+ headers: response_headers
588
+ )
589
+ end
590
+
591
+ it 'wraps the response and calls the right endpoint' do
592
+ expect(post_response).to be_a(GoCardlessPro::Resources::Subscription)
593
+
594
+ expect(stub).to have_been_requested
595
+ end
596
+
597
+ context 'when the request needs a body and custom header' do
598
+ let(:body) { { foo: 'bar' } }
599
+ let(:headers) { { 'Foo' => 'Bar' } }
600
+ subject(:post_response) { client.subscriptions.pause(resource_id, body, headers) }
601
+
602
+ let(:resource_id) { 'ABC123' }
603
+
604
+ let!(:stub) do
605
+ # /subscriptions/%v/actions/pause
606
+ stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
607
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
608
+ with(
609
+ body: { foo: 'bar' },
610
+ headers: { 'Foo' => 'Bar' }
611
+ ).to_return(
612
+ body: {
613
+ 'subscriptions' => {
614
+
615
+ 'amount' => 'amount-input',
616
+ 'app_fee' => 'app_fee-input',
617
+ 'count' => 'count-input',
618
+ 'created_at' => 'created_at-input',
619
+ 'currency' => 'currency-input',
620
+ 'day_of_month' => 'day_of_month-input',
621
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
622
+ 'end_date' => 'end_date-input',
623
+ 'id' => 'id-input',
624
+ 'interval' => 'interval-input',
625
+ 'interval_unit' => 'interval_unit-input',
626
+ 'links' => 'links-input',
627
+ 'metadata' => 'metadata-input',
628
+ 'month' => 'month-input',
629
+ 'name' => 'name-input',
630
+ 'payment_reference' => 'payment_reference-input',
631
+ 'retry_if_possible' => 'retry_if_possible-input',
632
+ 'start_date' => 'start_date-input',
633
+ 'status' => 'status-input',
634
+ 'upcoming_payments' => 'upcoming_payments-input',
635
+ },
636
+ }.to_json,
637
+ headers: response_headers
638
+ )
639
+ end
640
+ end
641
+ end
642
+
643
+ describe '#resume' do
644
+ subject(:post_response) { client.subscriptions.resume(resource_id) }
645
+
646
+ let(:resource_id) { 'ABC123' }
647
+
648
+ let!(:stub) do
649
+ # /subscriptions/%v/actions/resume
650
+ stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
651
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
652
+ body: {
653
+ 'subscriptions' => {
654
+
655
+ 'amount' => 'amount-input',
656
+ 'app_fee' => 'app_fee-input',
657
+ 'count' => 'count-input',
658
+ 'created_at' => 'created_at-input',
659
+ 'currency' => 'currency-input',
660
+ 'day_of_month' => 'day_of_month-input',
661
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
662
+ 'end_date' => 'end_date-input',
663
+ 'id' => 'id-input',
664
+ 'interval' => 'interval-input',
665
+ 'interval_unit' => 'interval_unit-input',
666
+ 'links' => 'links-input',
667
+ 'metadata' => 'metadata-input',
668
+ 'month' => 'month-input',
669
+ 'name' => 'name-input',
670
+ 'payment_reference' => 'payment_reference-input',
671
+ 'retry_if_possible' => 'retry_if_possible-input',
672
+ 'start_date' => 'start_date-input',
673
+ 'status' => 'status-input',
674
+ 'upcoming_payments' => 'upcoming_payments-input',
675
+ },
676
+ }.to_json,
677
+ headers: response_headers
678
+ )
679
+ end
680
+
681
+ it 'wraps the response and calls the right endpoint' do
682
+ expect(post_response).to be_a(GoCardlessPro::Resources::Subscription)
683
+
684
+ expect(stub).to have_been_requested
685
+ end
686
+
687
+ context 'when the request needs a body and custom header' do
688
+ let(:body) { { foo: 'bar' } }
689
+ let(:headers) { { 'Foo' => 'Bar' } }
690
+ subject(:post_response) { client.subscriptions.resume(resource_id, body, headers) }
691
+
692
+ let(:resource_id) { 'ABC123' }
693
+
694
+ let!(:stub) do
695
+ # /subscriptions/%v/actions/resume
696
+ stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
697
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
698
+ with(
699
+ body: { foo: 'bar' },
700
+ headers: { 'Foo' => 'Bar' }
701
+ ).to_return(
702
+ body: {
703
+ 'subscriptions' => {
704
+
705
+ 'amount' => 'amount-input',
706
+ 'app_fee' => 'app_fee-input',
707
+ 'count' => 'count-input',
708
+ 'created_at' => 'created_at-input',
709
+ 'currency' => 'currency-input',
710
+ 'day_of_month' => 'day_of_month-input',
711
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
712
+ 'end_date' => 'end_date-input',
713
+ 'id' => 'id-input',
714
+ 'interval' => 'interval-input',
715
+ 'interval_unit' => 'interval_unit-input',
716
+ 'links' => 'links-input',
717
+ 'metadata' => 'metadata-input',
718
+ 'month' => 'month-input',
719
+ 'name' => 'name-input',
720
+ 'payment_reference' => 'payment_reference-input',
721
+ 'retry_if_possible' => 'retry_if_possible-input',
722
+ 'start_date' => 'start_date-input',
723
+ 'status' => 'status-input',
724
+ 'upcoming_payments' => 'upcoming_payments-input',
725
+ },
726
+ }.to_json,
727
+ headers: response_headers
728
+ )
729
+ end
730
+ end
731
+ end
732
+
540
733
  describe '#cancel' do
541
734
  subject(:post_response) { client.subscriptions.cancel(resource_id) }
542
735
 
@@ -555,6 +748,7 @@ describe GoCardlessPro::Resources::Subscription do
555
748
  'created_at' => 'created_at-input',
556
749
  'currency' => 'currency-input',
557
750
  'day_of_month' => 'day_of_month-input',
751
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
558
752
  'end_date' => 'end_date-input',
559
753
  'id' => 'id-input',
560
754
  'interval' => 'interval-input',
@@ -604,6 +798,7 @@ describe GoCardlessPro::Resources::Subscription do
604
798
  'created_at' => 'created_at-input',
605
799
  'currency' => 'currency-input',
606
800
  'day_of_month' => 'day_of_month-input',
801
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
607
802
  'end_date' => 'end_date-input',
608
803
  'id' => 'id-input',
609
804
  'interval' => 'interval-input',
@@ -20,6 +20,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
20
20
  'description' => 'description-input',
21
21
  'id' => 'id-input',
22
22
  'links' => 'links-input',
23
+ 'metadata' => 'metadata-input',
23
24
  'redirect_url' => 'redirect_url-input',
24
25
  'scheme' => 'scheme-input',
25
26
  'session_token' => 'session_token-input',
@@ -38,6 +39,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
38
39
  'description' => 'description-input',
39
40
  'id' => 'id-input',
40
41
  'links' => 'links-input',
42
+ 'metadata' => 'metadata-input',
41
43
  'redirect_url' => 'redirect_url-input',
42
44
  'scheme' => 'scheme-input',
43
45
  'session_token' => 'session_token-input',
@@ -56,6 +58,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
56
58
  'description' => 'description-input',
57
59
  'id' => 'id-input',
58
60
  'links' => 'links-input',
61
+ 'metadata' => 'metadata-input',
59
62
  'redirect_url' => 'redirect_url-input',
60
63
  'scheme' => 'scheme-input',
61
64
  'session_token' => 'session_token-input',
@@ -130,6 +133,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
130
133
  'description' => 'description-input',
131
134
  'id' => 'id-input',
132
135
  'links' => 'links-input',
136
+ 'metadata' => 'metadata-input',
133
137
  'redirect_url' => 'redirect_url-input',
134
138
  'scheme' => 'scheme-input',
135
139
  'session_token' => 'session_token-input',
@@ -171,6 +175,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
171
175
  'description' => 'description-input',
172
176
  'id' => 'id-input',
173
177
  'links' => 'links-input',
178
+ 'metadata' => 'metadata-input',
174
179
  'redirect_url' => 'redirect_url-input',
175
180
  'scheme' => 'scheme-input',
176
181
  'session_token' => 'session_token-input',
@@ -237,6 +242,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
237
242
  'description' => 'description-input',
238
243
  'id' => 'id-input',
239
244
  'links' => 'links-input',
245
+ 'metadata' => 'metadata-input',
240
246
  'redirect_url' => 'redirect_url-input',
241
247
  'scheme' => 'scheme-input',
242
248
  'session_token' => 'session_token-input',
@@ -271,6 +277,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
271
277
  'description' => 'description-input',
272
278
  'id' => 'id-input',
273
279
  'links' => 'links-input',
280
+ 'metadata' => 'metadata-input',
274
281
  'redirect_url' => 'redirect_url-input',
275
282
  'scheme' => 'scheme-input',
276
283
  'session_token' => 'session_token-input',
@@ -381,6 +388,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
381
388
  'description' => 'description-input',
382
389
  'id' => 'id-input',
383
390
  'links' => 'links-input',
391
+ 'metadata' => 'metadata-input',
384
392
  'redirect_url' => 'redirect_url-input',
385
393
  'scheme' => 'scheme-input',
386
394
  'session_token' => 'session_token-input',
@@ -431,6 +439,7 @@ describe GoCardlessPro::Services::RedirectFlowsService do
431
439
  'description' => 'description-input',
432
440
  'id' => 'id-input',
433
441
  'links' => 'links-input',
442
+ 'metadata' => 'metadata-input',
434
443
  'redirect_url' => 'redirect_url-input',
435
444
  'scheme' => 'scheme-input',
436
445
  'session_token' => 'session_token-input',
@@ -21,6 +21,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
21
21
  'created_at' => 'created_at-input',
22
22
  'currency' => 'currency-input',
23
23
  'day_of_month' => 'day_of_month-input',
24
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
24
25
  'end_date' => 'end_date-input',
25
26
  'id' => 'id-input',
26
27
  'interval' => 'interval-input',
@@ -49,6 +50,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
49
50
  'created_at' => 'created_at-input',
50
51
  'currency' => 'currency-input',
51
52
  'day_of_month' => 'day_of_month-input',
53
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
52
54
  'end_date' => 'end_date-input',
53
55
  'id' => 'id-input',
54
56
  'interval' => 'interval-input',
@@ -77,6 +79,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
77
79
  'created_at' => 'created_at-input',
78
80
  'currency' => 'currency-input',
79
81
  'day_of_month' => 'day_of_month-input',
82
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
80
83
  'end_date' => 'end_date-input',
81
84
  'id' => 'id-input',
82
85
  'interval' => 'interval-input',
@@ -161,6 +164,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
161
164
  'created_at' => 'created_at-input',
162
165
  'currency' => 'currency-input',
163
166
  'day_of_month' => 'day_of_month-input',
167
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
164
168
  'end_date' => 'end_date-input',
165
169
  'id' => 'id-input',
166
170
  'interval' => 'interval-input',
@@ -212,6 +216,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
212
216
  'created_at' => 'created_at-input',
213
217
  'currency' => 'currency-input',
214
218
  'day_of_month' => 'day_of_month-input',
219
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
215
220
  'end_date' => 'end_date-input',
216
221
  'id' => 'id-input',
217
222
  'interval' => 'interval-input',
@@ -282,6 +287,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
282
287
  'created_at' => 'created_at-input',
283
288
  'currency' => 'currency-input',
284
289
  'day_of_month' => 'day_of_month-input',
290
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
285
291
  'end_date' => 'end_date-input',
286
292
  'id' => 'id-input',
287
293
  'interval' => 'interval-input',
@@ -327,6 +333,8 @@ describe GoCardlessPro::Services::SubscriptionsService do
327
333
 
328
334
  expect(get_list_response.records.first.day_of_month).to eq('day_of_month-input')
329
335
 
336
+ expect(get_list_response.records.first.earliest_charge_date_after_resume).to eq('earliest_charge_date_after_resume-input')
337
+
330
338
  expect(get_list_response.records.first.end_date).to eq('end_date-input')
331
339
 
332
340
  expect(get_list_response.records.first.id).to eq('id-input')
@@ -396,6 +404,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
396
404
  'created_at' => 'created_at-input',
397
405
  'currency' => 'currency-input',
398
406
  'day_of_month' => 'day_of_month-input',
407
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
399
408
  'end_date' => 'end_date-input',
400
409
  'id' => 'id-input',
401
410
  'interval' => 'interval-input',
@@ -430,6 +439,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
430
439
  'created_at' => 'created_at-input',
431
440
  'currency' => 'currency-input',
432
441
  'day_of_month' => 'day_of_month-input',
442
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
433
443
  'end_date' => 'end_date-input',
434
444
  'id' => 'id-input',
435
445
  'interval' => 'interval-input',
@@ -473,6 +483,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
473
483
  'created_at' => 'created_at-input',
474
484
  'currency' => 'currency-input',
475
485
  'day_of_month' => 'day_of_month-input',
486
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
476
487
  'end_date' => 'end_date-input',
477
488
  'id' => 'id-input',
478
489
  'interval' => 'interval-input',
@@ -507,6 +518,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
507
518
  'created_at' => 'created_at-input',
508
519
  'currency' => 'currency-input',
509
520
  'day_of_month' => 'day_of_month-input',
521
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
510
522
  'end_date' => 'end_date-input',
511
523
  'id' => 'id-input',
512
524
  'interval' => 'interval-input',
@@ -546,6 +558,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
546
558
  'created_at' => 'created_at-input',
547
559
  'currency' => 'currency-input',
548
560
  'day_of_month' => 'day_of_month-input',
561
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
549
562
  'end_date' => 'end_date-input',
550
563
  'id' => 'id-input',
551
564
  'interval' => 'interval-input',
@@ -583,6 +596,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
583
596
  'created_at' => 'created_at-input',
584
597
  'currency' => 'currency-input',
585
598
  'day_of_month' => 'day_of_month-input',
599
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
586
600
  'end_date' => 'end_date-input',
587
601
  'id' => 'id-input',
588
602
  'interval' => 'interval-input',
@@ -633,6 +647,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
633
647
  'created_at' => 'created_at-input',
634
648
  'currency' => 'currency-input',
635
649
  'day_of_month' => 'day_of_month-input',
650
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
636
651
  'end_date' => 'end_date-input',
637
652
  'id' => 'id-input',
638
653
  'interval' => 'interval-input',
@@ -677,6 +692,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
677
692
  'created_at' => 'created_at-input',
678
693
  'currency' => 'currency-input',
679
694
  'day_of_month' => 'day_of_month-input',
695
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
680
696
  'end_date' => 'end_date-input',
681
697
  'id' => 'id-input',
682
698
  'interval' => 'interval-input',
@@ -798,6 +814,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
798
814
  'created_at' => 'created_at-input',
799
815
  'currency' => 'currency-input',
800
816
  'day_of_month' => 'day_of_month-input',
817
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
801
818
  'end_date' => 'end_date-input',
802
819
  'id' => 'id-input',
803
820
  'interval' => 'interval-input',
@@ -849,6 +866,208 @@ describe GoCardlessPro::Services::SubscriptionsService do
849
866
  end
850
867
  end
851
868
 
869
+ describe '#pause' do
870
+ subject(:post_response) { client.subscriptions.pause(resource_id) }
871
+
872
+ let(:resource_id) { 'ABC123' }
873
+
874
+ let!(:stub) do
875
+ # /subscriptions/%v/actions/pause
876
+ stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
877
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
878
+ body: {
879
+ 'subscriptions' => {
880
+
881
+ 'amount' => 'amount-input',
882
+ 'app_fee' => 'app_fee-input',
883
+ 'count' => 'count-input',
884
+ 'created_at' => 'created_at-input',
885
+ 'currency' => 'currency-input',
886
+ 'day_of_month' => 'day_of_month-input',
887
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
888
+ 'end_date' => 'end_date-input',
889
+ 'id' => 'id-input',
890
+ 'interval' => 'interval-input',
891
+ 'interval_unit' => 'interval_unit-input',
892
+ 'links' => 'links-input',
893
+ 'metadata' => 'metadata-input',
894
+ 'month' => 'month-input',
895
+ 'name' => 'name-input',
896
+ 'payment_reference' => 'payment_reference-input',
897
+ 'retry_if_possible' => 'retry_if_possible-input',
898
+ 'start_date' => 'start_date-input',
899
+ 'status' => 'status-input',
900
+ 'upcoming_payments' => 'upcoming_payments-input',
901
+ },
902
+ }.to_json,
903
+ headers: response_headers
904
+ )
905
+ end
906
+
907
+ it 'wraps the response and calls the right endpoint' do
908
+ expect(post_response).to be_a(GoCardlessPro::Resources::Subscription)
909
+
910
+ expect(stub).to have_been_requested
911
+ end
912
+
913
+ describe 'retry behaviour' do
914
+ it "doesn't retry errors" do
915
+ stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
916
+ stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
917
+ to_timeout
918
+
919
+ expect { post_response }.to raise_error(Faraday::TimeoutError)
920
+ expect(stub).to have_been_requested
921
+ end
922
+ end
923
+
924
+ context 'when the request needs a body and custom header' do
925
+ let(:body) { { foo: 'bar' } }
926
+ let(:headers) { { 'Foo' => 'Bar' } }
927
+ subject(:post_response) { client.subscriptions.pause(resource_id, body, headers) }
928
+
929
+ let(:resource_id) { 'ABC123' }
930
+
931
+ let!(:stub) do
932
+ # /subscriptions/%v/actions/pause
933
+ stub_url = '/subscriptions/:identity/actions/pause'.gsub(':identity', resource_id)
934
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
935
+ with(
936
+ body: { foo: 'bar' },
937
+ headers: { 'Foo' => 'Bar' }
938
+ ).to_return(
939
+ body: {
940
+ 'subscriptions' => {
941
+
942
+ 'amount' => 'amount-input',
943
+ 'app_fee' => 'app_fee-input',
944
+ 'count' => 'count-input',
945
+ 'created_at' => 'created_at-input',
946
+ 'currency' => 'currency-input',
947
+ 'day_of_month' => 'day_of_month-input',
948
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
949
+ 'end_date' => 'end_date-input',
950
+ 'id' => 'id-input',
951
+ 'interval' => 'interval-input',
952
+ 'interval_unit' => 'interval_unit-input',
953
+ 'links' => 'links-input',
954
+ 'metadata' => 'metadata-input',
955
+ 'month' => 'month-input',
956
+ 'name' => 'name-input',
957
+ 'payment_reference' => 'payment_reference-input',
958
+ 'retry_if_possible' => 'retry_if_possible-input',
959
+ 'start_date' => 'start_date-input',
960
+ 'status' => 'status-input',
961
+ 'upcoming_payments' => 'upcoming_payments-input',
962
+ },
963
+ }.to_json,
964
+ headers: response_headers
965
+ )
966
+ end
967
+ end
968
+ end
969
+
970
+ describe '#resume' do
971
+ subject(:post_response) { client.subscriptions.resume(resource_id) }
972
+
973
+ let(:resource_id) { 'ABC123' }
974
+
975
+ let!(:stub) do
976
+ # /subscriptions/%v/actions/resume
977
+ stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
978
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
979
+ body: {
980
+ 'subscriptions' => {
981
+
982
+ 'amount' => 'amount-input',
983
+ 'app_fee' => 'app_fee-input',
984
+ 'count' => 'count-input',
985
+ 'created_at' => 'created_at-input',
986
+ 'currency' => 'currency-input',
987
+ 'day_of_month' => 'day_of_month-input',
988
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
989
+ 'end_date' => 'end_date-input',
990
+ 'id' => 'id-input',
991
+ 'interval' => 'interval-input',
992
+ 'interval_unit' => 'interval_unit-input',
993
+ 'links' => 'links-input',
994
+ 'metadata' => 'metadata-input',
995
+ 'month' => 'month-input',
996
+ 'name' => 'name-input',
997
+ 'payment_reference' => 'payment_reference-input',
998
+ 'retry_if_possible' => 'retry_if_possible-input',
999
+ 'start_date' => 'start_date-input',
1000
+ 'status' => 'status-input',
1001
+ 'upcoming_payments' => 'upcoming_payments-input',
1002
+ },
1003
+ }.to_json,
1004
+ headers: response_headers
1005
+ )
1006
+ end
1007
+
1008
+ it 'wraps the response and calls the right endpoint' do
1009
+ expect(post_response).to be_a(GoCardlessPro::Resources::Subscription)
1010
+
1011
+ expect(stub).to have_been_requested
1012
+ end
1013
+
1014
+ describe 'retry behaviour' do
1015
+ it "doesn't retry errors" do
1016
+ stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
1017
+ stub = stub_request(:post, /.*api.gocardless.com#{stub_url}/).
1018
+ to_timeout
1019
+
1020
+ expect { post_response }.to raise_error(Faraday::TimeoutError)
1021
+ expect(stub).to have_been_requested
1022
+ end
1023
+ end
1024
+
1025
+ context 'when the request needs a body and custom header' do
1026
+ let(:body) { { foo: 'bar' } }
1027
+ let(:headers) { { 'Foo' => 'Bar' } }
1028
+ subject(:post_response) { client.subscriptions.resume(resource_id, body, headers) }
1029
+
1030
+ let(:resource_id) { 'ABC123' }
1031
+
1032
+ let!(:stub) do
1033
+ # /subscriptions/%v/actions/resume
1034
+ stub_url = '/subscriptions/:identity/actions/resume'.gsub(':identity', resource_id)
1035
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
1036
+ with(
1037
+ body: { foo: 'bar' },
1038
+ headers: { 'Foo' => 'Bar' }
1039
+ ).to_return(
1040
+ body: {
1041
+ 'subscriptions' => {
1042
+
1043
+ 'amount' => 'amount-input',
1044
+ 'app_fee' => 'app_fee-input',
1045
+ 'count' => 'count-input',
1046
+ 'created_at' => 'created_at-input',
1047
+ 'currency' => 'currency-input',
1048
+ 'day_of_month' => 'day_of_month-input',
1049
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
1050
+ 'end_date' => 'end_date-input',
1051
+ 'id' => 'id-input',
1052
+ 'interval' => 'interval-input',
1053
+ 'interval_unit' => 'interval_unit-input',
1054
+ 'links' => 'links-input',
1055
+ 'metadata' => 'metadata-input',
1056
+ 'month' => 'month-input',
1057
+ 'name' => 'name-input',
1058
+ 'payment_reference' => 'payment_reference-input',
1059
+ 'retry_if_possible' => 'retry_if_possible-input',
1060
+ 'start_date' => 'start_date-input',
1061
+ 'status' => 'status-input',
1062
+ 'upcoming_payments' => 'upcoming_payments-input',
1063
+ },
1064
+ }.to_json,
1065
+ headers: response_headers
1066
+ )
1067
+ end
1068
+ end
1069
+ end
1070
+
852
1071
  describe '#cancel' do
853
1072
  subject(:post_response) { client.subscriptions.cancel(resource_id) }
854
1073
 
@@ -867,6 +1086,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
867
1086
  'created_at' => 'created_at-input',
868
1087
  'currency' => 'currency-input',
869
1088
  'day_of_month' => 'day_of_month-input',
1089
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
870
1090
  'end_date' => 'end_date-input',
871
1091
  'id' => 'id-input',
872
1092
  'interval' => 'interval-input',
@@ -927,6 +1147,7 @@ describe GoCardlessPro::Services::SubscriptionsService do
927
1147
  'created_at' => 'created_at-input',
928
1148
  'currency' => 'currency-input',
929
1149
  'day_of_month' => 'day_of_month-input',
1150
+ 'earliest_charge_date_after_resume' => 'earliest_charge_date_after_resume-input',
930
1151
  'end_date' => 'end_date-input',
931
1152
  'id' => 'id-input',
932
1153
  'interval' => 'interval-input',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gocardless_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.0
4
+ version: 2.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -144,7 +144,6 @@ files:
144
144
  - LICENSE.txt
145
145
  - README.md
146
146
  - demo.rb
147
- - gocardless_pro-2.17.1.gem
148
147
  - gocardless_pro.gemspec
149
148
  - lib/gocardless_pro.rb
150
149
  - lib/gocardless_pro/api_response.rb
@@ -267,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
266
  - !ruby/object:Gem::Version
268
267
  version: '0'
269
268
  requirements: []
270
- rubygems_version: 3.0.6
269
+ rubygems_version: 3.0.3
271
270
  signing_key:
272
271
  specification_version: 4
273
272
  summary: A gem for calling the GoCardless Pro API
Binary file