Class: ModernTreasury::Resources::LedgerAccountCategories

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ LedgerAccountCategories

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

Parameters:



280
281
282
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 280

def initialize(client:)
  @client = client
end

Instance Method Details

#add_ledger_account(ledger_account_id, id: , request_options: {}) ⇒ nil

Add a ledger account to a ledger account category.

Parameters:

Returns:

  • (nil)

See Also:



182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 182

def (, params)
  parsed, options = ModernTreasury::LedgerAccountCategoryAddLedgerAccountParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["api/ledger_account_categories/%1$s/ledger_accounts/%2$s", id, ],
    model: NilClass,
    options: options
  )
end

#add_nested_category(sub_category_id, id: , request_options: {}) ⇒ nil

Add a ledger account category to a ledger account category.

Parameters:

Returns:

  • (nil)

See Also:



209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 209

def add_nested_category(sub_category_id, params)
  parsed, options = ModernTreasury::LedgerAccountCategoryAddNestedCategoryParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["api/ledger_account_categories/%1$s/ledger_account_categories/%2$s", id, sub_category_id],
    model: NilClass,
    options: options
  )
end

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

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

Create a ledger account category.

Parameters:

  • currency (String)

    The currency of the ledger account category.

  • ledger_id (String)

    The id of the ledger that this account category belongs to.

  • name (String)

    The name of the ledger account category.

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

    The normal balance of the ledger account category.

  • currency_exponent (Integer, nil)

    The currency exponent of the ledger account category.

  • description (String, nil)

    The description of the ledger account category.

  • ledger_account_category_ids (Array<String>)

    The array of ledger account category ids that this ledger account category shoul

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



34
35
36
37
38
39
40
41
42
43
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 34

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

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

Delete a ledger account category.

Parameters:

Returns:

See Also:



160
161
162
163
164
165
166
167
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 160

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

#list(id: nil, after_cursor: nil, balances: nil, currency: nil, external_id: nil, ledger_account_id: nil, ledger_id: nil, metadata: nil, name: nil, parent_ledger_account_category_id: nil, per_page: nil, request_options: {}) ⇒ ModernTreasury::Internal::Page<ModernTreasury::Models::LedgerAccountCategory>

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

Get a list of ledger account categories.

Parameters:

  • id (Array<String>)

    If you have specific IDs to retrieve in bulk, you can pass them as query paramet

  • after_cursor (String, nil)
  • balances (ModernTreasury::Models::LedgerAccountCategoryListParams::Balances)

    For example, if you want the balances as of a particular time (ISO8601), the enc

  • currency (String)
  • external_id (String)
  • ledger_account_id (String)

    Query categories which contain a ledger account directly or through child catego

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

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

  • name (Array<String>)

    If you have specific names to retrieve in bulk, you can pass them as query param

  • parent_ledger_account_category_id (String)

    Query categories that are nested underneath a parent category

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

Returns:

See Also:



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 137

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

#remove_ledger_account(ledger_account_id, id: , request_options: {}) ⇒ nil

Remove a ledger account from a ledger account category.

Parameters:

Returns:

  • (nil)

See Also:



236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 236

def (, params)
  parsed, options = ModernTreasury::LedgerAccountCategoryRemoveLedgerAccountParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/ledger_account_categories/%1$s/ledger_accounts/%2$s", id, ],
    model: NilClass,
    options: options
  )
end

#remove_nested_category(sub_category_id, id: , request_options: {}) ⇒ nil

Delete a ledger account category from a ledger account category.

Parameters:

Returns:

  • (nil)

See Also:



263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 263

def remove_nested_category(sub_category_id, params)
  parsed, options = ModernTreasury::LedgerAccountCategoryRemoveNestedCategoryParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/ledger_account_categories/%1$s/ledger_account_categories/%2$s", id, sub_category_id],
    model: NilClass,
    options: options
  )
end

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

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

Get the details on a single ledger account category.

Parameters:

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 61

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

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

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

Update the details of a ledger account category.

Parameters:

  • id (String)

    id

  • description (String, nil)

    The description of the ledger account category.

  • 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 category.

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

Returns:

See Also:



92
93
94
95
96
97
98
99
100
101
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 92

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