gocardless_pro 3.4.0 → 3.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 472fa55ccac2de3bebc711783644d3f39312330c885b4fbf02a466a039009dc2
4
- data.tar.gz: 2fcabb2995c68ef9919c1e6b0a1c98b8d7b3b327dfe8f2b024d99aac00b79f42
3
+ metadata.gz: dc192d2230d8b35d8e0d5d7aecbfce3fc0fcd3516d973b3cef282771e8c16026
4
+ data.tar.gz: 7db1089cd74597a29b745f2b1275d4fef842317e2672b7fe0ebe3bdf4ae91f1d
5
5
  SHA512:
6
- metadata.gz: 6c9bb7e031e4fb33eeca2fab1fb6383f4cbb00bb64cac562b5a8b084d1f20ac5ce64d26e71662e2809e21d0b6929dad942963d3418fcb8787ea9a6e44134d3d1
7
- data.tar.gz: 6eedaf33f297a6d4560481d1c81f10017cf3894b4b6df483c6945d36cffcd2a6a73590855a0882938d9955893e42456c69134a79d9eb4f8c91d1480831e8c893
6
+ metadata.gz: 48cc431b2261bd308a6675d01127dcd11d57c3699872098da4eba888921e09c372b1e157565bd91416dc53f8c0a6d60587e7c183499f71c90caaef395c134b22
7
+ data.tar.gz: 2d8d59d8c86123537449a90a0a9fb927cbcba5f3b79afb9cd4111be21688a7a9f64aef4acc5e1f45dca34184d114d343389e2bc878a77c98ee7c115cf50339fc
@@ -8,6 +8,11 @@ module GoCardlessPro
8
8
  @balances ||= Services::BalancesService.new(@api_service)
9
9
  end
10
10
 
11
+ # Access to the service for bank_account_detail to make API calls
12
+ def bank_account_details
13
+ @bank_account_details ||= Services::BankAccountDetailsService.new(@api_service)
14
+ end
15
+
11
16
  # Access to the service for bank_authorisation to make API calls
12
17
  def bank_authorisations
13
18
  @bank_authorisations ||= Services::BankAuthorisationsService.new(@api_service)
@@ -118,6 +123,11 @@ module GoCardlessPro
118
123
  @negative_balance_limits ||= Services::NegativeBalanceLimitsService.new(@api_service)
119
124
  end
120
125
 
126
+ # Access to the service for outbound_payment to make API calls
127
+ def outbound_payments
128
+ @outbound_payments ||= Services::OutboundPaymentsService.new(@api_service)
129
+ end
130
+
121
131
  # Access to the service for payer_authorisation to make API calls
122
132
  def payer_authorisations
123
133
  @payer_authorisations ||= Services::PayerAuthorisationsService.new(@api_service)
@@ -238,7 +248,7 @@ module GoCardlessPro
238
248
  'User-Agent' => "#{user_agent}",
239
249
  'Content-Type' => 'application/json',
240
250
  'GoCardless-Client-Library' => 'gocardless-pro-ruby',
241
- 'GoCardless-Client-Version' => '3.4.0'
251
+ 'GoCardless-Client-Version' => '3.6.0'
242
252
  }
243
253
  }
244
254
  end
