gocardless_pro 3.5.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: 9b6c3812f06f80708ae87c97ddaadcd761072a851345b9ef5cf8334a41440f16
4
- data.tar.gz: 4b8de1ec177c357bf1ff19714318edd61b87a9da9241d3fed8861c3e9a4bc37c
3
+ metadata.gz: dc192d2230d8b35d8e0d5d7aecbfce3fc0fcd3516d973b3cef282771e8c16026
4
+ data.tar.gz: 7db1089cd74597a29b745f2b1275d4fef842317e2672b7fe0ebe3bdf4ae91f1d
5
5
  SHA512:
6
- metadata.gz: f53d81b4695e0a720a12f5f1b57ab4c0c94d6fbb5997bf42f73a6285b15abad69b7199d5f6fd6845e724e2552d66220f1946290f3ac93b2cad772714cba7a97f
7
- data.tar.gz: af724b976c328d768ac04c64303bf1c9c36aa6a8e916564e4ffef23303eaf884e9a067d994f2ea51553dd7a04aba1ca70ae79cad904edb3f18aa19429f21b0c8
6
+ metadata.gz: 48cc431b2261bd308a6675d01127dcd11d57c3699872098da4eba888921e09c372b1e157565bd91416dc53f8c0a6d60587e7c183499f71c90caaef395c134b22
7
+ data.tar.gz: 2d8d59d8c86123537449a90a0a9fb927cbcba5f3b79afb9cd4111be21688a7a9f64aef4acc5e1f45dca34184d114d343389e2bc878a77c98ee7c115cf50339fc
@@ -123,6 +123,11 @@ module GoCardlessPro
123
123
  @negative_balance_limits ||= Services::NegativeBalanceLimitsService.new(@api_service)
124
124
  end
125
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
+
126
131
  # Access to the service for payer_authorisation to make API calls
127
132
  def payer_authorisations
128
133
  @payer_authorisations ||= Services::PayerAuthorisationsService.new(@api_service)
@@ -243,7 +248,7 @@ module GoCardlessPro
243
248
  'User-Agent' => "#{user_agent}",
244
249
  'Content-Type' => 'application/json',
245
250
  'GoCardless-Client-Library' => 'gocardless-pro-ruby',
246
- 'GoCardless-Client-Version' => '3.5.0'
251
+ 'GoCardless-Client-Version' => '3.6.0'
247
252
  }
248
253
  }
249
254
  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,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.5.0'
6
+ VERSION = '3.6.0'
7
7
  end
@@ -111,6 +111,9 @@ require_relative 'gocardless_pro/services/mandate_pdfs_service'
111
111
  require_relative 'gocardless_pro/resources/negative_balance_limit'
112
112
  require_relative 'gocardless_pro/services/negative_balance_limits_service'
113
113
 
114
+ require_relative 'gocardless_pro/resources/outbound_payment'
115
+ require_relative 'gocardless_pro/services/outbound_payments_service'
116
+
114
117
  require_relative 'gocardless_pro/resources/payer_authorisation'
115
118
  require_relative 'gocardless_pro/services/payer_authorisations_service'
116
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.5.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-04-04 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
@@ -136,6 +136,7 @@ files:
136
136
  - lib/gocardless_pro/resources/mandate_import_entry.rb
137
137
  - lib/gocardless_pro/resources/mandate_pdf.rb
138
138
  - lib/gocardless_pro/resources/negative_balance_limit.rb
139
+ - lib/gocardless_pro/resources/outbound_payment.rb
139
140
  - lib/gocardless_pro/resources/payer_authorisation.rb
140
141
  - lib/gocardless_pro/resources/payer_theme.rb
141
142
  - lib/gocardless_pro/resources/payment.rb
@@ -176,6 +177,7 @@ files:
176
177
  - lib/gocardless_pro/services/mandate_pdfs_service.rb
177
178
  - lib/gocardless_pro/services/mandates_service.rb
178
179
  - lib/gocardless_pro/services/negative_balance_limits_service.rb
180
+ - lib/gocardless_pro/services/outbound_payments_service.rb
179
181
  - lib/gocardless_pro/services/payer_authorisations_service.rb
180
182
  - lib/gocardless_pro/services/payer_themes_service.rb
181
183
  - lib/gocardless_pro/services/payments_service.rb