Class: ZaiPayment::Resources::VirtualAccount
- Inherits:
-
Object
- Object
- ZaiPayment::Resources::VirtualAccount
- Defined in:
- lib/zai_payment/resources/virtual_account.rb
Overview
VirtualAccount resource for managing Zai virtual accounts
Constant Summary collapse
- CREATE_FIELD_MAPPING =
Map of attribute keys to API field names for create
{ account_name: :account_name, aka_names: :aka_names }.freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(wallet_account_id, **attributes) ⇒ Response
Create a Virtual Account for a given Wallet Account.
-
#initialize(client: nil) ⇒ VirtualAccount
constructor
A new instance of VirtualAccount.
-
#list(wallet_account_id) ⇒ Response
List Virtual Accounts for a given Wallet Account.
-
#show(virtual_account_id) ⇒ Response
Show a specific Virtual Account.
-
#update_account_name(virtual_account_id, account_name) ⇒ Response
Update Account Name for a Virtual Account.
-
#update_aka_names(virtual_account_id, aka_names) ⇒ Response
Update AKA Names for a Virtual Account.
-
#update_status(virtual_account_id, status) ⇒ Response
Update Status for a Virtual Account.
Constructor Details
#initialize(client: nil) ⇒ VirtualAccount
17 18 19 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 17 def initialize(client: nil) @client = client || Client.new(base_endpoint: :va_base) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 9 def client @client end |
Instance Method Details
#create(wallet_account_id, **attributes) ⇒ Response
Create a Virtual Account for a given Wallet Account
72 73 74 75 76 77 78 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 72 def create(wallet_account_id, **attributes) validate_id!(wallet_account_id, 'wallet_account_id') validate_create_attributes!(attributes) body = build_create_body(attributes) client.post("/wallet_accounts/#{wallet_account_id}/virtual_accounts", body: body) end |
#list(wallet_account_id) ⇒ Response
List Virtual Accounts for a given Wallet Account
33 34 35 36 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 33 def list(wallet_account_id) validate_id!(wallet_account_id, 'wallet_account_id') client.get("/wallet_accounts/#{wallet_account_id}/virtual_accounts") end |
#show(virtual_account_id) ⇒ Response
Show a specific Virtual Account
49 50 51 52 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 49 def show(virtual_account_id) validate_id!(virtual_account_id, 'virtual_account_id') client.get("/virtual_accounts/#{virtual_account_id}") end |
#update_account_name(virtual_account_id, account_name) ⇒ Response
Update Account Name for a Virtual Account
Change the name of a Virtual Account. This is used in CoP lookups.
123 124 125 126 127 128 129 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 123 def update_account_name(virtual_account_id, account_name) validate_id!(virtual_account_id, 'virtual_account_id') validate_account_name!(account_name) body = { account_name: account_name } client.patch("/virtual_accounts/#{virtual_account_id}/account_name", body: body) end |
#update_aka_names(virtual_account_id, aka_names) ⇒ Response
Update AKA Names for a Virtual Account
Replace the list of AKA Names for a Virtual Account. This completely replaces the existing AKA names with the new list provided.
98 99 100 101 102 103 104 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 98 def update_aka_names(virtual_account_id, aka_names) validate_id!(virtual_account_id, 'virtual_account_id') validate_aka_names!(aka_names) body = { aka_names: aka_names } client.patch("/virtual_accounts/#{virtual_account_id}/aka_names", body: body) end |
#update_status(virtual_account_id, status) ⇒ Response
Update Status for a Virtual Account
Close a Virtual Account. Once closed, the account cannot be reopened and will no longer be able to receive payments. This operation is asynchronous and returns a 202 Accepted response.
150 151 152 153 154 155 156 |
# File 'lib/zai_payment/resources/virtual_account.rb', line 150 def update_status(virtual_account_id, status) validate_id!(virtual_account_id, 'virtual_account_id') validate_status!(status) body = { status: status } client.patch("/virtual_accounts/#{virtual_account_id}/status", body: body) end |