@@ -0,0 +1,40 @@
1
+ #
2
+ # This client is automatically generated from a template and JSON schema definition.
3
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
4
+ #
5
+
6
+ require 'uri'
7
+
8
+ module GoCardlessPro
9
+ # A module containing classes for each of the resources in the GC Api
10
+ module Resources
11
+ # Represents an instance of a bank_account_detail resource returned from the API
12
+
13
+ # Retrieve bank account details in JWE encrypted format
14
+ class BankAccountDetail
15
+ attr_reader :ciphertext, :encrypted_key, :iv, :protected, :tag
16
+
17
+ # Initialize a bank_account_detail resource instance
18
+ # @param object [Hash] an object returned from the API
19
+ def initialize(object, response = nil)
20
+ @object = object
21
+
22
+ @ciphertext = object['ciphertext']
23
+ @encrypted_key = object['encrypted_key']
24
+ @iv = object['iv']
25
+ @protected = object['protected']
26
+ @tag = object['tag']
27
+ @response = response
28
+ end
29
+
30
+ def api_response
31
+ ApiResponse.new(@response)
32
+ end
33
+
34
+ # Provides the bank_account_detail resource as a hash of all its readable attributes
35
+ def to_h
36
+ @object
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,82 @@
1
+ #
2
+ # This client is automatically generated from a template and JSON schema definition.
3
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
4
+ #
5
+
6
+ require 'uri'
7
+
8
+ module GoCardlessPro
9
+ # A module containing classes for each of the resources in the GC Api
10
+ module Resources
11
+ # Represents an instance of a outbound_payment resource returned from the API
12
+
13
+ # Outbound Payments represent payments sent from
14
+ # [creditors](#core-endpoints-creditors).
15
+ #
16
+ # GoCardless will notify you via a [webhook](#appendix-webhooks) when the
17
+ # status of the outbound payment [changes](#event-actions-outbound-payment).
18
+ #
19
+ # <p class="restricted-notice"><strong>Restricted</strong>: Outbound
20
+ # Payments are currently in Early Access and available only to a limited
21
+ # list of organisations. If you are interested in using this feature, please
22
+ # stay tuned for our public launch announcement. We are actively testing and
23
+ # refining our API to ensure it meets your needs and provides the best
24
+ # experience.</p>
25
+ class OutboundPayment
26
+ attr_reader :amount, :created_at, :description, :execution_date, :id, :is_withdrawal, :metadata, :reference,
27
+ :scheme, :status, :verifications
28
+
29
+ # Initialize a outbound_payment resource instance
30
+ # @param object [Hash] an object returned from the API
31
+ def initialize(object, response = nil)
32
+ @object = object
33
+
34
+ @amount = object['amount']
35
+ @created_at = object['created_at']
36
+ @description = object['description']
37
+ @execution_date = object['execution_date']
38
+ @id = object['id']
39
+ @is_withdrawal = object['is_withdrawal']
40
+ @links = object['links']
41
+ @metadata = object['metadata']
42
+ @reference = object['reference']
43
+ @scheme = object['scheme']
44
+ @status = object['status']
45
+ @verifications = object['verifications']
46
+ @response = response
47
+ end
48
+
49
+ def api_response
50
+ ApiResponse.new(@response)
51
+ end
52
+
53
+ # Return the links that the resource has
54
+ def links
55
+ @outbound_payment_links ||= Links.new(@links)
56
+ end
57
+
58
+ # Provides the outbound_payment resource as a hash of all its readable attributes
59
+ def to_h
60
+ @object
61
+ end
62
+
63
+ class Links
64
+ def initialize(links)
65
+ @links = links || {}
66
+ end
67
+
68
+ def creditor
69
+ @links['creditor']
70
+ end
71
+
72
+ def customer
73
+ @links['customer']
74
+ end
75
+
76
+ def recipient_bank_account
77
+ @links['recipient_bank_account']
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,48 @@
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 BankAccountDetail endpoints
12
+ class BankAccountDetailsService < BaseService
13
+ # Returns bank account details in the flattened JSON Web Encryption format
14
+ # described in RFC 7516
15
+ # Example URL: /bank_account_details/:identity
16
+ #
17
+ # @param identity # Unique identifier, beginning with "BA".
18
+ # @param options [Hash] parameters as a hash, under a params key.
19
+ def get(identity, options = {})
20
+ path = sub_url('/bank_account_details/:identity', {
21
+ 'identity' => identity
22
+ })
23
+
24
+ options[:retry_failures] = true
25
+
26
+ response = make_request(:get, path, options)
27
+
28
+ return if response.body.nil?
29
+
30
+ Resources::BankAccountDetail.new(unenvelope_body(response.body), response)
31
+ end
32
+
33
+ private
34
+
35
+ # Unenvelope the response of the body using the service's `envelope_key`
36
+ #
37
+ # @param body [Hash]
38
+ def unenvelope_body(body)
39
+ body[envelope_key] || body['data']
40
+ end
41
+
42
+ # return the key which API responses will envelope data under
43
+ def envelope_key
44
+ 'bank_account_details'
45
+ end
46
+ end
47
+ end
48
+ end
@@ -11,7 +11,8 @@ module GoCardlessPro
11
11
  # Service for making requests to the BillingRequest endpoints
