gocardless_pro 4.1.0 → 4.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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -12
  3. data/lib/gocardless_pro/client.rb +23 -3
  4. data/lib/gocardless_pro/error.rb +3 -3
  5. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +11 -3
  6. data/lib/gocardless_pro/paginator.rb +3 -2
  7. data/lib/gocardless_pro/resources/balance.rb +4 -1
  8. data/lib/gocardless_pro/resources/bank_account_detail.rb +5 -1
  9. data/lib/gocardless_pro/resources/bank_account_holder_verification.rb +44 -0
  10. data/lib/gocardless_pro/resources/bank_authorisation.rb +9 -2
  11. data/lib/gocardless_pro/resources/bank_details_lookup.rb +3 -1
  12. data/lib/gocardless_pro/resources/billing_request.rb +17 -2
  13. data/lib/gocardless_pro/resources/billing_request_flow.rb +18 -2
  14. data/lib/gocardless_pro/resources/billing_request_template.rb +18 -2
  15. data/lib/gocardless_pro/resources/billing_request_with_action.rb +2 -1
  16. data/lib/gocardless_pro/resources/block.rb +8 -2
  17. data/lib/gocardless_pro/resources/creditor.rb +20 -2
  18. data/lib/gocardless_pro/resources/creditor_bank_account.rb +11 -2
  19. data/lib/gocardless_pro/resources/currency_exchange_rate.rb +4 -1
  20. data/lib/gocardless_pro/resources/customer.rb +18 -2
  21. data/lib/gocardless_pro/resources/customer_bank_account.rb +11 -2
  22. data/lib/gocardless_pro/resources/customer_notification.rb +5 -1
  23. data/lib/gocardless_pro/resources/event.rb +19 -3
  24. data/lib/gocardless_pro/resources/export.rb +5 -1
  25. data/lib/gocardless_pro/resources/funds_availability.rb +38 -0
  26. data/lib/gocardless_pro/resources/instalment_schedule.rb +8 -1
  27. data/lib/gocardless_pro/resources/institution.rb +8 -1
  28. data/lib/gocardless_pro/resources/mandate.rb +14 -2
  29. data/lib/gocardless_pro/resources/mandate_import.rb +4 -1
  30. data/lib/gocardless_pro/resources/mandate_import_entry.rb +3 -1
  31. data/lib/gocardless_pro/resources/mandate_pdf.rb +2 -1
  32. data/lib/gocardless_pro/resources/negative_balance_limit.rb +4 -1
  33. data/lib/gocardless_pro/resources/outbound_payment.rb +23 -9
  34. data/lib/gocardless_pro/resources/payer_authorisation.rb +7 -1
  35. data/lib/gocardless_pro/resources/payment.rb +15 -2
  36. data/lib/gocardless_pro/resources/payment_account.rb +63 -0
  37. data/lib/gocardless_pro/resources/payment_account_transaction.rb +78 -0
  38. data/lib/gocardless_pro/resources/payout.rb +12 -2
  39. data/lib/gocardless_pro/resources/payout_item.rb +3 -1
  40. data/lib/gocardless_pro/resources/redirect_flow.rb +10 -2
  41. data/lib/gocardless_pro/resources/refund.rb +8 -1
  42. data/lib/gocardless_pro/resources/scheme_identifier.rb +18 -2
  43. data/lib/gocardless_pro/resources/subscription.rb +20 -2
  44. data/lib/gocardless_pro/resources/tax_rate.rb +6 -1
  45. data/lib/gocardless_pro/resources/transferred_mandate.rb +3 -1
  46. data/lib/gocardless_pro/resources/verification_detail.rb +9 -2
  47. data/lib/gocardless_pro/resources/webhook.rb +13 -2
  48. data/lib/gocardless_pro/services/bank_account_details_service.rb +7 -2
  49. data/lib/gocardless_pro/services/bank_account_holder_verifications_service.rb +86 -0
  50. data/lib/gocardless_pro/services/bank_authorisations_service.rb +2 -2
  51. data/lib/gocardless_pro/services/billing_request_flows_service.rb +1 -1
  52. data/lib/gocardless_pro/services/billing_request_templates_service.rb +4 -4
  53. data/lib/gocardless_pro/services/billing_requests_service.rb +20 -20
  54. data/lib/gocardless_pro/services/blocks_service.rb +7 -7
  55. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +4 -4
  56. data/lib/gocardless_pro/services/creditors_service.rb +3 -3
  57. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +5 -5
  58. data/lib/gocardless_pro/services/customer_notifications_service.rb +1 -1
  59. data/lib/gocardless_pro/services/customers_service.rb +4 -4
  60. data/lib/gocardless_pro/services/events_service.rb +1 -1
  61. data/lib/gocardless_pro/services/exports_service.rb +1 -1
  62. data/lib/gocardless_pro/services/funds_availabilities_service.rb +50 -0
  63. data/lib/gocardless_pro/services/instalment_schedules_service.rb +6 -6
  64. data/lib/gocardless_pro/services/institutions_service.rb +1 -1
  65. data/lib/gocardless_pro/services/mandate_imports_service.rb +6 -6
  66. data/lib/gocardless_pro/services/mandates_service.rb +7 -7
  67. data/lib/gocardless_pro/services/negative_balance_limits_service.rb +0 -21
  68. data/lib/gocardless_pro/services/outbound_payments_service.rb +23 -8
  69. data/lib/gocardless_pro/services/payer_authorisations_service.rb +7 -7
  70. data/lib/gocardless_pro/services/payment_account_transactions_service.rb +66 -0
  71. data/lib/gocardless_pro/services/payment_accounts_service.rb +76 -0
  72. data/lib/gocardless_pro/services/payments_service.rb +7 -7
  73. data/lib/gocardless_pro/services/payouts_service.rb +2 -2
  74. data/lib/gocardless_pro/services/redirect_flows_service.rb +4 -4
  75. data/lib/gocardless_pro/services/refunds_service.rb +3 -3
  76. data/lib/gocardless_pro/services/scenario_simulators_service.rb +10 -4
  77. data/lib/gocardless_pro/services/scheme_identifiers_service.rb +2 -2
  78. data/lib/gocardless_pro/services/subscriptions_service.rb +9 -9
  79. data/lib/gocardless_pro/services/tax_rates_service.rb +1 -1
  80. data/lib/gocardless_pro/services/transferred_mandates_service.rb +1 -1
  81. data/lib/gocardless_pro/services/webhooks_service.rb +3 -3
  82. data/lib/gocardless_pro/version.rb +1 -1
  83. data/lib/gocardless_pro.rb +12 -0
  84. metadata +33 -11
