Class: ModernTreasury::CounterpartyController

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

Overview

CounterpartyController

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

#collect_account_details(id, idempotency_key: nil, body: nil) ⇒ CounterpartyCollectAccountResponse

Send an email requesting account details. something unique, preferably something like an UUID. type description here

Parameters:

  • id (String)

    Required parameter: counterparty id

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (CounterpartyCollectAccountRequest) (defaults to: nil)

    Optional parameter: TODO:

Returns:



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/counterparty_controller.rb', line 16

def (id,
                            idempotency_key: nil,
                            body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/counterparties/{id}/collect_account',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .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(CounterpartyCollectAccountResponse.method(:from_hash))
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#create_counterparty(idempotency_key: nil, body: nil) ⇒ Counterparty

Create a new counterparty. something unique, preferably something like an UUID. description here

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (CounterpartyCreateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/modern_treasury/controllers/counterparty_controller.rb', line 97

def create_counterparty(idempotency_key: nil,
                        body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/counterparties',
                                 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(Counterparty.method(:from_hash))
                .local_error('415',
                             'unsuccessful',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#delete_counterparty(id) ⇒ void

This method returns an undefined value.

Deletes a given counterparty. counterparty.

Parameters:

  • id (String)

    Required parameter: The id of an existing



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/modern_treasury/controllers/counterparty_controller.rb', line 175

def delete_counterparty(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/api/counterparties/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#get_counterparty(id) ⇒ Counterparty

Get details on a single counterparty. counterparty.

Parameters:

  • id (String)

    Required parameter: The id of an existing

Returns:



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/modern_treasury/controllers/counterparty_controller.rb', line 125

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

#list_counterparties(per_page: nil, name: nil, email: nil, metadata: nil, created_at_lower_bound: nil, created_at_upper_bound: nil, after_cursor: nil) ⇒ Array[Counterparty]

Get a paginated list of all counterparties. here of the name field. This is also case insensitive. of the email field. This is also case insensitive. 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. return counterparties created after some datetime. return counterparties created before some datetime. here

Parameters:

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

  • name (String) (defaults to: nil)

    Optional parameter: Performs a partial string match

  • email (String) (defaults to: nil)

    Optional parameter: Performs a partial string match

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

    Optional parameter: For example, if

  • created_at_lower_bound (DateTime) (defaults to: nil)

    Optional parameter: Used to

  • created_at_upper_bound (DateTime) (defaults to: nil)

    Optional parameter: Used to

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

Returns:



58
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
86
87
88
89
# File 'lib/modern_treasury/controllers/counterparty_controller.rb', line 58

def list_counterparties(per_page: nil,
                        name: nil,
                        email: nil,
                        metadata: nil,
                        created_at_lower_bound: nil,
                        created_at_upper_bound: nil,
                        after_cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/counterparties',
                                 Server::DEFAULT)
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(name, key: 'name'))
               .query_param(new_parameter(email, key: 'email'))
               .query_param(new_parameter(, key: 'metadata'))
               .query_param(new_parameter(created_at_lower_bound, key: 'created_at_lower_bound'))
               .query_param(new_parameter(created_at_upper_bound, key: 'created_at_upper_bound'))
               .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(Counterparty.method(:from_hash))
                .is_response_array(true)
                .local_error('400',
                             'bad_request',
                             APIException)
                .local_error('401',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#update_counterparty(id, body: nil) ⇒ Counterparty

Updates a given counterparty with new information. counterparty. description here

Parameters:

  • id (String)

    Required parameter: The id of an existing

  • body (CounterpartyUpdateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



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

def update_counterparty(id,
                        body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/api/counterparties/{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(Counterparty.method(:from_hash))
                .local_error('404',
                             'not found',
                             ErrorMessageException))
    .execute
end