Class: ModernTreasury::ExternalAccountController

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

Overview

ExternalAccountController

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

#complete_verification_external_account(id, idempotency_key: nil, body: nil) ⇒ ExternalAccount

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

Parameters:

  • id (String)

    Required parameter: external account id

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (ExternalAccountCompleteVerificationRequest) (defaults to: nil)

    Optional

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/modern_treasury/controllers/external_account_controller.rb', line 47

def (id,
                                           idempotency_key: nil,
                                           body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/external_accounts/{id}/complete_verification',
                                 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(ExternalAccount.method(:from_hash))
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#create_external_account(idempotency_key: nil, body: nil) ⇒ ExternalAccount

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

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (ExternalAccountCreateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/modern_treasury/controllers/external_account_controller.rb', line 117

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

#delete_external_account(id) ⇒ void

This method returns an undefined value.

TODO: type endpoint description here

Parameters:

  • id (String)

    Required parameter: external account id



189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/modern_treasury/controllers/external_account_controller.rb', line 189

def (id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/api/external_accounts/{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_external_account(id) ⇒ ExternalAccount

TODO: type endpoint description here

Parameters:

  • id (String)

    Required parameter: external account id

Returns:



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/modern_treasury/controllers/external_account_controller.rb', line 141

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

#list_external_accounts(per_page: nil, party_name: nil, counterparty_id: nil, metadata: nil, after_cursor: nil) ⇒ Array[ExternalAccount]

TODO: type endpoint description here here ExternalAccount’s party_name AND the Counterparty’s party_name 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

Parameters:

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

  • party_name (String) (defaults to: nil)

    Optional parameter: Searches the

  • counterparty_id (String) (defaults to: nil)

    Optional parameter: TODO: type description

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

    Optional parameter: For example, if

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

Returns:



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

def list_external_accounts(per_page: nil,
                           party_name: nil,
                           counterparty_id: nil,
                           metadata: nil,
                           after_cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/external_accounts',
                                 Server::DEFAULT)
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(party_name, key: 'party_name'))
               .query_param(new_parameter(counterparty_id, key: 'counterparty_id'))
               .query_param(new_parameter(, key: 'metadata'))
               .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(ExternalAccount.method(:from_hash))
                .is_response_array(true)
                .local_error('401',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#update_external_account(id, body: nil) ⇒ ExternalAccount

TODO: type endpoint description here description here

Parameters:

  • id (String)

    Required parameter: external account id

  • body (ExternalAccountUpdateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/modern_treasury/controllers/external_account_controller.rb', line 164

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

#verify_external_account(id, idempotency_key: nil, body: nil) ⇒ ExternalAccount

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

Parameters:

  • id (String)

    Required parameter: external account id

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (ExternalAccountVerifyRequest) (defaults to: nil)

    Optional parameter: TODO: type

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

def (id,
                            idempotency_key: nil,
                            body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/external_accounts/{id}/verify',
                                 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(ExternalAccount.method(:from_hash))
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end