@@ -16,8 +16,20 @@ module GoCardlessPro
16
16
  # GoCardless will notify you via a [webhook](#appendix-webhooks) whenever
17
17
  # the status of a mandate changes.
18
18
  class Mandate
19
- attr_reader :authorisation_source, :consent_parameters, :consent_type, :created_at, :funds_settlement, :id,
20
- :metadata, :next_possible_charge_date, :next_possible_standard_ach_charge_date, :payments_require_approval, :reference, :scheme, :status, :verified_at
19
+ attr_reader :authorisation_source
20
+ attr_reader :consent_parameters
21
+ attr_reader :consent_type
22
+ attr_reader :created_at
23
+ attr_reader :funds_settlement
24
+ attr_reader :id
25
+ attr_reader :metadata
26
+ attr_reader :next_possible_charge_date
27
+ attr_reader :next_possible_standard_ach_charge_date
28
+ attr_reader :payments_require_approval
29
+ attr_reader :reference
30
+ attr_reader :scheme
31
+ attr_reader :status
32
+ attr_reader :verified_at
21
33
 
22
34
  # Initialize a mandate resource instance
23
35
  # @param object [Hash] an object returned from the API
@@ -53,7 +53,10 @@ module GoCardlessPro
53
53
  # href="mailto:help@gocardless.com">get in touch</a> if you would like to
