Class: ModernTreasury::LedgerEventHandlerController

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

Overview

LedgerEventHandlerController

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_event_handler(idempotency_key: nil, body: nil) ⇒ LedgerEventHandler

TODO: type endpoint description here something unique, preferably something like an UUID. type description here

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (LedgerEventHandlerCreateRequest) (defaults to: nil)

    Optional parameter: TODO:

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/modern_treasury/controllers/ledger_event_handler_controller.rb', line 53

def create_ledger_event_handler(idempotency_key: nil,
                                body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/ledger_event_handlers',
                                 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(LedgerEventHandler.method(:from_hash))
                .local_error('400',
                             'parameter_invalid',
                             APIException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#delete_ledger_event_handler(id) ⇒ LedgerEventHandler

Archive a ledger event handler.

Parameters:

  • id (String)

    Required parameter: id

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/modern_treasury/controllers/ledger_event_handler_controller.rb', line 101

def delete_ledger_event_handler(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/api/ledger_event_handlers/{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(LedgerEventHandler.method(:from_hash))
                .local_error('404',
                             'not found',
                             ErrorMessageException))
    .execute
end

#get_ledger_event_handler(id) ⇒ LedgerEventHandler

Get details on a single ledger event handler.

Parameters:

  • id (String)

    Required parameter: id

Returns:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/modern_treasury/controllers/ledger_event_handler_controller.rb', line 80

def get_ledger_event_handler(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/ledger_event_handlers/{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(LedgerEventHandler.method(:from_hash))
                .local_error('404',
                             'not found',
                             ErrorMessageException))
    .execute
end

#list_ledger_event_handlers(per_page: nil, metadata: nil, name: nil, created_at: nil, after_cursor: nil) ⇒ Array[LedgerEventHandler]

Get a list of ledger event handlers. 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. (>), `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 created_at%5Bgt%5D=2000-01-01T12:00:00Z. 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

  • name (String) (defaults to: nil)

    Optional parameter: TODO: type description here

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

    Optional parameter: Use ‘gt`

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/modern_treasury/controllers/ledger_event_handler_controller.rb', line 24

def list_ledger_event_handlers(per_page: nil,
                               metadata: nil,
                               name: nil,
                               created_at: nil,
                               after_cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/ledger_event_handlers',
                                 Server::DEFAULT)
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(, key: 'metadata'))
               .query_param(new_parameter(name, key: 'name'))
               .query_param(new_parameter(created_at, key: 'created_at'))
               .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(LedgerEventHandler.method(:from_hash))
                .is_response_array(true))
    .execute
end