12
12
  class BillingRequestsService < BaseService
13
13
  # <p class="notice"><strong>Important</strong>: All properties associated with
14
- # `subscription_request` are only supported for ACH and PAD schemes.</p>
14
+ # `subscription_request` and `instalment_schedule_request` are only supported
15
+ # for ACH and PAD schemes.</p>
15
16
  # Example URL: /billing_requests
16
17
  # @param options [Hash] parameters as a hash, under a params key.
17
18
  def create(options = {})
@@ -46,78 +47,6 @@ module GoCardlessPro
46
47
  Resources::BillingRequest.new(unenvelope_body(response.body), response)
47
48
  end
48
49
 
49
- # <p class="notice"><strong>Important</strong>: All properties associated with
50
- # `instalment_schedule_request` are only supported for ACH and PAD schemes.</p>
51
- # Example URL: /billing_requests
52
- # @param options [Hash] parameters as a hash, under a params key.
53
- def create_with_instalments_with_dates(options = {})
54
- path = '/billing_requests'
55
-
56
- params = options.delete(:params) || {}
57
- options[:params] = {}
58
- options[:params][envelope_key] = params
59
-
60
- options[:retry_failures] = true
61
-
62
- begin
63
- response = make_request(:post, path, options)
64
-
65
- # Response doesn't raise any errors until #body is called
66
- response.tap(&:body)
67
- rescue InvalidStateError => e
68
- if e.idempotent_creation_conflict?
69
- case @api_service.on_idempotency_conflict
70
- when :raise
71
- raise IdempotencyConflict, e.error
72
- when :fetch
73
- return get(e.conflicting_resource_id)
74
- end
75
- end
76
-
77
- raise e
78
- end
79
-
80
- return if response.body.nil?
81
-
82
- Resources::BillingRequest.new(unenvelope_body(response.body), response)
83
- end
84
-
85
- # <p class="notice"><strong>Important</strong>: All properties associated with
86
- # `instalment_schedule_request` are only supported for ACH and PAD schemes.</p>
87
- # Example URL: /billing_requests
88
- # @param options [Hash] parameters as a hash, under a params key.
89
- def create_with_instalments_with_schedule(options = {})
90
- path = '/billing_requests'
91
-
92
- params = options.delete(:params) || {}
93
- options[:params] = {}
94
- options[:params][envelope_key] = params
95
-
96
- options[:retry_failures] = true
97
-
98
- begin
99
- response = make_request(:post, path, options)
100
-
101
- # Response doesn't raise any errors until #body is called
102
- response.tap(&:body)
103
- rescue InvalidStateError => e
104
- if e.idempotent_creation_conflict?
105
- case @api_service.on_idempotency_conflict
106
- when :raise
107
- raise IdempotencyConflict, e.error
108
- when :fetch
109
- return get(e.conflicting_resource_id)
110
- end
111
- end
112
-
113
- raise e
114
- end
115
-
116
- return if response.body.nil?
117
-
118
- Resources::BillingRequest.new(unenvelope_body(response.body), response)
119
- end
120
-
121
50
  # If the billing request has a pending <code>collect_customer_details</code>
122
51
  # action, this endpoint can be used to collect the details in order to
123
52
  # complete it.
