gocardless_pro 4.2.0 → 4.4.1
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/README.md +16 -12
- data/lib/gocardless_pro/client.rb +33 -3
- data/lib/gocardless_pro/error.rb +3 -3
- data/lib/gocardless_pro/list_response.rb +2 -2
- data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +11 -3
- data/lib/gocardless_pro/paginator.rb +3 -2
- data/lib/gocardless_pro/resources/balance.rb +4 -1
- data/lib/gocardless_pro/resources/bank_account_detail.rb +5 -1
- data/lib/gocardless_pro/resources/bank_account_holder_verification.rb +44 -0
- data/lib/gocardless_pro/resources/bank_authorisation.rb +9 -2
- data/lib/gocardless_pro/resources/bank_details_lookup.rb +3 -1
- data/lib/gocardless_pro/resources/billing_request.rb +24 -10
- data/lib/gocardless_pro/resources/billing_request_flow.rb +18 -2
- data/lib/gocardless_pro/resources/billing_request_template.rb +18 -2
- data/lib/gocardless_pro/resources/billing_request_with_action.rb +6 -5
- data/lib/gocardless_pro/resources/block.rb +12 -8
- data/lib/gocardless_pro/resources/creditor.rb +26 -6
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +17 -7
- data/lib/gocardless_pro/resources/currency_exchange_rate.rb +4 -1
- data/lib/gocardless_pro/resources/customer.rb +22 -5
- data/lib/gocardless_pro/resources/customer_bank_account.rb +24 -10
- data/lib/gocardless_pro/resources/customer_notification.rb +8 -5
- data/lib/gocardless_pro/resources/event.rb +31 -4
- data/lib/gocardless_pro/resources/export.rb +7 -1
- data/lib/gocardless_pro/resources/funds_availability.rb +38 -0
- data/lib/gocardless_pro/resources/instalment_schedule.rb +8 -2
- data/lib/gocardless_pro/resources/institution.rb +11 -4
- data/lib/gocardless_pro/resources/logo.rb +2 -1
- data/lib/gocardless_pro/resources/mandate.rb +21 -6
- data/lib/gocardless_pro/resources/mandate_import.rb +29 -22
- data/lib/gocardless_pro/resources/mandate_import_entry.rb +16 -17
- data/lib/gocardless_pro/resources/mandate_pdf.rb +5 -4
- data/lib/gocardless_pro/resources/negative_balance_limit.rb +4 -2
- data/lib/gocardless_pro/resources/outbound_payment.rb +33 -12
- data/lib/gocardless_pro/resources/outbound_payment_import.rb +81 -0
- data/lib/gocardless_pro/resources/outbound_payment_import_entry.rb +77 -0
- data/lib/gocardless_pro/resources/payer_authorisation.rb +34 -32
- data/lib/gocardless_pro/resources/payment.rb +24 -8
- data/lib/gocardless_pro/resources/payment_account.rb +64 -0
- data/lib/gocardless_pro/resources/payment_account_transaction.rb +79 -0
- data/lib/gocardless_pro/resources/payout.rb +19 -8
- data/lib/gocardless_pro/resources/payout_item.rb +4 -3
- data/lib/gocardless_pro/resources/redirect_flow.rb +44 -25
- data/lib/gocardless_pro/resources/refund.rb +16 -7
- data/lib/gocardless_pro/resources/scheme_identifier.rb +18 -3
- data/lib/gocardless_pro/resources/subscription.rb +37 -16
- data/lib/gocardless_pro/resources/tax_rate.rb +8 -3
- data/lib/gocardless_pro/resources/transferred_mandate.rb +3 -1
- data/lib/gocardless_pro/resources/verification_detail.rb +19 -8
- data/lib/gocardless_pro/resources/webhook.rb +13 -2
- data/lib/gocardless_pro/services/balances_service.rb +11 -3
- data/lib/gocardless_pro/services/bank_account_details_service.rb +14 -3
- data/lib/gocardless_pro/services/bank_account_holder_verifications_service.rb +92 -0
- data/lib/gocardless_pro/services/bank_authorisations_service.rb +9 -3
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +14 -6
- data/lib/gocardless_pro/services/billing_request_flows_service.rb +8 -2
- data/lib/gocardless_pro/services/billing_request_templates_service.rb +14 -7
- data/lib/gocardless_pro/services/billing_request_with_actions_service.rb +7 -1
- data/lib/gocardless_pro/services/billing_requests_service.rb +38 -33
- data/lib/gocardless_pro/services/blocks_service.rb +17 -10
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +14 -7
- data/lib/gocardless_pro/services/creditors_service.rb +13 -6
- data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +10 -3
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +25 -15
- data/lib/gocardless_pro/services/customer_notifications_service.rb +8 -3
- data/lib/gocardless_pro/services/customers_service.rb +15 -9
- data/lib/gocardless_pro/services/events_service.rb +16 -4
- data/lib/gocardless_pro/services/exports_service.rb +8 -2
- data/lib/gocardless_pro/services/funds_availabilities_service.rb +56 -0
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +21 -13
- data/lib/gocardless_pro/services/institutions_service.rb +8 -2
- data/lib/gocardless_pro/services/logos_service.rb +9 -3
- data/lib/gocardless_pro/services/mandate_import_entries_service.rb +10 -4
- data/lib/gocardless_pro/services/mandate_imports_service.rb +16 -8
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +11 -5
- data/lib/gocardless_pro/services/mandates_service.rb +23 -16
- data/lib/gocardless_pro/services/negative_balance_limits_service.rb +10 -3
- data/lib/gocardless_pro/services/outbound_payment_import_entries_service.rb +64 -0
- data/lib/gocardless_pro/services/outbound_payment_imports_service.rb +118 -0
- data/lib/gocardless_pro/services/outbound_payments_service.rb +34 -12
- data/lib/gocardless_pro/services/payer_authorisations_service.rb +18 -15
- data/lib/gocardless_pro/services/payer_themes_service.rb +7 -1
- data/lib/gocardless_pro/services/payment_account_transactions_service.rb +93 -0
- data/lib/gocardless_pro/services/payment_accounts_service.rb +83 -0
- data/lib/gocardless_pro/services/payments_service.rb +29 -21
- data/lib/gocardless_pro/services/payout_items_service.rb +12 -7
- data/lib/gocardless_pro/services/payouts_service.rb +14 -7
- data/lib/gocardless_pro/services/redirect_flows_service.rb +19 -9
- data/lib/gocardless_pro/services/refunds_service.rb +18 -13
- data/lib/gocardless_pro/services/scenario_simulators_service.rb +90 -81
- data/lib/gocardless_pro/services/scheme_identifiers_service.rb +15 -9
- data/lib/gocardless_pro/services/subscriptions_service.rb +57 -47
- data/lib/gocardless_pro/services/tax_rates_service.rb +11 -4
- data/lib/gocardless_pro/services/transferred_mandates_service.rb +8 -2
- data/lib/gocardless_pro/services/verification_details_service.rb +7 -1
- data/lib/gocardless_pro/services/webhooks_service.rb +13 -6
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro/webhook.rb +45 -0
- data/lib/gocardless_pro.rb +18 -0
- metadata +38 -16
|
@@ -12,10 +12,15 @@ module GoCardlessPro
|
|
|
12
12
|
|
|
13
13
|
# Tax rates from tax authority.
|
|
14
14
|
#
|
|
15
|
-
# We also maintain a
|
|
16
|
-
#
|
|
15
|
+
# We also maintain a static list of the tax rates for each jurisdiction
|
|
16
|
+
# (https://developer.gocardless.com/api-reference/#appendix-tax-rates).
|
|
17
17
|
class TaxRate
|
|
18
|
-
attr_reader :end_date
|
|
18
|
+
attr_reader :end_date
|
|
19
|
+
attr_reader :id
|
|
20
|
+
attr_reader :jurisdiction
|
|
21
|
+
attr_reader :percentage
|
|
22
|
+
attr_reader :start_date
|
|
23
|
+
attr_reader :type
|
|
19
24
|
|
|
20
25
|
# Initialize a tax_rate resource instance
|
|
21
26
|
# @param object [Hash] an object returned from the API
|
|
@@ -12,7 +12,9 @@ module GoCardlessPro
|
|
|
12
12
|
|
|
13
13
|
# Mandates that have been transferred using Current Account Switch Service
|
|
14
14
|
class TransferredMandate
|
|
15
|
-
attr_reader :encrypted_customer_bank_details
|
|
15
|
+
attr_reader :encrypted_customer_bank_details
|
|
16
|
+
attr_reader :encrypted_decryption_key
|
|
17
|
+
attr_reader :public_key_id
|
|
16
18
|
|
|
17
19
|
# Initialize a transferred_mandate resource instance
|
|
18
20
|
# @param object [Hash] an object returned from the API
|
|
@@ -13,17 +13,26 @@ module GoCardlessPro
|
|
|
13
13
|
# Verification details represent any information needed by GoCardless to
|
|
14
14
|
# verify a creditor.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
16
|
+
# Restricted:
|
|
17
|
+
# These endpoints are restricted to customers who want to collect their
|
|
18
18
|
# merchant's
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
19
|
+
# verification details and pass them to GoCardless via our API. Please get
|
|
20
|
+
# in
|
|
21
|
+
# touch (mailto:help@gocardless.com) if you wish to enable this feature on
|
|
22
22
|
# your
|
|
23
|
-
#
|
|
23
|
+
# account.
|
|
24
24
|
class VerificationDetail
|
|
25
|
-
attr_reader :address_line1
|
|
26
|
-
|
|
25
|
+
attr_reader :address_line1
|
|
26
|
+
attr_reader :address_line2
|
|
27
|
+
attr_reader :address_line3
|
|
28
|
+
attr_reader :city
|
|
29
|
+
attr_reader :company_number
|
|
30
|
+
attr_reader :country_code
|
|
31
|
+
attr_reader :description
|
|
32
|
+
attr_reader :directors
|
|
33
|
+
attr_reader :name
|
|
34
|
+
attr_reader :postal_code
|
|
35
|
+
attr_reader :region
|
|
27
36
|
|
|
28
37
|
# Initialize a verification_detail resource instance
|
|
29
38
|
# @param object [Hash] an object returned from the API
|
|
@@ -35,11 +44,13 @@ module GoCardlessPro
|
|
|
35
44
|
@address_line3 = object['address_line3']
|
|
36
45
|
@city = object['city']
|
|
37
46
|
@company_number = object['company_number']
|
|
47
|
+
@country_code = object['country_code']
|
|
38
48
|
@description = object['description']
|
|
39
49
|
@directors = object['directors']
|
|
40
50
|
@links = object['links']
|
|
41
51
|
@name = object['name']
|
|
42
52
|
@postal_code = object['postal_code']
|
|
53
|
+
@region = object['region']
|
|
43
54
|
@response = response
|
|
44
55
|
end
|
|
45
56
|
|
|
@@ -12,8 +12,19 @@ module GoCardlessPro
|
|
|
12
12
|
|
|
13
13
|
# Basic description of a webhook
|
|
14
14
|
class Webhook
|
|
15
|
-
attr_reader :created_at
|
|
16
|
-
|
|
15
|
+
attr_reader :created_at
|
|
16
|
+
attr_reader :id
|
|
17
|
+
attr_reader :is_test
|
|
18
|
+
attr_reader :request_body
|
|
19
|
+
attr_reader :request_headers
|
|
20
|
+
attr_reader :response_body
|
|
21
|
+
attr_reader :response_body_truncated
|
|
22
|
+
attr_reader :response_code
|
|
23
|
+
attr_reader :response_headers
|
|
24
|
+
attr_reader :response_headers_content_truncated
|
|
25
|
+
attr_reader :response_headers_count_truncated
|
|
26
|
+
attr_reader :successful
|
|
27
|
+
attr_reader :url
|
|
17
28
|
|
|
18
29
|
# Initialize a webhook resource instance
|
|
19
30
|
# @param object [Hash] an object returned from the API
|
|
@@ -10,8 +10,10 @@ module GoCardlessPro
|
|
|
10
10
|
module Services
|
|
11
11
|
# Service for making requests to the Balance endpoints
|
|
12
12
|
class BalancesService < BaseService
|
|
13
|
-
# Returns a
|
|
14
|
-
#
|
|
13
|
+
# Returns a cursor-paginated
|
|
14
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
15
|
+
# list of balances for a given creditor. This endpoint is rate limited to 60
|
|
16
|
+
# requests per minute.
|
|
15
17
|
# Example URL: /balances
|
|
16
18
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
17
19
|
def list(options = {})
|
|
@@ -45,7 +47,13 @@ module GoCardlessPro
|
|
|
45
47
|
#
|
|
46
48
|
# @param body [Hash]
|
|
47
49
|
def unenvelope_body(body)
|
|
48
|
-
body
|
|
50
|
+
if body.key?(envelope_key)
|
|
51
|
+
body[envelope_key]
|
|
52
|
+
elsif body.key?('data')
|
|
53
|
+
body['data']
|
|
54
|
+
else
|
|
55
|
+
body
|
|
56
|
+
end
|
|
49
57
|
end
|
|
50
58
|
|
|
51
59
|
# return the key which API responses will envelope data under
|
|
@@ -11,14 +11,19 @@ module GoCardlessPro
|
|
|
11
11
|
# Service for making requests to the BankAccountDetail endpoints
|
|
12
12
|
class BankAccountDetailsService < BaseService
|
|
13
13
|
# Returns bank account details in the flattened JSON Web Encryption format
|
|
14
|
-
# described in RFC 7516
|
|
14
|
+
# described in RFC 7516.
|
|
15
|
+
#
|
|
16
|
+
# You must specify a `Gc-Key-Id` header when using this endpoint. See Public Key
|
|
17
|
+
# Setup
|
|
18
|
+
# (https://developer.gocardless.com/gc-embed/bank-details-access#public_key_setup)
|
|
19
|
+
# for more details.
|
|
15
20
|
# Example URL: /bank_account_details/:identity
|
|
16
21
|
#
|
|
17
22
|
# @param identity # Unique identifier, beginning with "BA".
|
|
18
23
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
19
24
|
def get(identity, options = {})
|
|
20
25
|
path = sub_url('/bank_account_details/:identity', {
|
|
21
|
-
'identity' => identity
|
|
26
|
+
'identity' => identity,
|
|
22
27
|
})
|
|
23
28
|
|
|
24
29
|
options[:retry_failures] = true
|
|
@@ -36,7 +41,13 @@ module GoCardlessPro
|
|
|
36
41
|
#
|
|
37
42
|
# @param body [Hash]
|
|
38
43
|
def unenvelope_body(body)
|
|
39
|
-
body
|
|
44
|
+
if body.key?(envelope_key)
|
|
45
|
+
body[envelope_key]
|
|
46
|
+
elsif body.key?('data')
|
|
47
|
+
body['data']
|
|
48
|
+
else
|
|
49
|
+
body
|
|
50
|
+
end
|
|
40
51
|
end
|
|
41
52
|
|
|
42
53
|
# return the key which API responses will envelope data under
|
|
@@ -0,0 +1,92 @@
|
|
|
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 BankAccountHolderVerification endpoints
|
|
12
|
+
class BankAccountHolderVerificationsService < BaseService
|
|
13
|
+
# Verify the account holder of the bank account. A complete verification can be
|
|
14
|
+
# attached when creating an outbound payment. This endpoint allows partner
|
|
15
|
+
# merchants to create Confirmation of Payee checks on customer bank accounts
|
|
16
|
+
# before sending outbound payments.
|
|
17
|
+
# Example URL: /bank_account_holder_verifications
|
|
18
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
|
19
|
+
def create(options = {})
|
|
20
|
+
path = '/bank_account_holder_verifications'
|
|
21
|
+
|
|
22
|
+
params = options.delete(:params) || {}
|
|
23
|
+
options[:params] = {}
|
|
24
|
+
options[:params][envelope_key] = params
|
|
25
|
+
|
|
26
|
+
options[:retry_failures] = true
|
|
27
|
+
|
|
28
|
+
begin
|
|
29
|
+
response = make_request(:post, path, options)
|
|
30
|
+
|
|
31
|
+
# Response doesn't raise any errors until #body is called
|
|
32
|
+
response.tap(&:body)
|
|
33
|
+
rescue InvalidStateError => e
|
|
34
|
+
if e.idempotent_creation_conflict?
|
|
35
|
+
case @api_service.on_idempotency_conflict
|
|
36
|
+
when :raise
|
|
37
|
+
raise IdempotencyConflict.new(e.error)
|
|
38
|
+
when :fetch
|
|
39
|
+
return get(e.conflicting_resource_id)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
raise e
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
return if response.body.nil?
|
|
47
|
+
|
|
48
|
+
Resources::BankAccountHolderVerification.new(unenvelope_body(response.body), response)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Fetches a bank account holder verification by ID.
|
|
52
|
+
# Example URL: /bank_account_holder_verifications/:identity
|
|
53
|
+
#
|
|
54
|
+
# @param identity # The unique identifier for the bank account holder verification resource,
|
|
55
|
+
# e.g. "BAHV123".
|
|
56
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
|
57
|
+
def get(identity, options = {})
|
|
58
|
+
path = sub_url('/bank_account_holder_verifications/:identity', {
|
|
59
|
+
'identity' => identity,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
options[:retry_failures] = true
|
|
63
|
+
|
|
64
|
+
response = make_request(:get, path, options)
|
|
65
|
+
|
|
66
|
+
return if response.body.nil?
|
|
67
|
+
|
|
68
|
+
Resources::BankAccountHolderVerification.new(unenvelope_body(response.body), response)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
# Unenvelope the response of the body using the service's `envelope_key`
|
|
74
|
+
#
|
|
75
|
+
# @param body [Hash]
|
|
76
|
+
def unenvelope_body(body)
|
|
77
|
+
if body.key?(envelope_key)
|
|
78
|
+
body[envelope_key]
|
|
79
|
+
elsif body.key?('data')
|
|
80
|
+
body['data']
|
|
81
|
+
else
|
|
82
|
+
body
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# return the key which API responses will envelope data under
|
|
87
|
+
def envelope_key
|
|
88
|
+
'bank_account_holder_verifications'
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -31,7 +31,7 @@ module GoCardlessPro
|
|
|
31
31
|
if e.idempotent_creation_conflict?
|
|
32
32
|
case @api_service.on_idempotency_conflict
|
|
33
33
|
when :raise
|
|
34
|
-
raise IdempotencyConflict
|
|
34
|
+
raise IdempotencyConflict.new(e.error)
|
|
35
35
|
when :fetch
|
|
36
36
|
return get(e.conflicting_resource_id)
|
|
37
37
|
end
|
|
@@ -52,7 +52,7 @@ module GoCardlessPro
|
|
|
52
52
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
53
53
|
def get(identity, options = {})
|
|
54
54
|
path = sub_url('/bank_authorisations/:identity', {
|
|
55
|
-
'identity' => identity
|
|
55
|
+
'identity' => identity,
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
options[:retry_failures] = true
|
|
@@ -70,7 +70,13 @@ module GoCardlessPro
|
|
|
70
70
|
#
|
|
71
71
|
# @param body [Hash]
|
|
72
72
|
def unenvelope_body(body)
|
|
73
|
-
body
|
|
73
|
+
if body.key?(envelope_key)
|
|
74
|
+
body[envelope_key]
|
|
75
|
+
elsif body.key?('data')
|
|
76
|
+
body['data']
|
|
77
|
+
else
|
|
78
|
+
body
|
|
79
|
+
end
|
|
74
80
|
end
|
|
75
81
|
|
|
76
82
|
# return the key which API responses will envelope data under
|
|
@@ -19,23 +19,25 @@ module GoCardlessPro
|
|
|
19
19
|
# number match the details held by
|
|
20
20
|
# the relevant bank.
|
|
21
21
|
#
|
|
22
|
-
# If your request returns an
|
|
22
|
+
# If your request returns an error
|
|
23
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-errors) or the
|
|
23
24
|
# `available_debit_schemes`
|
|
24
25
|
# attribute is an empty array, you will not be able to collect payments from the
|
|
25
26
|
# specified bank account. GoCardless may be able to collect payments from an
|
|
26
27
|
# account
|
|
27
28
|
# even if no `bic` is returned.
|
|
28
29
|
#
|
|
29
|
-
# Bank account details may be supplied using
|
|
30
|
-
#
|
|
30
|
+
# Bank account details may be supplied using local details
|
|
31
|
+
# (https://developer.gocardless.com/api-reference/#appendix-local-bank-details)
|
|
32
|
+
# or an IBAN.
|
|
31
33
|
#
|
|
32
|
-
#
|
|
34
|
+
# ACH scheme For compliance reasons, an extra validation step is done using
|
|
33
35
|
# a third-party provider to make sure the customer's bank account can accept
|
|
34
36
|
# Direct Debit. If a bank account is discovered to be closed or invalid, the
|
|
35
37
|
# customer is requested to adjust the account number/routing number and
|
|
36
38
|
# succeed in this check to continue with the flow.
|
|
37
39
|
#
|
|
38
|
-
#
|
|
40
|
+
# Note: Usage of this endpoint is monitored. If your organisation relies on
|
|
39
41
|
# GoCardless for
|
|
40
42
|
# modulus or reachability checking but not for payment collection, please get in
|
|
41
43
|
# touch.
|
|
@@ -63,7 +65,13 @@ module GoCardlessPro
|
|
|
63
65
|
#
|
|
64
66
|
# @param body [Hash]
|
|
65
67
|
def unenvelope_body(body)
|
|
66
|
-
body
|
|
68
|
+
if body.key?(envelope_key)
|
|
69
|
+
body[envelope_key]
|
|
70
|
+
elsif body.key?('data')
|
|
71
|
+
body['data']
|
|
72
|
+
else
|
|
73
|
+
body
|
|
74
|
+
end
|
|
67
75
|
end
|
|
68
76
|
|
|
69
77
|
# return the key which API responses will envelope data under
|
|
@@ -38,7 +38,7 @@ module GoCardlessPro
|
|
|
38
38
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
39
39
|
def initialise(identity, options = {})
|
|
40
40
|
path = sub_url('/billing_request_flows/:identity/actions/initialise', {
|
|
41
|
-
'identity' => identity
|
|
41
|
+
'identity' => identity,
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
params = options.delete(:params) || {}
|
|
@@ -60,7 +60,13 @@ module GoCardlessPro
|
|
|
60
60
|
#
|
|
61
61
|
# @param body [Hash]
|
|
62
62
|
def unenvelope_body(body)
|
|
63
|
-
body
|
|
63
|
+
if body.key?(envelope_key)
|
|
64
|
+
body[envelope_key]
|
|
65
|
+
elsif body.key?('data')
|
|
66
|
+
body['data']
|
|
67
|
+
else
|
|
68
|
+
body
|
|
69
|
+
end
|
|
64
70
|
end
|
|
65
71
|
|
|
66
72
|
# return the key which API responses will envelope data under
|
|
@@ -10,8 +10,9 @@ module GoCardlessPro
|
|
|
10
10
|
module Services
|
|
11
11
|
# Service for making requests to the BillingRequestTemplate endpoints
|
|
12
12
|
class BillingRequestTemplatesService < BaseService
|
|
13
|
-
# Returns a
|
|
14
|
-
#
|
|
13
|
+
# Returns a cursor-paginated
|
|
14
|
+
# (https://developer.gocardless.com/api-reference/#api-usage-cursor-pagination)
|
|
15
|
+
# list of your Billing Request Templates.
|
|
15
16
|
# Example URL: /billing_request_templates
|
|
16
17
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
17
18
|
def list(options = {})
|
|
@@ -46,7 +47,7 @@ module GoCardlessPro
|
|
|
46
47
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
47
48
|
def get(identity, options = {})
|
|
48
49
|
path = sub_url('/billing_request_templates/:identity', {
|
|
49
|
-
'identity' => identity
|
|
50
|
+
'identity' => identity,
|
|
50
51
|
})
|
|
51
52
|
|
|
52
53
|
options[:retry_failures] = true
|
|
@@ -79,7 +80,7 @@ module GoCardlessPro
|
|
|
79
80
|
if e.idempotent_creation_conflict?
|
|
80
81
|
case @api_service.on_idempotency_conflict
|
|
81
82
|
when :raise
|
|
82
|
-
raise IdempotencyConflict
|
|
83
|
+
raise IdempotencyConflict.new(e.error)
|
|
83
84
|
when :fetch
|
|
84
85
|
return get(e.conflicting_resource_id)
|
|
85
86
|
end
|
|
@@ -97,11 +98,11 @@ module GoCardlessPro
|
|
|
97
98
|
# Requests created by this template.
|
|
98
99
|
# Example URL: /billing_request_templates/:identity
|
|
99
100
|
#
|
|
100
|
-
# @param identity # Unique identifier, beginning with "
|
|
101
|
+
# @param identity # Unique identifier, beginning with "BRT".
|
|
101
102
|
# @param options [Hash] parameters as a hash, under a params key.
|
|
102
103
|
def update(identity, options = {})
|
|
103
104
|
path = sub_url('/billing_request_templates/:identity', {
|
|
104
|
-
'identity' => identity
|
|
105
|
+
'identity' => identity,
|
|
105
106
|
})
|
|
106
107
|
|
|
107
108
|
params = options.delete(:params) || {}
|
|
@@ -123,7 +124,13 @@ module GoCardlessPro
|
|
|
123
124
|
#
|
|
124
125
|
# @param body [Hash]
|
|
125
126
|
def unenvelope_body(body)
|
|
126
|
-
body
|
|
127
|
+
if body.key?(envelope_key)
|
|
128
|
+
body[envelope_key]
|
|
129
|
+
elsif body.key?('data')
|
|
130
|
+
body['data']
|
|
131
|
+
else
|
|
132
|
+
body
|
|
133
|
+
end
|
|
127
134
|
end
|
|
128
135
|
|
|
129
136
|
# return the key which API responses will envelope data under
|
|
@@ -40,7 +40,13 @@ module GoCardlessPro
|
|
|
40
40
|
#
|
|
41
41
|
# @param body [Hash]
|
|
42
42
|
def unenvelope_body(body)
|
|
43
|
-
body
|
|
43
|
+
if body.key?(envelope_key)
|
|
44
|
+
body[envelope_key]
|
|
45
|
+
elsif body.key?('data')
|
|
46
|
+
body['data']
|
|
47
|
+
else
|
|
48
|
+
body
|
|
49
|
+
end
|
|
44
50
|
end
|
|
45
51
|
|
|
46
52
|
# return the key which API responses will envelope data under
|