Class: ModernTreasury::Resources::LedgerAccounts

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ LedgerAccounts

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 LedgerAccounts.

Parameters:



186
187
188
# File 'lib/modern_treasury/resources/ledger_accounts.rb', line 186

def initialize(client:)
  @client = client
end

Instance Method Details

#create(currency: , ledger_id: , name: , normal_balance: , currency_exponent: nil, description: nil, ledger_account_category_ids: nil, ledgerable_id: nil, ledgerable_type: nil, metadata: nil, request_options: {}) ⇒ ModernTreasury::Models::LedgerAccount

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

Create a ledger account.

Parameters:

  • currency (String)

    The currency of the ledger account.

  • ledger_id (String)

    The id of the ledger that this account belongs to.

  • name (String)

    The name of the ledger account.

  • normal_balance (Symbol, ModernTreasury::Models::TransactionDirection)

    The normal balance of the ledger account.

  • currency_exponent (Integer, nil)

    The currency exponent of the ledger account.

  • description (String, nil)

    The description of the ledger account.

  • ledger_account_category_ids (Array<String>)

    The array of ledger account category ids that this ledger account should be a ch

  • ledgerable_id (String)

    If the ledger account links to another object in Modern Treasury, the id will be

  • ledgerable_type (Symbol, ModernTreasury::Models::LedgerAccountCreateRequest::LedgerableType)

    If the ledger account links to another object in Modern Treasury, the type will

  • metadata (Hash{Symbol=>String})

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

  • 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/ledger_accounts.rb', line 38

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

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

Delete a ledger account.

Parameters:

Returns:

See Also:



174
175
176
177
178
179
180
181
# File 'lib/modern_treasury/resources/ledger_accounts.rb', line 174

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

#list(id: nil, after_cursor: nil, available_balance_amount: nil, balances: nil, created_at: nil, currency: nil, external_id: nil, ledger_account_category_id: nil, ledger_id: nil, metadata: nil, name: nil, normal_balance: nil, pending_balance_amount: nil, per_page: nil, posted_balance_amount: nil, updated_at: nil, request_options: {}) ⇒ ModernTreasury::Internal::Page<ModernTreasury::Models::LedgerAccount>

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

Get a list of ledger accounts.

Parameters:

Returns:

See Also:



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/modern_treasury/resources/ledger_accounts.rb', line 151

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

#retrieve(id, balances: nil, request_options: {}) ⇒ ModernTreasury::Models::LedgerAccount

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

Get details on a single ledger account.

Parameters:

Returns:

See Also:



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

def retrieve(id, params = {})
  parsed, options = ModernTreasury::LedgerAccountRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["api/ledger_accounts/%1$s", id],
    query: parsed,
    model: ModernTreasury::LedgerAccount,
    options: options
  )
end

#update(id, description: nil, metadata: nil, name: nil, request_options: {}) ⇒ ModernTreasury::Models::LedgerAccount

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

Update the details of a ledger account.

Parameters:

  • id (String)

    id

  • description (String, nil)

    The description of the ledger account.

  • metadata (Hash{Symbol=>String})

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

  • name (String)

    The name of the ledger account.

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

Returns:

See Also:



96
97
98
99
100
101
102
103
104
105
# File 'lib/modern_treasury/resources/ledger_accounts.rb', line 96

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