54
54
  # use this API.</p>
55
55
  class MandateImport
56
- attr_reader :created_at, :id, :scheme, :status
56
+ attr_reader :created_at
57
+ attr_reader :id
58
+ attr_reader :scheme
59
+ attr_reader :status
57
60
 
58
61
  # Initialize a mandate_import resource instance
59
62
  # @param object [Hash] an object returned from the API
@@ -41,7 +41,9 @@ 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, :processing_errors, :record_identifier
44
+ attr_reader :created_at
45
+ attr_reader :processing_errors
46
+ attr_reader :record_identifier
45
47
 
46
48
  # Initialize a mandate_import_entry resource instance
47
49
  # @param object [Hash] an object returned from the API
@@ -14,7 +14,8 @@ module GoCardlessPro
14
14
  # compliant](#appendix-compliance-requirements) Direct Debit mandates to
15
15
  # your customers.
16
16
  class MandatePdf
17
- attr_reader :expires_at, :url
17
+ attr_reader :expires_at
18
+ attr_reader :url
18
19
 
19
20
  # Initialize a mandate_pdf resource instance
20
21
  # @param object [Hash] an object returned from the API
@@ -16,7 +16,10 @@ module GoCardlessPro
16
16
  # changed on a per-creditor basis.
17
17
  #
18
18
  class NegativeBalanceLimit
19
- attr_reader :balance_limit, :created_at, :currency, :id
19
+ attr_reader :balance_limit
20
+ attr_reader :created_at
21
+ attr_reader :currency
22
+ attr_reader :id
20
23
 
21
24
  # Initialize a negative_balance_limit resource instance
22
25
  # @param object [Hash] an object returned from the API
@@ -14,17 +14,31 @@ module GoCardlessPro
14
14
  # [creditors](#core-endpoints-creditors).
15
15
  #
16
16
  # GoCardless will notify you via a [webhook](#appendix-webhooks) when the
17
- # status of the outbound payment [changes](#event-actions-outbound-payment).
17
+ # status of the outbound payment [changes](#event-types-outbound-payment).
18
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>
19
+ # ####Rate limiting
20
+ #
21
+ # Two rate limits apply to the Outbound Payments APIs:
22
+ # - All POST Outbound Payment endpoints (create, withdraw, approve, cancel
23
+ # and etc.) share a single rate-limit group of 300 requests per minute. As
24
+ # initiating a payment typically requires two API calls (one to create the
25
+ # payment and one to approve it), this allows you to add approximately 150
26
+ # outbound payments per minute.
27
+ # - All remaining Outbound Payment endpoints are limited to 500 requests per
28
+ # minute.
25
29
  class OutboundPayment
26
- attr_reader :amount, :created_at, :currency, :description, :execution_date, :id, :is_withdrawal, :metadata,
27
- :reference, :scheme, :status, :verifications
30
+ attr_reader :amount
31
+ attr_reader :created_at
32
+ attr_reader :currency
33
+ attr_reader :description
34
+ attr_reader :execution_date
35
+ attr_reader :id
36
+ attr_reader :is_withdrawal
37
+ attr_reader :metadata
38
+ attr_reader :reference
39
+ attr_reader :scheme
40
+ attr_reader :status
41
+ attr_reader :verifications
28
42
 
29
43
  # Initialize a outbound_payment resource instance
30
44
  # @param object [Hash] an object returned from the API
@@ -69,7 +69,13 @@ module GoCardlessPro
69
69
  # your servers.
70
70
  # </p>
71
71
  class PayerAuthorisation
72
- attr_reader :bank_account, :created_at, :customer, :id, :incomplete_fields, :mandate, :status
72
+ attr_reader :bank_account
73
+ attr_reader :created_at
74
+ attr_reader :customer
75
+ attr_reader :id
76
+ attr_reader :incomplete_fields
77
+ attr_reader :mandate
78
+ attr_reader :status
73
79
 
74
80
  # Initialize a payer_authorisation resource instance
75
81
  # @param object [Hash] an object returned from the API
