Class: ZaiPayment::Resources::BankAccount
- Inherits:
-
Object
- Object
- ZaiPayment::Resources::BankAccount
- Defined in:
- lib/zai_payment/resources/bank_account.rb
Overview
BankAccount resource for managing Zai bank accounts
Constant Summary collapse
- FIELD_MAPPING =
Map of attribute keys to API field names
{ user_id: :user_id, bank_name: :bank_name, account_name: :account_name, routing_number: :routing_number, account_number: :account_number, account_type: :account_type, holder_type: :holder_type, country: :country, payout_currency: :payout_currency, currency: :currency }.freeze
- UK_FIELD_MAPPING =
Map of UK-specific attribute keys to API field names
{ user_id: :user_id, bank_name: :bank_name, account_name: :account_name, routing_number: :routing_number, account_number: :account_number, account_type: :account_type, holder_type: :holder_type, country: :country, payout_currency: :payout_currency, currency: :currency, iban: :iban, swift_code: :swift_code }.freeze
- VALID_ACCOUNT_TYPES =
Valid account types
%w[savings checking].freeze
- VALID_HOLDER_TYPES =
Valid holder types
%w[personal business].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create_au(**attributes) ⇒ Response
Create a new bank account for Australia.
-
#create_uk(**attributes) ⇒ Response
Create a new bank account for UK.
-
#initialize(client: nil) ⇒ BankAccount
constructor
A new instance of BankAccount.
-
#redact(bank_account_id) ⇒ Response
Redact a bank account.
-
#show(bank_account_id, include_decrypted_fields: false) ⇒ Response
Get a specific bank account by ID.
-
#validate_routing_number(routing_number) ⇒ Response
Validate a US bank routing number.
Constructor Details
#initialize(client: nil) ⇒ BankAccount
Returns a new instance of BankAccount.
47 48 49 |
# File 'lib/zai_payment/resources/bank_account.rb', line 47 def initialize(client: nil) @client = client || Client.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/zai_payment/resources/bank_account.rb', line 9 def client @client end |
Instance Method Details
#create_au(**attributes) ⇒ Response
Create a new bank account for Australia
111 112 113 114 115 116 |
# File 'lib/zai_payment/resources/bank_account.rb', line 111 def create_au(**attributes) validate_create_au_attributes!(attributes) body = build_bank_account_body(attributes, :au) client.post('/bank_accounts', body: body) end |
#create_uk(**attributes) ⇒ Response
Create a new bank account for UK
156 157 158 159 160 161 |
# File 'lib/zai_payment/resources/bank_account.rb', line 156 def create_uk(**attributes) validate_create_uk_attributes!(attributes) body = build_bank_account_body(attributes, :uk) client.post('/bank_accounts', body: body) end |
#redact(bank_account_id) ⇒ Response
Redact a bank account
Redacts a bank account using the given bank_account_id. Redacted bank accounts can no longer be used as a funding source or a disbursement destination.
176 177 178 179 |
# File 'lib/zai_payment/resources/bank_account.rb', line 176 def redact(bank_account_id) validate_id!(bank_account_id, 'bank_account_id') client.delete("/bank_accounts/#{bank_account_id}") end |
#show(bank_account_id, include_decrypted_fields: false) ⇒ Response
Get a specific bank account by ID
68 69 70 71 72 73 74 75 |
# File 'lib/zai_payment/resources/bank_account.rb', line 68 def show(bank_account_id, include_decrypted_fields: false) validate_id!(bank_account_id, 'bank_account_id') params = {} params[:include_decrypted_fields] = include_decrypted_fields if include_decrypted_fields client.get("/bank_accounts/#{bank_account_id}", params: params) end |
#validate_routing_number(routing_number) ⇒ Response
Validate a US bank routing number
Validates a US bank routing number before creating an account. This can be used to provide on-demand verification and further information of the bank information a user is providing.
196 197 198 199 200 201 |
# File 'lib/zai_payment/resources/bank_account.rb', line 196 def validate_routing_number(routing_number) validate_presence!(routing_number, 'routing_number') params = { routing_number: routing_number } client.get('/tools/routing_number', params: params) end |