@@ -0,0 +1,252 @@
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 OutboundPayment endpoints
12
+ class OutboundPaymentsService < BaseService
13
+ #
14
+ # Example URL: /outbound_payments
15
+ # @param options [Hash] parameters as a hash, under a params key.
16
+ def create(options = {})
17
+ path = '/outbound_payments'
18
+
19
+ params = options.delete(:params) || {}
20
+ options[:params] = {}
21
+ options[:params][envelope_key] = params
22
+
23
+ options[:retry_failures] = true
24
+
25
+ begin
26
+ response = make_request(:post, path, options)
27
+
28
+ # Response doesn't raise any errors until #body is called
29
+ response.tap(&:body)
30
+ rescue InvalidStateError => e
31
+ if e.idempotent_creation_conflict?
32
+ case @api_service.on_idempotency_conflict
33
+ when :raise
34
+ raise IdempotencyConflict, e.error
35
+ when :fetch
36
+ return get(e.conflicting_resource_id)
37
+ end
38
+ end
39
+
40
+ raise e
41
+ end
42
+
43
+ return if response.body.nil?
44
+
45
+ Resources::OutboundPayment.new(unenvelope_body(response.body), response)
46
+ end
47
+
48
+ # Creates an outbound payment to your verified business bank account as the
49
+ # recipient.
50
+ # Example URL: /outbound_payments/withdrawal
51
+ # @param options [Hash] parameters as a hash, under a params key.
52
+ def withdraw(options = {})
53
+ path = '/outbound_payments/withdrawal'
54
+
55
+ params = options.delete(:params) || {}
56
+ options[:params] = {}
57
+ options[:params]['data'] = params
58
+
59
+ options[:retry_failures] = false
60
+
61
+ begin
62
+ response = make_request(:post, path, options)
63
+
64
+ # Response doesn't raise any errors until #body is called
65
+ response.tap(&:body)
66
+ rescue InvalidStateError => e
67
+ if e.idempotent_creation_conflict?
68
+ case @api_service.on_idempotency_conflict
69
+ when :raise
70
+ raise IdempotencyConflict, e.error
71
+ when :fetch
72
+ return get(e.conflicting_resource_id)
73
+ end
74
+ end
75
+
76
+ raise e
77
+ end
78
+
79
+ return if response.body.nil?
80
+
81
+ Resources::OutboundPayment.new(unenvelope_body(response.body), response)
82
+ end
83
+
84
+ # Cancels an outbound payment. Only outbound payments with either `verifying`,
85
+ # `pending_approval`, or `scheduled` status can be cancelled.
86
+ # Once an outbound payment is `executing`, the money moving process has begun
87
+ # and cannot be reversed.
88
+ # Example URL: /outbound_payments/:identity/actions/cancel
89
+ #
90
+ # @param identity # Unique identifier of the outbound payment.
91
+ # @param options [Hash] parameters as a hash, under a params key.
92
+ def cancel(identity, options = {})
93
+ path = sub_url('/outbound_payments/:identity/actions/cancel', {
94
+ 'identity' => identity
95
+ })
96
+
97
+ params = options.delete(:params) || {}
98
+ options[:params] = {}
99
+ options[:params]['data'] = params
100
+
101
+ options[:retry_failures] = false
102
+
103
+ begin
104
+ response = make_request(:post, path, options)
105
+
106
+ # Response doesn't raise any errors until #body is called
107
+ response.tap(&:body)
108
+ rescue InvalidStateError => e
109
+ if e.idempotent_creation_conflict?
110
+ case @api_service.on_idempotency_conflict
111
+ when :raise
112
+ raise IdempotencyConflict, e.error
113
+ when :fetch
114
+ return get(e.conflicting_resource_id)
115
+ end
116
+ end
117
+
118
+ raise e
119
+ end
120
+
121
+ return if response.body.nil?
122
+
123
+ Resources::OutboundPayment.new(unenvelope_body(response.body), response)
124
+ end
125
+
126
+ # Approves an outbound payment. Only outbound payments with the
127
+ # “pending_approval” status can be approved.
128
+ # Example URL: /outbound_payments/:identity/actions/approve
129
+ #
130
+ # @param identity # Unique identifier of the outbound payment.
131
+ # @param options [Hash] parameters as a hash, under a params key.
132
+ def approve(identity, options = {})
133
+ path = sub_url('/outbound_payments/:identity/actions/approve', {
134
+ 'identity' => identity
135
+ })
136
+
137
+ params = options.delete(:params) || {}
138
+ options[:params] = {}
139
+ options[:params]['data'] = params
140
+
141
+ options[:retry_failures] = false
142
+
143
+ begin
144
+ response = make_request(:post, path, options)
145
+
146
+ # Response doesn't raise any errors until #body is called
147
+ response.tap(&:body)
148
+ rescue InvalidStateError => e
149
+ if e.idempotent_creation_conflict?
150
+ case @api_service.on_idempotency_conflict
151
+ when :raise
152
+ raise IdempotencyConflict, e.error
153
+ when :fetch
154
+ return get(e.conflicting_resource_id)
155
+ end
156
+ end
157
+
158
+ raise e
159
+ end
160
+
161
+ return if response.body.nil?
162
+
163
+ Resources::OutboundPayment.new(unenvelope_body(response.body), response)
164
+ end
165
+
166
+ # Fetches an outbound_payment by ID
167
+ # Example URL: /outbound_payments/:identity
168
+ #
169
+ # @param identity # Unique identifier of the outbound payment.
170
+ # @param options [Hash] parameters as a hash, under a params key.
171
+ def get(identity, options = {})
172
+ path = sub_url('/outbound_payments/:identity', {
173
+ 'identity' => identity
174
+ })
175
+
176
+ options[:retry_failures] = true
177
+
178
+ response = make_request(:get, path, options)
179
+
180
+ return if response.body.nil?
181
+
182
+ Resources::OutboundPayment.new(unenvelope_body(response.body), response)
183
+ end
184
+
185
+ # Returns a [cursor-paginated](#api-usage-cursor-pagination) list of outbound
186
+ # payments.
187
+ # Example URL: /outbound_payments
188
+ # @param options [Hash] parameters as a hash, under a params key.
189
+ def list(options = {})
190
+ path = '/outbound_payments'
191
+
192
+ options[:retry_failures] = true
193
+
194
+ response = make_request(:get, path, options)
195
+
196
+ ListResponse.new(
197
+ response: response,
198
+ unenveloped_body: unenvelope_body(response.body),
199
+ resource_class: Resources::OutboundPayment
200
+ )
201
+ end
202
+
203
+ # Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
204
+ #
205
+ # @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
206
+ # Otherwise they will be the body of the request.
207
+ def all(options = {})
208
+ Paginator.new(
209
+ service: self,
210
+ options: options
211
+ ).enumerator
212
+ end
213
+
214
+ # Updates an outbound payment object. This accepts only the metadata parameter.
215
+ # Example URL: /outbound_payments/:identity
216
+ #
217
+ # @param identity # Unique identifier of the outbound payment.
218
+ # @param options [Hash] parameters as a hash, under a params key.
219
+ def update(identity, options = {})
220
+ path = sub_url('/outbound_payments/:identity', {
221
+ 'identity' => identity
222
+ })
223
+
224
+ params = options.delete(:params) || {}
225
+ options[:params] = {}
226
+ options[:params][envelope_key] = params
227
+
228
+ options[:retry_failures] = true
229
+
230
+ response = make_request(:put, path, options)
231
+
232
+ return if response.body.nil?
233
+
234
+ Resources::OutboundPayment.new(unenvelope_body(response.body), response)
235
+ end
236
+
237
+ private
238
+
239
+ # Unenvelope the response of the body using the service's `envelope_key`
240
+ #
241
+ # @param body [Hash]
242
+ def unenvelope_body(body)
243
+ body[envelope_key] || body['data']
244
+ end
245
+
246
+ # return the key which API responses will envelope data under
247
+ def envelope_key
248
+ 'outbound_payments'
249
+ end
250
+ end
251
+ end
252
+ end
@@ -3,5 +3,5 @@ end
3
3
 
