Class: ModernTreasury::VirtualAccountApi
- Defined in:
- lib/modern_treasury/apis/virtual_account_api.rb
Overview
VirtualAccountApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_virtual_account(idempotency_key: nil, body: nil) ⇒ ApiResponse
TODO: type endpoint description here something unique, preferably something like an UUID.
-
#delete_virtual_account(id) ⇒ ApiResponse
TODO: type endpoint description here.
-
#get_virtual_account(id) ⇒ ApiResponse
TODO: type endpoint description here.
-
#list_virtual_accounts(after_cursor: nil, per_page: nil, internal_account_id: nil, counterparty_id: nil, metadata: nil) ⇒ ApiResponse
Get a list of virtual accounts.
-
#update_virtual_account(id, body: nil) ⇒ ApiResponse
TODO: type endpoint description here description here.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from ModernTreasury::BaseApi
Instance Method Details
#create_virtual_account(idempotency_key: nil, body: nil) ⇒ ApiResponse
TODO: type endpoint description here something unique, preferably something like an UUID. description here
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/modern_treasury/apis/virtual_account_api.rb', line 56 def create_virtual_account(idempotency_key: nil, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/virtual_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(VirtualAccount.method(:from_hash)) .is_api_response(true) .local_error('401', 'unauthorized', ErrorMessageException) .local_error('422', 'unsuccessful', ErrorMessageException)) .execute end |
#delete_virtual_account(id) ⇒ ApiResponse
TODO: type endpoint description here
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/modern_treasury/apis/virtual_account_api.rb', line 133 def delete_virtual_account(id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/api/virtual_accounts/{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(VirtualAccount.method(:from_hash)) .is_api_response(true)) .execute end |
#get_virtual_account(id) ⇒ ApiResponse
TODO: type endpoint description here
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/modern_treasury/apis/virtual_account_api.rb', line 84 def get_virtual_account(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/virtual_accounts/{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(VirtualAccount.method(:from_hash)) .is_api_response(true) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#list_virtual_accounts(after_cursor: nil, per_page: nil, internal_account_id: nil, counterparty_id: nil, metadata: nil) ⇒ ApiResponse
Get a list of virtual accounts. here here description 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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/modern_treasury/apis/virtual_account_api.rb', line 23 def list_virtual_accounts(after_cursor: nil, per_page: nil, internal_account_id: nil, counterparty_id: nil, metadata: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/virtual_accounts', Server::DEFAULT) .query_param(new_parameter(after_cursor, key: 'after_cursor')) .query_param(new_parameter(per_page, key: 'per_page')) .query_param(new_parameter(internal_account_id, key: 'internal_account_id')) .query_param(new_parameter(counterparty_id, key: 'counterparty_id')) .query_param(new_parameter(, key: 'metadata')) .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(VirtualAccount.method(:from_hash)) .is_api_response(true) .is_response_array(true) .local_error('401', 'unsuccessful', ErrorMessageException)) .execute end |
#update_virtual_account(id, body: nil) ⇒ ApiResponse
TODO: type endpoint description here description here
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/modern_treasury/apis/virtual_account_api.rb', line 109 def update_virtual_account(id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/api/virtual_accounts/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .is_required(true) .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(VirtualAccount.method(:from_hash)) .is_api_response(true)) .execute end |