gocardless_pro 3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d491b212bf75a7f70a1191be6b0d7d94eb4fb6cfd2d319047d62d0e2e9adf94b
4
- data.tar.gz: e473a9b05df7ec6b70e48f2b426a7fae6585ed0c919a3963d91431d6fe5bd4a4
3
+ metadata.gz: 215f258cc6eedaf440d8ecd8f6d603b85fc693f1d97bd1a84838e1cd8b910c8c
4
+ data.tar.gz: 4b94529879e8e0e88e09cf4b3a903c4e933acbc9934707e8b1d5f168c0b6b4c5
5
5
  SHA512:
6
- metadata.gz: b605624bcbbace950cf6ad9c4558a0b06abc9da731c85e934645716918cd9b9b9a5b25649e7a3e9fab57d8ca38f4facb8a221276062a1671e168eaff294d94e6
7
- data.tar.gz: eeb013ab2a0278f9f56ccb437b0f61107d7afdbdbb9670a58aff1c6afea7086b319f9a349996401d64c68281c9be743a27d1e1e7318d6ae0a6681325e438a6d1
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.2.0'
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
@@ -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
@@ -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 been
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` 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>
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
@@ -3,5 +3,5 @@ end
3
3
 
4
4
  module GoCardlessPro
5
5
  # Current version of the GC gem
6
- VERSION = '3.2.0'
6
+ VERSION = '3.3.0'
7
7
  end
@@ -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.2.0
4
+ version: 3.3.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-01-28 00:00:00.000000000 Z
11
+ date: 2025-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -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