4
4
  module GoCardlessPro
5
5
  # Current version of the GC gem
6
- VERSION = '3.4.0'
6
+ VERSION = '3.6.0'
7
7
  end
@@ -42,6 +42,9 @@ require_relative 'gocardless_pro/webhook'
42
42
  require_relative 'gocardless_pro/resources/balance'
43
43
  require_relative 'gocardless_pro/services/balances_service'
44
44
 
45
+ require_relative 'gocardless_pro/resources/bank_account_detail'
46
+ require_relative 'gocardless_pro/services/bank_account_details_service'
47
+
45
48
  require_relative 'gocardless_pro/resources/bank_authorisation'
46
49
  require_relative 'gocardless_pro/services/bank_authorisations_service'
47
50
 
@@ -108,6 +111,9 @@ require_relative 'gocardless_pro/services/mandate_pdfs_service'
108
111
  require_relative 'gocardless_pro/resources/negative_balance_limit'
109
112
  require_relative 'gocardless_pro/services/negative_balance_limits_service'
110
113
 
114
+ require_relative 'gocardless_pro/resources/outbound_payment'
115
+ require_relative 'gocardless_pro/services/outbound_payments_service'
116
+
111
117
  require_relative 'gocardless_pro/resources/payer_authorisation'
112
118
  require_relative 'gocardless_pro/services/payer_authorisations_service'
