Class: ModernTreasury::Resources::VirtualAccounts

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

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:



156
157
158
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 156

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, ledger_account: nil, metadata: nil, routing_details: 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.

  • ledger_account (ModernTreasury::Models::LedgerAccountCreateRequest)

    Specifies a ledger account object that will be created with 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.

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

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 38

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:



144
145
146
147
148
149
150
151
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 144

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, 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)
  • 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:



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 121

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

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

get virtual_account

Parameters:

Returns:

See Also:



60
61
62
63
64
65
66
67
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 60

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:



88
89
90
91
92
93
94
95
96
97
# File 'lib/modern_treasury/resources/virtual_accounts.rb', line 88

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