@@ -18,8 +18,20 @@ module GoCardlessPro
18
18
  # GoCardless will notify you via a [webhook](#appendix-webhooks) whenever
19
19
  # the state of a payment changes.
20
20
  class Payment
21
- attr_reader :amount, :amount_refunded, :charge_date, :created_at, :currency, :description, :faster_ach, :fx, :id,
22
- :metadata, :reference, :retry_if_possible, :status
21
+ attr_reader :amount
22
+ attr_reader :amount_refunded
23
+ attr_reader :charge_date
24
+ attr_reader :created_at
25
+ attr_reader :currency
26
+ attr_reader :description
27
+ attr_reader :faster_ach
28
+ attr_reader :fx
29
+ attr_reader :id
30
+ attr_reader :metadata
31
+ attr_reader :reference
32
+ attr_reader :retry_if_possible
33
+ attr_reader :scheme
34
+ attr_reader :status
23
35
 
24
36
  # Initialize a payment resource instance
25
37
  # @param object [Hash] an object returned from the API
@@ -39,6 +51,7 @@ module GoCardlessPro
39
51
  @metadata = object['metadata']
40
52
  @reference = object['reference']
41
53
  @retry_if_possible = object['retry_if_possible']
54
+ @scheme = object['scheme']
42
55
  @status = object['status']
43
56
  @response = response
44
57
  end
@@ -0,0 +1,63 @@
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 payment_account resource returned from the API
12
+
13
+ # Access the details of bank accounts provided for you by GoCardless that
14
+ # are used to fund [Outbound Payments](#core-endpoints-outbound-payments).
15
+ class PaymentAccount
16
+ attr_reader :account_balance
17
+ attr_reader :account_holder_name
18
+ attr_reader :account_number_ending
19
+ attr_reader :bank_name
20
+ attr_reader :currency
21
+ attr_reader :id
22
+
23
+ # Initialize a payment_account resource instance
24
+ # @param object [Hash] an object returned from the API
25
+ def initialize(object, response = nil)
26
+ @object = object
27
+
28
+ @account_balance = object['account_balance']
29
+ @account_holder_name = object['account_holder_name']
30
+ @account_number_ending = object['account_number_ending']
31
+ @bank_name = object['bank_name']
32
+ @currency = object['currency']
33
+ @id = object['id']
34
+ @links = object['links']
35
+ @response = response
36
+ end
37
+
38
+ def api_response
39
+ ApiResponse.new(@response)
40
+ end
41
+
42
+ # Return the links that the resource has
43
+ def links
44
+ @payment_account_links ||= Links.new(@links)
45
+ end
46
+
47
+ # Provides the payment_account resource as a hash of all its readable attributes
48
+ def to_h
49
+ @object
50
+ end
51
+
52
+ class Links
53
+ def initialize(links)
54
+ @links = links || {}
55
+ end
56
+
57
+ def creditor
58
+ @links['creditor']
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,78 @@
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 payment_account_transaction resource returned from the API
12
+
13
+ # Payment account transactions represent movements of funds on a given
14
+ # payment account. The payment account is provisioned by GoCardless and is
15
+ # used to fund [outbound payments](#core-endpoints-outbound-payments).
16
+ class PaymentAccountTransaction
17
+ attr_reader :amount
18
+ attr_reader :balance_after_transaction
19
+ attr_reader :counterparty_name
20
+ attr_reader :currency
21
+ attr_reader :description
22
+ attr_reader :direction
23
+ attr_reader :id
24
+ attr_reader :reference
25
+ attr_reader :value_date
26
+
27
+ # Initialize a payment_account_transaction resource instance
28
+ # @param object [Hash] an object returned from the API
29
+ def initialize(object, response = nil)
30
+ @object = object
31
+
32
+ @amount = object['amount']
33
+ @balance_after_transaction = object['balance_after_transaction']
34
+ @counterparty_name = object['counterparty_name']
35
+ @currency = object['currency']
36
+ @description = object['description']
37
+ @direction = object['direction']
38
+ @id = object['id']
39
+ @links = object['links']
40
+ @reference = object['reference']
41
+ @value_date = object['value_date']
42
+ @response = response
43
+ end
44
+
45
+ def api_response
46
+ ApiResponse.new(@response)
47
+ end
48
+
49
+ # Return the links that the resource has
50
+ def links
51
+ @payment_account_transaction_links ||= Links.new(@links)
52
+ end
53
+
54
+ # Provides the payment_account_transaction resource as a hash of all its readable attributes
55
+ def to_h
56
+ @object
57
+ end
58
+
59
+ class Links
60
+ def initialize(links)
61
+ @links = links || {}
62
+ end
63
+
64
+ def outbound_payment
65
+ @links['outbound_payment']
66
+ end
67
+
68
+ def payment_bank_account
69
+ @links['payment_bank_account']
70
+ end
71
+
72
+ def payout
73
+ @links['payout']
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -17,8 +17,18 @@ module GoCardlessPro
17
17
  # Payouts are created automatically after a payment has been successfully