113
119
 
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: 3.4.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-26 00:00:00.000000000 Z
11
+ date: 2025-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -113,6 +113,7 @@ files:
113
113
  - lib/gocardless_pro/paginator.rb
114
114
  - lib/gocardless_pro/request.rb
115
115
  - lib/gocardless_pro/resources/balance.rb
116
+ - lib/gocardless_pro/resources/bank_account_detail.rb
116
117
  - lib/gocardless_pro/resources/bank_authorisation.rb
117
118
  - lib/gocardless_pro/resources/bank_details_lookup.rb
118
119
  - lib/gocardless_pro/resources/billing_request.rb
@@ -135,6 +136,7 @@ files:
135
136
  - lib/gocardless_pro/resources/mandate_import_entry.rb
136
137
  - lib/gocardless_pro/resources/mandate_pdf.rb
137
138
  - lib/gocardless_pro/resources/negative_balance_limit.rb
139
+ - lib/gocardless_pro/resources/outbound_payment.rb
138
140
  - lib/gocardless_pro/resources/payer_authorisation.rb
139
141
  - lib/gocardless_pro/resources/payer_theme.rb
140
142
  - lib/gocardless_pro/resources/payment.rb
@@ -151,6 +153,7 @@ files:
151
153
  - lib/gocardless_pro/resources/webhook.rb
152
154
  - lib/gocardless_pro/response.rb
153
155
  - lib/gocardless_pro/services/balances_service.rb
156
+ - lib/gocardless_pro/services/bank_account_details_service.rb
154
157
  - lib/gocardless_pro/services/bank_authorisations_service.rb
155
158
  - lib/gocardless_pro/services/bank_details_lookups_service.rb
156
159
  - lib/gocardless_pro/services/base_service.rb
@@ -174,6 +177,7 @@ files:
174
177
  - lib/gocardless_pro/services/mandate_pdfs_service.rb
175
178
  - lib/gocardless_pro/services/mandates_service.rb
176
179
  - lib/gocardless_pro/services/negative_balance_limits_service.rb
180
+ - lib/gocardless_pro/services/outbound_payments_service.rb
177
181
  - lib/gocardless_pro/services/payer_authorisations_service.rb
178
182
  - lib/gocardless_pro/services/payer_themes_service.rb
179
183
  - lib/gocardless_pro/services/payments_service.rb