gocardless_pro 3.1.0 → 3.3.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/lib/gocardless_pro/client.rb +6 -1
- data/lib/gocardless_pro/resources/balance.rb +61 -0
- data/lib/gocardless_pro/resources/mandate_import_entry.rb +2 -1
- data/lib/gocardless_pro/services/balances_service.rb +57 -0
- data/lib/gocardless_pro/services/billing_requests_service.rb +73 -2
- data/lib/gocardless_pro/services/refunds_service.rb +2 -2
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +6 -5
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro.rb +3 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 215f258cc6eedaf440d8ecd8f6d603b85fc693f1d97bd1a84838e1cd8b910c8c
|
4
|
+
data.tar.gz: 4b94529879e8e0e88e09cf4b3a903c4e933acbc9934707e8b1d5f168c0b6b4c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f03cb54c869ee653a7ea3bced2edca67e5edc0fe7ef4561b75edeca5a60a2d758b6c8632b0b86485500ef2d44644e369810e632575eb8e60cf5ba8da93e077
|
7
|
+
data.tar.gz: 320f63dd94607c96eef0a42ffb8137e24b9b6cd07d201ca29e3fa53b82ef81907f150d92df6f2e72430f5cedf0ed329d7bcc1b41e83261790e7c1e0c49a5c5ef
|
@@ -3,6 +3,11 @@ module GoCardlessPro
|
|
3
3
|
class Client
|
4
4
|
extend Forwardable
|
5
5
|
|
6
|
+
# Access to the service for balance to make API calls
|
7
|
+
def balances
|
8
|
+
@balances ||= Services::BalancesService.new(@api_service)
|
9
|
+
end
|
10
|
+
|
6
11
|
# Access to the service for bank_authorisation to make API calls
|
7
12
|
def bank_authorisations
|
8
13
|
@bank_authorisations ||= Services::BankAuthorisationsService.new(@api_service)
|
@@ -233,7 +238,7 @@ module GoCardlessPro
|
|
233
238
|
'User-Agent' => "#{user_agent}",
|
234
239
|
'Content-Type' => 'application/json',
|
235
240
|
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
|
236
|
-
'GoCardless-Client-Version' => '3.
|
241
|
+
'GoCardless-Client-Version' => '3.3.0'
|
237
242
|
}
|
238
243
|
}
|
239
244
|
end
|
@@ -0,0 +1,61 @@
|
|
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 balance resource returned from the API
|
12
|
+
|
13
|
+
# Returns the balances for a creditor. These balances are the same as what’s
|
14
|
+
# shown in the dashboard with one exception (mentioned below under
|
15
|
+
# balance_type).
|
16
|
+
#
|
17
|
+
# These balances will typically be 3-5 minutes old. The balance amounts
|
18
|
+
# likely won’t match what’s shown in the dashboard as the dashboard balances
|
19
|
+
# are updated much less frequently (once per day).
|
20
|
+
class Balance
|
21
|
+
attr_reader :amount, :balance_type, :currency, :last_updated_at
|
22
|
+
|
23
|
+
# Initialize a balance resource instance
|
24
|
+
# @param object [Hash] an object returned from the API
|
25
|
+
def initialize(object, response = nil)
|
26
|
+
@object = object
|
27
|
+
|
28
|
+
@amount = object['amount']
|
29
|
+
@balance_type = object['balance_type']
|
30
|
+
@currency = object['currency']
|
31
|
+
@last_updated_at = object['last_updated_at']
|
32
|
+
@links = object['links']
|
33
|
+
@response = response
|
34
|
+
end
|
35
|
+
|
36
|
+
def api_response
|
37
|
+
ApiResponse.new(@response)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Return the links that the resource has
|
41
|
+
def links
|
42
|
+
@balance_links ||= Links.new(@links)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Provides the balance resource as a hash of all its readable attributes
|
46
|
+
def to_h
|
47
|
+
@object
|
48
|
+
end
|
49
|
+
|
50
|
+
class Links
|
51
|
+
def initialize(links)
|
52
|
+
@links = links || {}
|
53
|
+
end
|
54
|
+
|
55
|
+
def creditor
|
56
|
+
@links['creditor']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -41,7 +41,7 @@ module GoCardlessPro
|
|
41
41
|
# href="mailto:help@gocardless.com">get in touch</a> if you would like to
|
42
42
|
# use this API.</p>
|
43
43
|
class MandateImportEntry
|
44
|
-
attr_reader :created_at, :record_identifier
|
44
|
+
attr_reader :created_at, :processing_errors, :record_identifier
|
45
45
|
|
46
46
|
# Initialize a mandate_import_entry resource instance
|
47
47
|
# @param object [Hash] an object returned from the API
|
@@ -50,6 +50,7 @@ module GoCardlessPro
|
|
50
50
|
|
51
51
|
@created_at = object['created_at']
|
52
52
|
@links = object['links']
|
53
|
+
@processing_errors = object['processing_errors']
|
53
54
|
@record_identifier = object['record_identifier']
|
54
55
|
@response = response
|
55
56
|
end
|
@@ -0,0 +1,57 @@
|
|
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 Balance endpoints
|
12
|
+
class BalancesService < BaseService
|
13
|
+
# Returns a [cursor-paginated](#api-usage-cursor-pagination) list of balances
|
14
|
+
# for a given creditor. This endpoint is rate limited to 60 requests per minute.
|
15
|
+
# Example URL: /balances
|
16
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
17
|
+
def list(options = {})
|
18
|
+
path = '/balances'
|
19
|
+
|
20
|
+
options[:retry_failures] = true
|
21
|
+
|
22
|
+
response = make_request(:get, path, options)
|
23
|
+
|
24
|
+
ListResponse.new(
|
25
|
+
response: response,
|
26
|
+
unenveloped_body: unenvelope_body(response.body),
|
27
|
+
resource_class: Resources::Balance
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
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
|
+
#
|
33
|
+
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
|
34
|
+
# Otherwise they will be the body of the request.
|
35
|
+
def all(options = {})
|
36
|
+
Paginator.new(
|
37
|
+
service: self,
|
38
|
+
options: options
|
39
|
+
).enumerator
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Unenvelope the response of the body using the service's `envelope_key`
|
45
|
+
#
|
46
|
+
# @param body [Hash]
|
47
|
+
def unenvelope_body(body)
|
48
|
+
body[envelope_key] || body['data']
|
49
|
+
end
|
50
|
+
|
51
|
+
# return the key which API responses will envelope data under
|
52
|
+
def envelope_key
|
53
|
+
'balances'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -11,8 +11,7 @@ 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`
|
15
|
-
# for ACH and PAD schemes.</p>
|
14
|
+
# `subscription_request` are only supported for ACH and PAD schemes.</p>
|
16
15
|
# Example URL: /billing_requests
|
17
16
|
# @param options [Hash] parameters as a hash, under a params key.
|
18
17
|
def create(options = {})
|
@@ -47,6 +46,78 @@ module GoCardlessPro
|
|
47
46
|
Resources::BillingRequest.new(unenvelope_body(response.body), response)
|
48
47
|
end
|
49
48
|
|
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
|
+
|
50
121
|
# If the billing request has a pending <code>collect_customer_details</code>
|
51
122
|
# action, this endpoint can be used to collect the details in order to
|
52
123
|
# complete it.
|
@@ -20,8 +20,8 @@ module GoCardlessPro
|
|
20
20
|
# the total amount refunded for the payment. This safeguard is there to prevent
|
21
21
|
# two processes from creating refunds without awareness of each other.
|
22
22
|
#
|
23
|
-
# - `number_of_refunds_exceeded` if five or more refunds have already
|
24
|
-
# created against the payment.
|
23
|
+
# - `number_of_refunds_exceeded` if twenty five or more refunds have already
|
24
|
+
# been created against the payment.
|
25
25
|
#
|
26
26
|
# - `available_refund_amount_insufficient` if the creditor does not have
|
27
27
|
# sufficient balance for refunds available to cover the cost of the requested
|
@@ -52,11 +52,12 @@ module GoCardlessPro
|
|
52
52
|
# the charged back payment.</li>
|
53
53
|
# <li>`payment_late_failure`: Transitions a payment through to
|
54
54
|
# `late_failure`, having been apparently collected successfully
|
55
|
-
# beforehand. It must start in the `pending_submission`
|
56
|
-
# mandate must be in the `activated` state
|
57
|
-
# ACH, BECS, BECS_NZ or SEPA, in which cases
|
58
|
-
# `pending_submission`, since their mandates are
|
59
|
-
# first payment). Not compatible with Autogiro
|
55
|
+
# beforehand. It must start in either the `pending_submission` or
|
56
|
+
# `paid_out` state, and its mandate must be in the `activated` state
|
57
|
+
# (unless it is a payment for ACH, BECS, BECS_NZ or SEPA, in which cases
|
58
|
+
# the mandate may be `pending_submission`, since their mandates are
|
59
|
+
# submitted with their first payment). Not compatible with Autogiro
|
60
|
+
# mandates.</li>
|
60
61
|
# <li>`payment_late_failure_settled`: Behaves the same as the
|
61
62
|
# `payment_late_failure` simulator, except that the late failure is
|
62
63
|
# additionally included as a debit item in a payout, thereby settling the
|
data/lib/gocardless_pro.rb
CHANGED
@@ -39,6 +39,9 @@ require_relative 'gocardless_pro/response'
|
|
39
39
|
require_relative 'gocardless_pro/api_response'
|
40
40
|
require_relative 'gocardless_pro/webhook'
|
41
41
|
|
42
|
+
require_relative 'gocardless_pro/resources/balance'
|
43
|
+
require_relative 'gocardless_pro/services/balances_service'
|
44
|
+
|
42
45
|
require_relative 'gocardless_pro/resources/bank_authorisation'
|
43
46
|
require_relative 'gocardless_pro/services/bank_authorisations_service'
|
44
47
|
|
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
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 0.9.11
|
89
|
-
description:
|
89
|
+
description:
|
90
90
|
email:
|
91
91
|
- engineering@gocardless.com
|
92
92
|
executables: []
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/gocardless_pro/middlewares/raise_gocardless_errors.rb
|
113
113
|
- lib/gocardless_pro/paginator.rb
|
114
114
|
- lib/gocardless_pro/request.rb
|
115
|
+
- lib/gocardless_pro/resources/balance.rb
|
115
116
|
- lib/gocardless_pro/resources/bank_authorisation.rb
|
116
117
|
- lib/gocardless_pro/resources/bank_details_lookup.rb
|
117
118
|
- lib/gocardless_pro/resources/billing_request.rb
|
@@ -149,6 +150,7 @@ files:
|
|
149
150
|
- lib/gocardless_pro/resources/verification_detail.rb
|
150
151
|
- lib/gocardless_pro/resources/webhook.rb
|
151
152
|
- lib/gocardless_pro/response.rb
|
153
|
+
- lib/gocardless_pro/services/balances_service.rb
|
152
154
|
- lib/gocardless_pro/services/bank_authorisations_service.rb
|
153
155
|
- lib/gocardless_pro/services/bank_details_lookups_service.rb
|
154
156
|
- lib/gocardless_pro/services/base_service.rb
|
@@ -192,7 +194,7 @@ homepage: https://github.com/gocardless/gocardless-pro-ruby
|
|
192
194
|
licenses:
|
193
195
|
- MIT
|
194
196
|
metadata: {}
|
195
|
-
post_install_message:
|
197
|
+
post_install_message:
|
196
198
|
rdoc_options: []
|
197
199
|
require_paths:
|
198
200
|
- lib
|
@@ -208,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
210
|
version: '0'
|
209
211
|
requirements: []
|
210
212
|
rubygems_version: 3.4.19
|
211
|
-
signing_key:
|
213
|
+
signing_key:
|
212
214
|
specification_version: 4
|
213
215
|
summary: A gem for calling the GoCardless Pro API
|
214
216
|
test_files: []
|