Class: ModernTreasury::LedgerAccountController

Inherits:
BaseController show all
Defined in:
lib/modern_treasury/controllers/ledger_account_controller.rb

Overview

LedgerAccountController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from ModernTreasury::BaseController

Instance Method Details

#create_ledger_account(idempotency_key: nil, body: nil) ⇒ LedgerAccount

Create a ledger account. something unique, preferably something like an UUID. description here

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (LedgerAccountCreateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/modern_treasury/controllers/ledger_account_controller.rb', line 84

def (idempotency_key: nil,
                          body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/ledger_accounts',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LedgerAccount.method(:from_hash))
                .local_error('403',
                             'forbidden',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#delete_ledger_account(id) ⇒ LedgerAccount

Delete a ledger account.

Parameters:

  • id (String)

    Required parameter: id

Returns:



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/modern_treasury/controllers/ledger_account_controller.rb', line 178

def (id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/api/ledger_accounts/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LedgerAccount.method(:from_hash))
                .local_error('403',
                             'forbidden',
                             ErrorMessageException)
                .local_error('404',
                             'not found',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#get_ledger_account(id, balances: nil) ⇒ LedgerAccount

Get details on a single ledger account. ‘balances` and `balances` to get the balances change between the two timestamps. The lower bound is inclusive while the upper bound is exclusive of the provided timestamps. If no value is supplied the balances will be retrieved not including that bound. Use `balances` to retrieve a balance as of a specific Ledger Account `lock_version`.

Parameters:

  • id (String)

    Required parameter: id

  • balances (Balances3) (defaults to: nil)

    Optional parameter: Use

Returns:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/modern_treasury/controllers/ledger_account_controller.rb', line 119

def (id,
                       balances: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/ledger_accounts/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .query_param(new_parameter(balances, key: 'balances'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LedgerAccount.method(:from_hash))
                .local_error('404',
                             'not found',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#list_ledger_accounts(per_page: nil, metadata: nil, id: nil, name: nil, ledger_id: nil, currency: nil, balances: nil, created_at: nil, updated_at: nil, ledger_account_category_id: nil, after_cursor: nil) ⇒ Array[LedgerAccount]

Get a list of ledger accounts. here you want to query for records with metadata key ‘Type` and value `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query parameters. here `balances` and `balances` to get the balances change between the two timestamps. The lower bound is inclusive while the upper bound is exclusive of the provided timestamps. If no value is supplied the balances will be retrieved not including that bound. (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by the created at timestamp. For example, for all times after Jan 1 2000 12:00 UTC, use created_at%5Bgt%5D=2000-01-01T12:00:00Z. (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by the updated at timestamp. For example, for all times after Jan 1 2000 12:00 UTC, use updated_at%5Bgt%5D=2000-01-01T12:00:00Z. description here here

Parameters:

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

  • metadata (Hash[String, String]) (defaults to: nil)

    Optional parameter: For example, if

  • id (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • name (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • ledger_id (String) (defaults to: nil)

    Optional parameter: TODO: type description

  • currency (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • balances (Balances2) (defaults to: nil)

    Optional parameter: Use

  • created_at (Hash[String, DateTime]) (defaults to: nil)

    Optional parameter: Use ‘gt`

  • updated_at (Hash[String, DateTime]) (defaults to: nil)

    Optional parameter: Use ‘gt`

  • ledger_account_category_id (String) (defaults to: nil)

    Optional parameter: TODO: type

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/modern_treasury/controllers/ledger_account_controller.rb', line 40

def list_ledger_accounts(per_page: nil,
                         metadata: nil,
                         id: nil,
                         name: nil,
                         ledger_id: nil,
                         currency: nil,
                         balances: nil,
                         created_at: nil,
                         updated_at: nil,
                         ledger_account_category_id: nil,
                         after_cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/ledger_accounts',
                                 Server::DEFAULT)
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(, key: 'metadata'))
               .query_param(new_parameter(id, key: 'id'))
               .query_param(new_parameter(name, key: 'name'))
               .query_param(new_parameter(ledger_id, key: 'ledger_id'))
               .query_param(new_parameter(currency, key: 'currency'))
               .query_param(new_parameter(balances, key: 'balances'))
               .query_param(new_parameter(created_at, key: 'created_at'))
               .query_param(new_parameter(updated_at, key: 'updated_at'))
               .query_param(new_parameter(, key: 'ledger_account_category_id'))
               .query_param(new_parameter(after_cursor, key: 'after_cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LedgerAccount.method(:from_hash))
                .is_response_array(true)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#update_ledger_account(id, body: nil) ⇒ LedgerAccount

Update the details of a ledger account. description here

Parameters:

Returns:



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/modern_treasury/controllers/ledger_account_controller.rb', line 147

def (id,
                          body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/api/ledger_accounts/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LedgerAccount.method(:from_hash))
                .local_error('403',
                             'forbidden',
                             ErrorMessageException)
                .local_error('404',
                             'not found',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end