18
18
  # collected.
19
19
  class Payout
20
- attr_reader :amount, :arrival_date, :created_at, :currency, :deducted_fees, :fx, :id, :metadata, :payout_type,
21
- :reference, :status, :tax_currency
20
+ attr_reader :amount
21
+ attr_reader :arrival_date
22
+ attr_reader :created_at
23
+ attr_reader :currency
24
+ attr_reader :deducted_fees
25
+ attr_reader :fx
26
+ attr_reader :id
27
+ attr_reader :metadata
28
+ attr_reader :payout_type
29
+ attr_reader :reference
30
+ attr_reader :status
31
+ attr_reader :tax_currency
22
32
 
23
33
  # Initialize a payout resource instance
24
34
  # @param object [Hash] an object returned from the API
@@ -33,7 +33,9 @@ module GoCardlessPro
33
33
  # <code>410 Gone</code>.
34
34
  #
35
35
  class PayoutItem
36
- attr_reader :amount, :taxes, :type
36
+ attr_reader :amount
37
+ attr_reader :taxes
38
+ attr_reader :type
37
39
 
38
40
  # Initialize a payout_item resource instance
39
41
  # @param object [Hash] an object returned from the API
@@ -49,8 +49,16 @@ module GoCardlessPro
49
49
  # complete an expired redirect flow. For an integrator this is shorter and
50
50
  # they will expire after 10 minutes.
51
51
  class RedirectFlow
52
- attr_reader :confirmation_url, :created_at, :description, :id, :mandate_reference, :metadata, :redirect_url,
53
- :scheme, :session_token, :success_redirect_url
52
+ attr_reader :confirmation_url
53
+ attr_reader :created_at
54
+ attr_reader :description
55
+ attr_reader :id
56
+ attr_reader :mandate_reference
57
+ attr_reader :metadata
58
+ attr_reader :redirect_url
59
+ attr_reader :scheme
60
+ attr_reader :session_token
61
+ attr_reader :success_redirect_url
54
62
 
55
63
  # Initialize a redirect_flow resource instance
56
64
  # @param object [Hash] an object returned from the API
@@ -18,7 +18,14 @@ module GoCardlessPro
18
18
  # refund is created, and will update the `amount_refunded` property of the
19
19
  # payment.
20
20
  class Refund
21
- attr_reader :amount, :created_at, :currency, :fx, :id, :metadata, :reference, :status
21
+ attr_reader :amount
22
+ attr_reader :created_at
23
+ attr_reader :currency
24
+ attr_reader :fx
25
+ attr_reader :id
26
+ attr_reader :metadata
27
+ attr_reader :reference
28
+ attr_reader :status
22
29
 
23
30
  # Initialize a refund resource instance
24
31
  # @param object [Hash] an object returned from the API
@@ -15,8 +15,24 @@ module GoCardlessPro
15
15
  # on customers' bank statements.
16
16
  #
17
17
  class SchemeIdentifier
