Class: ModernTreasury::LedgerAccountStatementController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/modern_treasury/controllers/ledger_account_statement_controller.rb

Overview

LedgerAccountStatementController

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, user_agent_parameters

Constructor Details

This class inherits a constructor from ModernTreasury::BaseController

Instance Method Details

#create_ledger_account_statement(idempotency_key: nil, body: nil) ⇒ ApiResponse

Create a ledger account statement. something unique, preferably something like an UUID. TODO: type description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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_account_statement_controller.rb', line 15

def (idempotency_key: nil,
                                    body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/ledger_account_statements',
                                 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(LedgerAccountStatement.method(:from_hash))
                .is_api_response(true)
                .local_error('403',
                             'forbidden',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#get_ledger_account_statement(id) ⇒ ApiResponse

Get details on a single ledger account statement.

Parameters:

  • id (String)

    Required parameter: id

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/modern_treasury/controllers/ledger_account_statement_controller.rb', line 43

def (id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/ledger_account_statements/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .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(LedgerAccountStatement.method(:from_hash))
                .is_api_response(true)
                .local_error('404',
                             'not found',
                             ErrorMessageException))
    .execute
end