Class: ModernTreasury::Resources::VirtualAccounts

Inherits:
Object
  • Object
show all
Defined in:
lib/modern_treasury/resources/virtual_accounts.rb,
sig/modern_treasury/resources/virtual_accounts.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ VirtualAccounts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of VirtualAccounts.

Parameters:



165
166
167
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 165

def initialize(client:)
  @client = client
end

Instance Method Details

#create(internal_account_id:, name:, account_details: nil, counterparty_id: nil, credit_ledger_account_id: nil, debit_ledger_account_id: nil, description: nil, external_id: nil, ledger_account: nil, ledger_account_id: nil, metadata: nil, routing_details: nil, virtual_account_setting_id: nil, request_options: {}) ⇒ ModernTreasury::Models::VirtualAccount

Some parameter documentations has been truncated, see Models::VirtualAccountCreateParams for more details.

create virtual_account

Parameters:

  • internal_account_id (String) —

    The ID of the internal account that this virtual account is associated with.

  • name (String) —

    The name of the virtual account.

  • account_details (Array<ModernTreasury::Models::VirtualAccountCreateParams::AccountDetail>) —

    An array of account detail objects.

  • counterparty_id (String) —

    The ID of the counterparty that the virtual account belongs to.

  • credit_ledger_account_id (String) —

    The ID of a credit normal ledger account. When money leaves the virtual account,

  • debit_ledger_account_id (String) —

    The ID of a debit normal ledger account. When money enters the virtual account,

  • description (String) —

    An optional description for internal use.

  • external_id (String, nil) —

    A user-defined identifier for the virtual account.

  • ledger_account (ModernTreasury::Models::LedgerAccountCreateRequest) —

    Specifies a ledger account object that will be created with the virtual account.

  • ledger_account_id (String) —

    The ledger account that you'd like to link to the virtual account.

  • metadata (Hash{Symbol=>String}) —

    Additional data represented as key-value pairs. Both the key and value must be s

  • routing_details (Array<ModernTreasury::Models::VirtualAccountCreateParams::RoutingDetail>) —

    An array of routing detail objects.

  • virtual_account_setting_id (String) —

    The ID of the virtual account setting used to allocate this virtual account.

  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 44

def create(params)
  parsed, options = ModernTreasury::VirtualAccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/virtual_accounts",
    body: parsed,
    model: ModernTreasury::VirtualAccount,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ ModernTreasury::Models::VirtualAccount

delete virtual_account

Parameters:

Returns:

See Also:



153
154
155
156
157
158
159
160
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 153

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["api/virtual_accounts/%1$s", id],
    model: ModernTreasury::VirtualAccount,
    options: params[:request_options]
  )
end

#list(after_cursor: nil, counterparty_id: nil, external_id: nil, internal_account_id: nil, metadata: nil, per_page: nil, request_options: {}) ⇒ ModernTreasury::Internal::Page<ModernTreasury::Models::VirtualAccount>

Some parameter documentations has been truncated, see Models::VirtualAccountListParams for more details.

Get a list of virtual accounts.

Parameters:

  • after_cursor (String, nil)
  • counterparty_id (String)
  • external_id (String) —

    Only return virtual accounts with this external ID.

  • internal_account_id (String)
  • metadata (Hash{Symbol=>String}) —

    For example, if you want to query for records with metadata key Type and value

  • per_page (Integer)
  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 129

def list(params = {})
  parsed, options = ModernTreasury::VirtualAccountListParams.dump_request(params)
  query = ModernTreasury::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/virtual_accounts",
    query: query,
    page: ModernTreasury::Internal::Page,
    model: ModernTreasury::VirtualAccount,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ ModernTreasury::Models::VirtualAccount

get virtual_account

Parameters:

Returns:

See Also:



66
67
68
69
70
71
72
73
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 66

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["api/virtual_accounts/%1$s", id],
    model: ModernTreasury::VirtualAccount,
    options: params[:request_options]
  )
end

#update(id, counterparty_id: nil, ledger_account_id: nil, metadata: nil, name: nil, request_options: {}) ⇒ ModernTreasury::Models::VirtualAccount

update virtual_account

Parameters:

  • id (String) —

    Virtual Acccount ID

  • counterparty_id (String)
  • ledger_account_id (String) —

    The ledger account that you'd like to link to the virtual account.

  • metadata (Hash{Symbol=>String})
  • name (String, nil)
  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 94

def update(id, params = {})
  parsed, options = ModernTreasury::VirtualAccountUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/virtual_accounts/%1$s", id],
    body: parsed,
    model: ModernTreasury::VirtualAccount,
    options: options
  )
end