gocardless_pro 2.24.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -4
- data/lib/gocardless_pro/api_service.rb +4 -0
- data/lib/gocardless_pro/client.rb +46 -1
- data/lib/gocardless_pro/error/authentication_error.rb +4 -0
- data/lib/gocardless_pro/error/permission_error.rb +4 -0
- data/lib/gocardless_pro/error/rate_limit_error.rb +4 -0
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +12 -1
- data/lib/gocardless_pro/resources/bank_authorisation.rb +81 -0
- data/lib/gocardless_pro/resources/billing_request.rb +108 -0
- data/lib/gocardless_pro/resources/billing_request_flow.rb +72 -0
- data/lib/gocardless_pro/resources/billing_request_template.rb +68 -0
- data/lib/gocardless_pro/resources/block.rb +66 -0
- data/lib/gocardless_pro/resources/creditor.rb +2 -3
- data/lib/gocardless_pro/resources/event.rb +20 -0
- data/lib/gocardless_pro/resources/institution.rb +47 -0
- data/lib/gocardless_pro/resources/payer_authorisation.rb +131 -0
- data/lib/gocardless_pro/resources/payout_item.rb +4 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +2 -0
- data/lib/gocardless_pro/resources/scenario_simulator.rb +42 -0
- data/lib/gocardless_pro/resources/webhook.rb +62 -0
- data/lib/gocardless_pro/services/bank_authorisations_service.rb +80 -0
- data/lib/gocardless_pro/services/billing_request_flows_service.rb +70 -0
- data/lib/gocardless_pro/services/billing_request_templates_service.rb +131 -0
- data/lib/gocardless_pro/services/billing_requests_service.rb +352 -0
- data/lib/gocardless_pro/services/blocks_service.rb +223 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +1 -5
- data/lib/gocardless_pro/services/creditors_service.rb +1 -3
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +1 -1
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +1 -5
- data/lib/gocardless_pro/services/customers_service.rb +1 -3
- data/lib/gocardless_pro/services/events_service.rb +1 -1
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +1 -7
- data/lib/gocardless_pro/services/institutions_service.rb +56 -0
- data/lib/gocardless_pro/services/mandate_import_entries_service.rb +1 -1
- data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -6
- data/lib/gocardless_pro/services/mandates_service.rb +1 -7
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +202 -0
- data/lib/gocardless_pro/services/payments_service.rb +1 -7
- data/lib/gocardless_pro/services/payout_items_service.rb +1 -1
- data/lib/gocardless_pro/services/payouts_service.rb +1 -1
- data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -4
- data/lib/gocardless_pro/services/refunds_service.rb +1 -3
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +170 -0
- data/lib/gocardless_pro/services/subscriptions_service.rb +10 -13
- data/lib/gocardless_pro/services/tax_rates_service.rb +1 -1
- data/lib/gocardless_pro/services/webhooks_service.rb +111 -0
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro.rb +30 -0
- data/spec/api_service_spec.rb +12 -1
- data/spec/middlewares/raise_gocardless_errors_spec.rb +30 -0
- data/spec/resources/bank_authorisation_spec.rb +259 -0
- data/spec/resources/billing_request_flow_spec.rb +219 -0
- data/spec/resources/billing_request_spec.rb +782 -0
- data/spec/resources/billing_request_template_spec.rb +502 -0
- data/spec/resources/block_spec.rb +560 -0
- data/spec/resources/institution_spec.rb +108 -0
- data/spec/resources/payer_authorisation_spec.rb +418 -0
- data/spec/resources/redirect_flow_spec.rb +9 -0
- data/spec/resources/scenario_simulator_spec.rb +63 -0
- data/spec/resources/webhook_spec.rb +323 -0
- data/spec/services/bank_authorisations_service_spec.rb +353 -0
- data/spec/services/billing_request_flows_service_spec.rb +253 -0
- data/spec/services/billing_request_templates_service_spec.rb +789 -0
- data/spec/services/billing_requests_service_spec.rb +1082 -0
- data/spec/services/blocks_service_spec.rb +823 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +0 -13
- data/spec/services/creditors_service_spec.rb +0 -13
- data/spec/services/customer_bank_accounts_service_spec.rb +0 -13
- data/spec/services/customers_service_spec.rb +0 -13
- data/spec/services/instalment_schedules_service_spec.rb +0 -26
- data/spec/services/institutions_service_spec.rb +232 -0
- data/spec/services/mandate_imports_service_spec.rb +0 -13
- data/spec/services/mandates_service_spec.rb +0 -13
- data/spec/services/payer_authorisations_service_spec.rb +559 -0
- data/spec/services/payments_service_spec.rb +0 -13
- data/spec/services/redirect_flows_service_spec.rb +9 -13
- data/spec/services/refunds_service_spec.rb +0 -13
- data/spec/services/scenario_simulators_service_spec.rb +74 -0
- data/spec/services/subscriptions_service_spec.rb +0 -13
- data/spec/services/webhooks_service_spec.rb +545 -0
- metadata +64 -7
@@ -52,8 +52,6 @@ module GoCardlessPro
|
|
52
52
|
raise IdempotencyConflict, e.error
|
53
53
|
when :fetch
|
54
54
|
return get(e.conflicting_resource_id)
|
55
|
-
else
|
56
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
@@ -102,8 +100,6 @@ module GoCardlessPro
|
|
102
100
|
raise IdempotencyConflict, e.error
|
103
101
|
when :fetch
|
104
102
|
return get(e.conflicting_resource_id)
|
105
|
-
else
|
106
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
107
103
|
end
|
108
104
|
end
|
109
105
|
|
@@ -133,7 +129,7 @@ module GoCardlessPro
|
|
133
129
|
)
|
134
130
|
end
|
135
131
|
|
136
|
-
# Get a lazily enumerated list of all the items returned. This is
|
132
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
137
133
|
#
|
138
134
|
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
139
135
|
# Otherwise they will be the body of the request.
|
@@ -212,8 +208,6 @@ module GoCardlessPro
|
|
212
208
|
raise IdempotencyConflict, e.error
|
213
209
|
when :fetch
|
214
210
|
return get(e.conflicting_resource_id)
|
215
|
-
else
|
216
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
217
211
|
end
|
218
212
|
end
|
219
213
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative './base_service'
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# This client is automatically generated from a template and JSON schema definition.
|
6
|
+
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
|
7
|
+
#
|
8
|
+
|
9
|
+
module GoCardlessPro
|
10
|
+
module Services
|
11
|
+
# Service for making requests to the Institution endpoints
|
12
|
+
class InstitutionsService < BaseService
|
13
|
+
# Returns a list of all supported institutions.
|
14
|
+
# Example URL: /institutions
|
15
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
16
|
+
def list(options = {})
|
17
|
+
path = '/institutions'
|
18
|
+
|
19
|
+
options[:retry_failures] = true
|
20
|
+
|
21
|
+
response = make_request(:get, path, options)
|
22
|
+
|
23
|
+
ListResponse.new(
|
24
|
+
response: response,
|
25
|
+
unenveloped_body: unenvelope_body(response.body),
|
26
|
+
resource_class: Resources::Institution
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
31
|
+
#
|
32
|
+
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
33
|
+
# Otherwise they will be the body of the request.
|
34
|
+
def all(options = {})
|
35
|
+
Paginator.new(
|
36
|
+
service: self,
|
37
|
+
options: options
|
38
|
+
).enumerator
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# Unenvelope the response of the body using the service's `envelope_key`
|
44
|
+
#
|
45
|
+
# @param body [Hash]
|
46
|
+
def unenvelope_body(body)
|
47
|
+
body[envelope_key] || body['data']
|
48
|
+
end
|
49
|
+
|
50
|
+
# return the key which API responses will envelope data under
|
51
|
+
def envelope_key
|
52
|
+
'institutions'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -60,7 +60,7 @@ module GoCardlessPro
|
|
60
60
|
)
|
61
61
|
end
|
62
62
|
|
63
|
-
# Get a lazily enumerated list of all the items returned. This is
|
63
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
64
64
|
#
|
65
65
|
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
66
66
|
# Otherwise they will be the body of the request.
|
@@ -38,8 +38,6 @@ module GoCardlessPro
|
|
38
38
|
raise IdempotencyConflict, e.error
|
39
39
|
when :fetch
|
40
40
|
return get(e.conflicting_resource_id)
|
41
|
-
else
|
42
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -104,8 +102,6 @@ module GoCardlessPro
|
|
104
102
|
raise IdempotencyConflict, e.error
|
105
103
|
when :fetch
|
106
104
|
return get(e.conflicting_resource_id)
|
107
|
-
else
|
108
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
109
105
|
end
|
110
106
|
end
|
111
107
|
|
@@ -149,8 +145,6 @@ module GoCardlessPro
|
|
149
145
|
raise IdempotencyConflict, e.error
|
150
146
|
when :fetch
|
151
147
|
return get(e.conflicting_resource_id)
|
152
|
-
else
|
153
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
154
148
|
end
|
155
149
|
end
|
156
150
|
|
@@ -34,8 +34,6 @@ module GoCardlessPro
|
|
34
34
|
raise IdempotencyConflict, e.error
|
35
35
|
when :fetch
|
36
36
|
return get(e.conflicting_resource_id)
|
37
|
-
else
|
38
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
@@ -65,7 +63,7 @@ module GoCardlessPro
|
|
65
63
|
)
|
66
64
|
end
|
67
65
|
|
68
|
-
# Get a lazily enumerated list of all the items returned. This is
|
66
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
69
67
|
#
|
70
68
|
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
71
69
|
# Otherwise they will be the body of the request.
|
@@ -148,8 +146,6 @@ module GoCardlessPro
|
|
148
146
|
raise IdempotencyConflict, e.error
|
149
147
|
when :fetch
|
150
148
|
return get(e.conflicting_resource_id)
|
151
|
-
else
|
152
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
153
149
|
end
|
154
150
|
end
|
155
151
|
|
@@ -198,8 +194,6 @@ module GoCardlessPro
|
|
198
194
|
raise IdempotencyConflict, e.error
|
199
195
|
when :fetch
|
200
196
|
return get(e.conflicting_resource_id)
|
201
|
-
else
|
202
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
203
197
|
end
|
204
198
|
end
|
205
199
|
|
@@ -0,0 +1,202 @@
|
|
1
|
+
require_relative './base_service'
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# This client is automatically generated from a template and JSON schema definition.
|
6
|
+
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
|
7
|
+
#
|
8
|
+
|
9
|
+
module GoCardlessPro
|
10
|
+
module Services
|
11
|
+
# Service for making requests to the PayerAuthorisation endpoints
|
12
|
+
class PayerAuthorisationsService < BaseService
|
13
|
+
# Retrieves the details of a single existing Payer Authorisation. It can be used
|
14
|
+
# for polling the status of a Payer Authorisation.
|
15
|
+
# Example URL: /payer_authorisations/:identity
|
16
|
+
#
|
17
|
+
# @param identity # Unique identifier, beginning with "PA".
|
18
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
19
|
+
def get(identity, options = {})
|
20
|
+
path = sub_url('/payer_authorisations/:identity', 'identity' => identity)
|
21
|
+
|
22
|
+
options[:retry_failures] = true
|
23
|
+
|
24
|
+
response = make_request(:get, path, options)
|
25
|
+
|
26
|
+
return if response.body.nil?
|
27
|
+
|
28
|
+
Resources::PayerAuthorisation.new(unenvelope_body(response.body), response)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Creates a Payer Authorisation. The resource is saved to the database even if
|
32
|
+
# incomplete. An empty array of incomplete_fields means that the resource is
|
33
|
+
# valid. The ID of the resource is used for the other actions. This endpoint has
|
34
|
+
# been designed this way so you do not need to save any payer data on your
|
35
|
+
# servers or the browser while still being able to implement a progressive
|
36
|
+
# solution, such as a multi-step form.
|
37
|
+
# Example URL: /payer_authorisations
|
38
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
39
|
+
def create(options = {})
|
40
|
+
path = '/payer_authorisations'
|
41
|
+
|
42
|
+
params = options.delete(:params) || {}
|
43
|
+
options[:params] = {}
|
44
|
+
options[:params][envelope_key] = params
|
45
|
+
|
46
|
+
options[:retry_failures] = true
|
47
|
+
|
48
|
+
begin
|
49
|
+
response = make_request(:post, path, options)
|
50
|
+
|
51
|
+
# Response doesn't raise any errors until #body is called
|
52
|
+
response.tap(&:body)
|
53
|
+
rescue InvalidStateError => e
|
54
|
+
if e.idempotent_creation_conflict?
|
55
|
+
case @api_service.on_idempotency_conflict
|
56
|
+
when :raise
|
57
|
+
raise IdempotencyConflict, e.error
|
58
|
+
when :fetch
|
59
|
+
return get(e.conflicting_resource_id)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
raise e
|
64
|
+
end
|
65
|
+
|
66
|
+
return if response.body.nil?
|
67
|
+
|
68
|
+
Resources::PayerAuthorisation.new(unenvelope_body(response.body), response)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Updates a Payer Authorisation. Updates the Payer Authorisation with the
|
72
|
+
# request data. Can be invoked as many times as needed. Only fields present in
|
73
|
+
# the request will be modified. An empty array of incomplete_fields means that
|
74
|
+
# the resource is valid. This endpoint has been designed this way so you do not
|
75
|
+
# need to save any payer data on your servers or the browser while still being
|
76
|
+
# able to implement a progressive solution, such a multi-step form. <p
|
77
|
+
# class="notice"> Note that in order to update the `metadata` attribute values
|
78
|
+
# it must be sent completely as it overrides the previously existing values.
|
79
|
+
# </p>
|
80
|
+
# Example URL: /payer_authorisations/:identity
|
81
|
+
#
|
82
|
+
# @param identity # Unique identifier, beginning with "PA".
|
83
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
84
|
+
def update(identity, options = {})
|
85
|
+
path = sub_url('/payer_authorisations/:identity', 'identity' => identity)
|
86
|
+
|
87
|
+
params = options.delete(:params) || {}
|
88
|
+
options[:params] = {}
|
89
|
+
options[:params][envelope_key] = params
|
90
|
+
|
91
|
+
options[:retry_failures] = true
|
92
|
+
|
93
|
+
response = make_request(:put, path, options)
|
94
|
+
|
95
|
+
return if response.body.nil?
|
96
|
+
|
97
|
+
Resources::PayerAuthorisation.new(unenvelope_body(response.body), response)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Submits all the data previously pushed to this PayerAuthorisation for
|
101
|
+
# verification. This time, a 200 HTTP status is returned if the resource is
|
102
|
+
# valid and a 422 error response in case of validation errors. After it is
|
103
|
+
# successfully submitted, the Payer Authorisation can no longer be edited.
|
104
|
+
# Example URL: /payer_authorisations/:identity/actions/submit
|
105
|
+
#
|
106
|
+
# @param identity # Unique identifier, beginning with "PA".
|
107
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
108
|
+
def submit(identity, options = {})
|
109
|
+
path = sub_url('/payer_authorisations/:identity/actions/submit', 'identity' => identity)
|
110
|
+
|
111
|
+
params = options.delete(:params) || {}
|
112
|
+
options[:params] = {}
|
113
|
+
options[:params]['data'] = params
|
114
|
+
|
115
|
+
options[:retry_failures] = false
|
116
|
+
|
117
|
+
begin
|
118
|
+
response = make_request(:post, path, options)
|
119
|
+
|
120
|
+
# Response doesn't raise any errors until #body is called
|
121
|
+
response.tap(&:body)
|
122
|
+
rescue InvalidStateError => e
|
123
|
+
if e.idempotent_creation_conflict?
|
124
|
+
case @api_service.on_idempotency_conflict
|
125
|
+
when :raise
|
126
|
+
raise IdempotencyConflict, e.error
|
127
|
+
when :fetch
|
128
|
+
return get(e.conflicting_resource_id)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
raise e
|
133
|
+
end
|
134
|
+
|
135
|
+
return if response.body.nil?
|
136
|
+
|
137
|
+
Resources::PayerAuthorisation.new(unenvelope_body(response.body), response)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Confirms the Payer Authorisation, indicating that the resources are ready to
|
141
|
+
# be created.
|
142
|
+
# A Payer Authorisation cannot be confirmed if it hasn't been submitted yet.
|
143
|
+
#
|
144
|
+
# <p class="notice">
|
145
|
+
# The main use of the confirm endpoint is to enable integrators to acknowledge
|
146
|
+
# the end of the setup process.
|
147
|
+
# They might want to make the payers go through some other steps after they go
|
148
|
+
# through our flow or make them go through the necessary verification mechanism
|
149
|
+
# (upcoming feature).
|
150
|
+
# </p>
|
151
|
+
# Example URL: /payer_authorisations/:identity/actions/confirm
|
152
|
+
#
|
153
|
+
# @param identity # Unique identifier, beginning with "PA".
|
154
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
155
|
+
def confirm(identity, options = {})
|
156
|
+
path = sub_url('/payer_authorisations/:identity/actions/confirm', 'identity' => identity)
|
157
|
+
|
158
|
+
params = options.delete(:params) || {}
|
159
|
+
options[:params] = {}
|
160
|
+
options[:params]['data'] = params
|
161
|
+
|
162
|
+
options[:retry_failures] = false
|
163
|
+
|
164
|
+
begin
|
165
|
+
response = make_request(:post, path, options)
|
166
|
+
|
167
|
+
# Response doesn't raise any errors until #body is called
|
168
|
+
response.tap(&:body)
|
169
|
+
rescue InvalidStateError => e
|
170
|
+
if e.idempotent_creation_conflict?
|
171
|
+
case @api_service.on_idempotency_conflict
|
172
|
+
when :raise
|
173
|
+
raise IdempotencyConflict, e.error
|
174
|
+
when :fetch
|
175
|
+
return get(e.conflicting_resource_id)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
raise e
|
180
|
+
end
|
181
|
+
|
182
|
+
return if response.body.nil?
|
183
|
+
|
184
|
+
Resources::PayerAuthorisation.new(unenvelope_body(response.body), response)
|
185
|
+
end
|
186
|
+
|
187
|
+
private
|
188
|
+
|
189
|
+
# Unenvelope the response of the body using the service's `envelope_key`
|
190
|
+
#
|
191
|
+
# @param body [Hash]
|
192
|
+
def unenvelope_body(body)
|
193
|
+
body[envelope_key] || body['data']
|
194
|
+
end
|
195
|
+
|
196
|
+
# return the key which API responses will envelope data under
|
197
|
+
def envelope_key
|
198
|
+
'payer_authorisations'
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -39,8 +39,6 @@ module GoCardlessPro
|
|
39
39
|
raise IdempotencyConflict, e.error
|
40
40
|
when :fetch
|
41
41
|
return get(e.conflicting_resource_id)
|
42
|
-
else
|
43
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -70,7 +68,7 @@ module GoCardlessPro
|
|
70
68
|
)
|
71
69
|
end
|
72
70
|
|
73
|
-
# Get a lazily enumerated list of all the items returned. This is
|
71
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
74
72
|
#
|
75
73
|
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
76
74
|
# Otherwise they will be the body of the request.
|
@@ -150,8 +148,6 @@ module GoCardlessPro
|
|
150
148
|
raise IdempotencyConflict, e.error
|
151
149
|
when :fetch
|
152
150
|
return get(e.conflicting_resource_id)
|
153
|
-
else
|
154
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
155
151
|
end
|
156
152
|
end
|
157
153
|
|
@@ -198,8 +194,6 @@ module GoCardlessPro
|
|
198
194
|
raise IdempotencyConflict, e.error
|
199
195
|
when :fetch
|
200
196
|
return get(e.conflicting_resource_id)
|
201
|
-
else
|
202
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
203
197
|
end
|
204
198
|
end
|
205
199
|
|
@@ -29,7 +29,7 @@ module GoCardlessPro
|
|
29
29
|
)
|
30
30
|
end
|
31
31
|
|
32
|
-
# Get a lazily enumerated list of all the items returned. This is
|
32
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
33
33
|
#
|
34
34
|
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
35
35
|
# Otherwise they will be the body of the request.
|
@@ -28,7 +28,7 @@ module GoCardlessPro
|
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
|
-
# Get a lazily enumerated list of all the items returned. This is
|
31
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
32
32
|
#
|
33
33
|
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
34
34
|
# Otherwise they will be the body of the request.
|
@@ -35,8 +35,6 @@ module GoCardlessPro
|
|
35
35
|
raise IdempotencyConflict, e.error
|
36
36
|
when :fetch
|
37
37
|
return get(e.conflicting_resource_id)
|
38
|
-
else
|
39
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
@@ -100,8 +98,6 @@ module GoCardlessPro
|
|
100
98
|
raise IdempotencyConflict, e.error
|
101
99
|
when :fetch
|
102
100
|
return get(e.conflicting_resource_id)
|
103
|
-
else
|
104
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
105
101
|
end
|
106
102
|
end
|
107
103
|
|
@@ -50,8 +50,6 @@ module GoCardlessPro
|
|
50
50
|
raise IdempotencyConflict, e.error
|
51
51
|
when :fetch
|
52
52
|
return get(e.conflicting_resource_id)
|
53
|
-
else
|
54
|
-
raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
@@ -81,7 +79,7 @@ module GoCardlessPro
|
|
81
79
|
)
|
82
80
|
end
|
83
81
|
|
84
|
-
# Get a lazily enumerated list of all the items returned. This is
|
82
|
+
# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
|
85
83
|
#
|
86
84
|
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
87
85
|
# Otherwise they will be the body of the request.
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require_relative './base_service'
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# This client is automatically generated from a template and JSON schema definition.
|
6
|
+
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
|
7
|
+
#
|
8
|
+
|
9
|
+
module GoCardlessPro
|
10
|
+
module Services
|
11
|
+
# Service for making requests to the ScenarioSimulator endpoints
|
12
|
+
class ScenarioSimulatorsService < BaseService
|
13
|
+
# Runs the specific scenario simulator against the specific resource
|
14
|
+
# Example URL: /scenario_simulators/:identity/actions/run
|
15
|
+
#
|
16
|
+
# @param identity # The unique identifier of the simulator, used to initiate simulations.
|
17
|
+
# One of:
|
18
|
+
# <ul>
|
19
|
+
# <li>`creditor_verification_status_action_required`: Sets a creditor's
|
20
|
+
# `verification status` to `action required`, meaning that the creditor
|
21
|
+
# must provide further information to GoCardless in order to verify their
|
22
|
+
# account to receive payouts.</li>
|
23
|
+
# <li>`creditor_verification_status_in_review`: Sets a creditor's
|
24
|
+
# `verification status` to `in review`, meaning that the creditor has
|
25
|
+
# provided all of the information requested by GoCardless to verify their
|
26
|
+
# account, and is now awaiting review.</li>
|
27
|
+
# <li>`creditor_verification_status_successful`: Sets a creditor's
|
28
|
+
# `verification status` to `successful`, meaning that the creditor is
|
29
|
+
# fully verified and can receive payouts.</li>
|
30
|
+
# <li>`payment_confirmed`: Transitions a payment through to `confirmed`.
|
31
|
+
# It must start in the `pending_submission` state, and its mandate must be
|
32
|
+
# in the `activated` state (unless it is a payment for ACH, BECS, BECS_NZ
|
33
|
+
# or SEPA, in which cases the mandate may be `pending_submission`, since
|
34
|
+
# their mandates are submitted with their first payment).</li>
|
35
|
+
# <li>`payment_paid_out`: Transitions a payment through to `paid_out`,
|
36
|
+
# having been collected successfully and paid out to you. It must start in
|
37
|
+
# the `pending_submission` state, and its mandate must be in the
|
38
|
+
# `activated` state (unless it is a payment for ACH, BECS, BECS_NZ or
|
39
|
+
# SEPA, in which cases the mandate may be `pending_submission`, since
|
40
|
+
# their mandates are submitted with their first payment).</li>
|
41
|
+
# <li>`payment_failed`: Transitions a payment through to `failed`. It must
|
42
|
+
# start in the `pending_submission` state, and its mandate must be in the
|
43
|
+
# `activated` state (unless it is a payment for ACH, BECS, BECS_NZ or
|
44
|
+
# SEPA, in which cases the mandate may be `pending_submission`, since
|
45
|
+
# their mandates are submitted with their first payment).</li>
|
46
|
+
# <li>`payment_charged_back`: Behaves the same as the `payout_paid_out`
|
47
|
+
# simulator, except that the payment is transitioned to `charged_back`
|
48
|
+
# after it is paid out, having been charged back by the customer.</li>
|
49
|
+
# <li>`payment_chargeback_settled`: Behaves the same as the
|
50
|
+
# `payment_charged_back` simulator, except that the charged back payment
|
51
|
+
# is additionally included as a debit item in a payout, thereby settling
|
52
|
+
# the charged back payment.</li>
|
53
|
+
# <li>`payment_late_failure`: Transitions a payment through to
|
54
|
+
# `late_failure`, having been apparently collected successfully
|
55
|
+
# beforehand. It must start in the `pending_submission` state, and its
|
56
|
+
# mandate must be in the `activated` state (unless it is a payment for
|
57
|
+
# ACH, BECS, BECS_NZ or SEPA, in which cases the mandate may be
|
58
|
+
# `pending_submission`, since their mandates are submitted with their
|
59
|
+
# first payment). Not compatible with Autogiro mandates.</li>
|
60
|
+
# <li>`payment_late_failure_settled`: Behaves the same as the
|
61
|
+
# `payment_late_failure` simulator, except that the late failure is
|
62
|
+
# additionally included as a debit item in a payout, thereby settling the
|
63
|
+
# late failure.</li>
|
64
|
+
# <li>`payment_submitted`: Transitions a payment to `submitted`, without
|
65
|
+
# proceeding any further. It must start in the `pending_submission`
|
66
|
+
# state.</li>
|
67
|
+
# <li>`mandate_activated`: Transitions a mandate through to `activated`,
|
68
|
+
# having been submitted to the banks and set up successfully. It must
|
69
|
+
# start in the `pending_submission` state. Not compatible with ACH, BECS,
|
70
|
+
# BECS_NZ and SEPA mandates, which are submitted and activated with their
|
71
|
+
# first payment.</li>
|
72
|
+
# <li>`mandate_customer_approval_granted`: Transitions a mandate through
|
73
|
+
# to `pending_submission`, as if the customer approved the mandate
|
74
|
+
# creation. It must start in the `pending_customer_approval` state.
|
75
|
+
# Compatible only with Bacs and SEPA mandates, which support customer
|
76
|
+
# signatures on the mandate. All payments associated with the mandate will
|
77
|
+
# be transitioned to `pending_submission`. All subscriptions associated
|
78
|
+
# with the mandate will become `active`.</li>
|
79
|
+
# <li>`mandate_customer_approval_skipped`: Transitions a mandate through
|
80
|
+
# to `pending_submission`, as if the customer skipped the mandate approval
|
81
|
+
# during the mandate creation process. It must start in the
|
82
|
+
# `pending_customer_approval` state. Compatible only with Bacs and SEPA
|
83
|
+
# mandates, which support customer signatures on the mandate. All payments
|
84
|
+
# associated with the mandate will be transitioned to
|
85
|
+
# `pending_submission`. All subscriptions associated with the mandate will
|
86
|
+
# become `active`.</li>
|
87
|
+
# <li>`mandate_failed`: Transitions a mandate through to `failed`, having
|
88
|
+
# been submitted to the banks but found to be invalid (for example due to
|
89
|
+
# invalid bank details). It must start in the `pending_submission` or
|
90
|
+
# `submitted` states. Not compatible with SEPA mandates, which are
|
91
|
+
# submitted with their first payment.</li>
|
92
|
+
# <li>`mandate_expired`: Transitions a mandate through to `expired`,
|
93
|
+
# having been submitted to the banks, set up successfully and then expired
|
94
|
+
# because no collection attempts were made against it for longer than the
|
95
|
+
# scheme's dormancy period (13 months for Bacs, 3 years for SEPA, 15
|
96
|
+
# months for ACH, Betalingsservice, and BECS). It must start in the
|
97
|
+
# `pending_submission` state. Not compatible with Autogiro, BECS NZ, and
|
98
|
+
# PAD mandates, which do not expire.</li>
|
99
|
+
# <li>`mandate_transferred`: Transitions a mandate through to
|
100
|
+
# `transferred`, having been submitted to the banks, set up successfully
|
101
|
+
# and then moved to a new bank account due to the customer using the UK's
|
102
|
+
# Current Account Switching Service (CASS). It must start in the
|
103
|
+
# `pending_submission` state. Only compatible with Bacs mandates.</li>
|
104
|
+
# <li>`mandate_transferred_with_resubmission`: Transitions a mandate
|
105
|
+
# through `transferred` and resubmits it to the banks, can be caused be
|
106
|
+
# the UK's Current Account Switching Service (CASS) or when a customer
|
107
|
+
# contacts GoCardless to change their bank details. It must start in the
|
108
|
+
# `pending_submission` state. Only compatible with Bacs, SEPA and Autogiro
|
109
|
+
# mandates.</li>
|
110
|
+
# <li>`refund_paid`: Transitions a refund to `paid`. It must start in
|
111
|
+
# either the `pending_submission` or `submitted` state.</li>
|
112
|
+
# <li>`refund_settled`: Transitions a refund to `paid`, if it's not
|
113
|
+
# already, then generates a payout that includes the refund, thereby
|
114
|
+
# settling the funds. It must start in one of `pending_submission`,
|
115
|
+
# `submitted` or `paid` states.</li>
|
116
|
+
# <li>`refund_bounced`: Transitions a refund to `bounced`. It must start
|
117
|
+
# in either the `pending_submission`, `submitted`, or `paid` state.</li>
|
118
|
+
# <li>`refund_returned`: Transitions a refund to `refund_returned`. The
|
119
|
+
# refund must start in `pending_submission`.</li>
|
120
|
+
# <li>`payout_bounced`: Transitions a payout to `bounced`. It must start
|
121
|
+
# in the `paid` state.</li>
|
122
|
+
# <li>`billing_request_fulfilled`: Authorises the billing request, fulfils
|
123
|
+
# it, and moves the associated payment to `failed`. The billing request
|
124
|
+
# must be in the `pending` state, with all actions completed except for
|
125
|
+
# `bank_authorisation`. Only billing requests with a `payment_request` are
|
126
|
+
# supported.</li>
|
127
|
+
# <li>`billing_request_fulfilled_and_payment_failed`: Authorises the
|
128
|
+
# billing request, fulfils it, and moves the associated payment to
|
129
|
+
# `failed`. The billing request must be in the `pending` state, with all
|
130
|
+
# actions completed except for `bank_authorisation`. Only billing requests
|
131
|
+
# with a `payment_request` are supported.</li>
|
132
|
+
# <li>`billing_request_fulfilled_and_payment_paid_out`: Authorises the
|
133
|
+
# billing request, fulfils it, and moves the associated payment to
|
134
|
+
# `paid_out`. The billing request must be in the `pending` state, with all
|
135
|
+
# actions completed except for `bank_authorisation`. Only billing requests
|
136
|
+
# with a `payment_request` are supported.</li>
|
137
|
+
# </ul>
|
138
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
139
|
+
def run(identity, options = {})
|
140
|
+
path = sub_url('/scenario_simulators/:identity/actions/run', 'identity' => identity)
|
141
|
+
|
142
|
+
params = options.delete(:params) || {}
|
143
|
+
options[:params] = {}
|
144
|
+
options[:params]['data'] = params
|
145
|
+
|
146
|
+
options[:retry_failures] = false
|
147
|
+
|
148
|
+
response = make_request(:post, path, options)
|
149
|
+
|
150
|
+
return if response.body.nil?
|
151
|
+
|
152
|
+
Resources::ScenarioSimulator.new(unenvelope_body(response.body), response)
|
153
|
+
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
# Unenvelope the response of the body using the service's `envelope_key`
|
158
|
+
#
|
159
|
+
# @param body [Hash]
|
160
|
+
def unenvelope_body(body)
|
161
|
+
body[envelope_key] || body['data']
|
162
|
+
end
|
163
|
+
|
164
|
+
# return the key which API responses will envelope data under
|
165
|
+
def envelope_key
|
166
|
+
'scenario_simulators'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|