Class: ModernTreasury::LedgerTransactionController
- Inherits:
-
BaseController
- Object
- BaseController
- ModernTreasury::LedgerTransactionController
- Defined in:
- lib/modern_treasury/controllers/ledger_transaction_controller.rb
Overview
LedgerTransactionController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_ledger_transaction(idempotency_key: nil, body: nil) ⇒ LedgerTransaction
Create a ledger transaction.
-
#create_ledger_transaction_reversal(id, body: nil) ⇒ LedgerTransaction
Create a ledger transaction reversal.
-
#get_ledger_transaction(id) ⇒ LedgerTransaction
Get details on a single ledger transaction.
-
#list_ledger_transaction_versions(per_page: nil, created_at: nil, version: nil, ledger_transaction_id: nil, ledger_account_statement_id: nil, after_cursor: nil) ⇒ Array[LedgerTransactionVersion]
Get a list of ledger transaction versions.
-
#list_ledger_transaction_versions1(id, after_cursor: nil, per_page: nil, created_at: nil, version: nil) ⇒ Array[LedgerTransactionVersion]
Get a list of ledger transaction versions.
-
#list_ledger_transactions(per_page: nil, id: nil, metadata: nil, ledger_id: nil, ledger_account_id: nil, effective_at: nil, effective_date: nil, posted_at: nil, updated_at: nil, order_by: nil, status: nil, external_id: nil, ledger_account_category_id: nil, ledger_account_payout_id: nil, reverses_ledger_transaction_id: nil, ledgerable_id: nil, ledgerable_type: nil, after_cursor: nil) ⇒ Array[LedgerTransaction]
Get a list of ledger transactions.
-
#update_ledger_transaction(id, body: nil) ⇒ LedgerTransaction
Update the details of a ledger transaction.
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_transaction(idempotency_key: nil, body: nil) ⇒ LedgerTransaction
Create a ledger transaction. something unique, preferably something like an UUID. type description here
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/modern_treasury/controllers/ledger_transaction_controller.rb', line 194 def create_ledger_transaction(idempotency_key: nil, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/ledger_transactions', 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(LedgerTransaction.method(:from_hash)) .local_error('403', 'forbidden', ErrorMessageException) .local_error('404', 'not found', ErrorMessageException) .local_error('422', 'unsuccessful', ErrorMessageException) .local_error('429', 'too many requests', ErrorMessageException)) .execute end |
#create_ledger_transaction_reversal(id, body: nil) ⇒ LedgerTransaction
Create a ledger transaction reversal. reverse. TODO: type description here
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/modern_treasury/controllers/ledger_transaction_controller.rb', line 15 def create_ledger_transaction_reversal(id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/ledger_transactions/{id}/reversal', 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(LedgerTransaction.method(:from_hash)) .local_error('404', 'not found', ErrorMessageException) .local_error('422', 'unsuccessful', ErrorMessageException)) .execute end |
#get_ledger_transaction(id) ⇒ LedgerTransaction
Get details on a single ledger transaction.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/modern_treasury/controllers/ledger_transaction_controller.rb', line 227 def get_ledger_transaction(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/ledger_transactions/{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(LedgerTransaction.method(:from_hash)) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#list_ledger_transaction_versions(per_page: nil, created_at: nil, version: nil, ledger_transaction_id: nil, ledger_account_statement_id: nil, after_cursor: nil) ⇒ Array[LedgerTransactionVersion]
Get a list of ledger transaction versions. here (>), ‘gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by the created_at timestamp. For example, for all dates 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 version. For example, for all versions after 2, use version%5Bgt%5D=2. ledger transaction versions corresponding to the ID of a ledger transaction. ledger transaction versions that are included in the ledger account statement. here
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/modern_treasury/controllers/ledger_transaction_controller.rb', line 59 def list_ledger_transaction_versions(per_page: nil, created_at: nil, version: nil, ledger_transaction_id: nil, ledger_account_statement_id: nil, after_cursor: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/ledger_transaction_versions', Server::DEFAULT) .query_param(new_parameter(per_page, key: 'per_page')) .query_param(new_parameter(created_at, key: 'created_at')) .query_param(new_parameter(version, key: 'version')) .query_param(new_parameter(ledger_transaction_id, key: 'ledger_transaction_id')) .query_param(new_parameter(ledger_account_statement_id, key: 'ledger_account_statement_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(LedgerTransactionVersion.method(:from_hash)) .is_response_array(true) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#list_ledger_transaction_versions1(id, after_cursor: nil, per_page: nil, created_at: nil, version: nil) ⇒ Array[LedgerTransactionVersion]
Get a list of ledger transaction versions. here here (>), ‘gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by the created_at timestamp. For example, for all dates 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 version. For example, for all versions after 2, use version%5Bgt%5D=2.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/modern_treasury/controllers/ledger_transaction_controller.rb', line 298 def list_ledger_transaction_versions1(id, after_cursor: nil, per_page: nil, created_at: nil, version: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/ledger_transactions/{id}/versions', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .query_param(new_parameter(after_cursor, key: 'after_cursor')) .query_param(new_parameter(per_page, key: 'per_page')) .query_param(new_parameter(created_at, key: 'created_at')) .query_param(new_parameter(version, key: 'version')) .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(LedgerTransactionVersion.method(:from_hash)) .is_response_array(true) .local_error('404', 'not found', ErrorMessageException) .local_error('422', 'unsuccessful', ErrorMessageException)) .execute end |
#list_ledger_transactions(per_page: nil, id: nil, metadata: nil, ledger_id: nil, ledger_account_id: nil, effective_at: nil, effective_date: nil, posted_at: nil, updated_at: nil, order_by: nil, status: nil, external_id: nil, ledger_account_category_id: nil, ledger_account_payout_id: nil, reverses_ledger_transaction_id: nil, ledgerable_id: nil, ledgerable_type: nil, after_cursor: nil) ⇒ Array[LedgerTransaction]
Get a list of ledger transactions. here description 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 description here (>), “gte” (>=), “lt” (<), “lte” (<=), or “eq” (=) to filter by effective at. For example, for all transactions after Jan 1 2000, use effective_at%5Bgt%5D=2000-01-01T00:00:00:00.000Z. `gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by effective date. For example, for all dates after Jan 1 2000, use effective_date%5Bgt%5D=2000-01-01. (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by the posted at timestamp. For example, for all times after Jan 1 2000 12:00 UTC, use posted_at%5Bgt%5D=2000-01-01T12:00:00Z. (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by the posted at timestamp. For example, for all times after Jan 1 2000 12:00 UTC, use updated_at%5Bgt%5D=2000-01-01T12:00:00Z. `effective_at` in `asc` or `desc` order. For example, to order by `effective_at asc`, use `order_by%5Beffective_at%5D=asc`. Ordering by only one field at a time is supported. here description here description here type description here here Example: here
136 137 138 139 140 141 142 143 144 145 146 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 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/modern_treasury/controllers/ledger_transaction_controller.rb', line 136 def list_ledger_transactions(per_page: nil, id: nil, metadata: nil, ledger_id: nil, ledger_account_id: nil, effective_at: nil, effective_date: nil, posted_at: nil, updated_at: nil, order_by: nil, status: nil, external_id: nil, ledger_account_category_id: nil, ledger_account_payout_id: nil, reverses_ledger_transaction_id: nil, ledgerable_id: nil, ledgerable_type: nil, after_cursor: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/ledger_transactions', Server::DEFAULT) .query_param(new_parameter(per_page, key: 'per_page')) .query_param(new_parameter(id, key: 'id')) .query_param(new_parameter(, key: 'metadata')) .query_param(new_parameter(ledger_id, key: 'ledger_id')) .query_param(new_parameter(ledger_account_id, key: 'ledger_account_id')) .query_param(new_parameter(effective_at, key: 'effective_at')) .query_param(new_parameter(effective_date, key: 'effective_date')) .query_param(new_parameter(posted_at, key: 'posted_at')) .query_param(new_parameter(updated_at, key: 'updated_at')) .query_param(new_parameter(order_by, key: 'order_by')) .query_param(new_parameter(status, key: 'status')) .query_param(new_parameter(external_id, key: 'external_id')) .query_param(new_parameter(ledger_account_category_id, key: 'ledger_account_category_id')) .query_param(new_parameter(ledger_account_payout_id, key: 'ledger_account_payout_id')) .query_param(new_parameter(reverses_ledger_transaction_id, key: 'reverses_ledger_transaction_id')) .query_param(new_parameter(ledgerable_id, key: 'ledgerable_id')) .query_param(new_parameter(ledgerable_type, key: 'ledgerable_type')) .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(LedgerTransaction.method(:from_hash)) .is_response_array(true) .local_error('422', 'parameter invalid', ErrorMessageException)) .execute end |
#update_ledger_transaction(id, body: nil) ⇒ LedgerTransaction
Update the details of a ledger transaction. type description here
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/modern_treasury/controllers/ledger_transaction_controller.rb', line 250 def update_ledger_transaction(id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/api/ledger_transactions/{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(LedgerTransaction.method(:from_hash)) .local_error('400', 'parameter_invalid', ErrorMessageException) .local_error('403', 'forbidden', ErrorMessageException) .local_error('404', 'not found', ErrorMessageException) .local_error('422', 'unsuccessful', ErrorMessageException) .local_error('429', 'too many requests', ErrorMessageException)) .execute end |