18
- attr_reader :address_line1, :address_line2, :address_line3, :can_specify_mandate_reference, :city, :country_code,
19
- :created_at, :currency, :email, :id, :minimum_advance_notice, :name, :phone_number, :postal_code, :reference, :region, :scheme, :status
18
+ attr_reader :address_line1
19
+ attr_reader :address_line2
20
+ attr_reader :address_line3
21
+ attr_reader :can_specify_mandate_reference
22
+ attr_reader :city
23
+ attr_reader :country_code
24
+ attr_reader :created_at
25
+ attr_reader :currency
26
+ attr_reader :email
27
+ attr_reader :id
28
+ attr_reader :minimum_advance_notice
29
+ attr_reader :name
30
+ attr_reader :phone_number
31
+ attr_reader :postal_code
32
+ attr_reader :reference
33
+ attr_reader :region
34
+ attr_reader :scheme
35
+ attr_reader :status
20
36
 
21
37
  # Initialize a scheme_identifier resource instance
22
38
  # @param object [Hash] an object returned from the API
@@ -68,8 +68,26 @@ module GoCardlessPro
68
68
  # - otherwise the charge date will be rolled __forwards__ to the next
69
69
  # business day.
70
70
  class Subscription
71
- attr_reader :amount, :app_fee, :count, :created_at, :currency, :day_of_month, :earliest_charge_date_after_resume,
72
- :end_date, :id, :interval, :interval_unit, :metadata, :month, :name, :parent_plan_paused, :payment_reference, :retry_if_possible, :start_date, :status, :upcoming_payments
71
+ attr_reader :amount
72
+ attr_reader :app_fee
73
+ attr_reader :count
74
+ attr_reader :created_at
75
+ attr_reader :currency
76
+ attr_reader :day_of_month
77
+ attr_reader :earliest_charge_date_after_resume
78
+ attr_reader :end_date
79
+ attr_reader :id
80
+ attr_reader :interval
81
+ attr_reader :interval_unit
82
+ attr_reader :metadata
83
+ attr_reader :month
84
+ attr_reader :name
85
+ attr_reader :parent_plan_paused
86
+ attr_reader :payment_reference
87
+ attr_reader :retry_if_possible
88
+ attr_reader :start_date
89
+ attr_reader :status
90
+ attr_reader :upcoming_payments
73
91
 
74
92
  # Initialize a subscription resource instance
75
93
  # @param object [Hash] an object returned from the API
@@ -15,7 +15,12 @@ module GoCardlessPro
15
15
  # We also maintain a [static list of the tax rates for each
16
16
  # jurisdiction](#appendix-tax-rates).
17
17
  class TaxRate
18
- attr_reader :end_date, :id, :jurisdiction, :percentage, :start_date, :type
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, :encrypted_decryption_key, :public_key_id
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
@@ -22,8 +22,15 @@ module GoCardlessPro
22
22
  # your
23
23
  # account.</p>
24
24
  class VerificationDetail
25
- attr_reader :address_line1, :address_line2, :address_line3, :city, :company_number, :description, :directors,
26
- :name, :postal_code
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 :description
31
+ attr_reader :directors
32
+ attr_reader :name
33
+ attr_reader :postal_code
27
34
 
28
35
  # Initialize a verification_detail resource instance
29
36
  # @param object [Hash] an object returned from the API
@@ -12,8 +12,19 @@ module GoCardlessPro
12
12
 
13
13
  # Basic description of a webhook
14
14
  class Webhook
15
- attr_reader :created_at, :id, :is_test, :request_body, :request_headers, :response_body,
16
- :response_body_truncated, :response_code, :response_headers, :response_headers_content_truncated, :response_headers_count_truncated, :successful, :url
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
@@ -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
17
+ # Key
18
+ # Setup](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
@@ -0,0 +1,86 @@
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
+ body[envelope_key] || body['data']
78
+ end
79
+
80
+ # return the key which API responses will envelope data under
81
+ def envelope_key
82
+ 'bank_account_holder_verifications'
83
+ end
84
+ end
85
+ end
86
+ 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, e.error
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
@@ -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) || {}