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:



286
287
288
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 286

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:



188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 188

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:



215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 215

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, external_id: 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.

  • external_id (String, nil)

    An optional user-defined 180 character unique identifier.

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



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

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:



166
167
168
169
170
171
172
173
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 166

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 (String)
  • 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:



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 142

def list(params = {})
  parsed, options = ModernTreasury::LedgerAccountCategoryListParams.dump_request(params)
  query = ModernTreasury::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/ledger_account_categories",
    query: query,
    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:



242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 242

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:



269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/modern_treasury/resources/ledger_account_categories.rb', line 269

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:



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

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

#update(id, description: nil, external_id: 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.

  • external_id (String, nil)

    An optional user-defined 180 character unique identifier.

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



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

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