Class: ModernTreasury::TransactionApi
- Defined in:
- lib/modern_treasury/apis/transaction_api.rb
Overview
TransactionApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#get_transaction(id) ⇒ ApiResponse
Get details on a single transaction.
-
#list_transactions(after_cursor: nil, per_page: nil, internal_account_id: nil, virtual_account_id: nil, posted: nil, as_of_date_start: nil, as_of_date_end: nil, direction: nil, counterparty_id: nil, payment_type: nil, transactable_type: nil, description: nil, vendor_id: nil, metadata: nil) ⇒ ApiResponse
Get a list of all transactions.
-
#update_transaction(id, body: nil) ⇒ ApiResponse
Update a single transaction.
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
#get_transaction(id) ⇒ ApiResponse
Get details on a single transaction.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/modern_treasury/apis/transaction_api.rb', line 89 def get_transaction(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/transactions/{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(Transaction.method(:from_hash)) .is_api_response(true) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#list_transactions(after_cursor: nil, per_page: nil, internal_account_id: nil, virtual_account_id: nil, posted: nil, as_of_date_start: nil, as_of_date_end: nil, direction: nil, counterparty_id: nil, payment_type: nil, transactable_type: nil, description: nil, vendor_id: nil, metadata: nil) ⇒ ApiResponse
Get a list of all transactions. here here ‘internal_account_id` if you wish to see transactions to/from a specific account. description here or `false`. with an `as_of_date` starting on or after the specified date (YYYY-MM-DD). an `as_of_date` starting on or before the specified date (YYYY-MM-DD). here description here here description here including the queried string in the description. including the queried vendor id (an identifier given to transactions by the bank). 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.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 |
# File 'lib/modern_treasury/apis/transaction_api.rb', line 44 def list_transactions(after_cursor: nil, per_page: nil, internal_account_id: nil, virtual_account_id: nil, posted: nil, as_of_date_start: nil, as_of_date_end: nil, direction: nil, counterparty_id: nil, payment_type: nil, transactable_type: nil, description: nil, vendor_id: nil, metadata: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/transactions', 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(virtual_account_id, key: 'virtual_account_id')) .query_param(new_parameter(posted, key: 'posted')) .query_param(new_parameter(as_of_date_start, key: 'as_of_date_start')) .query_param(new_parameter(as_of_date_end, key: 'as_of_date_end')) .query_param(new_parameter(direction, key: 'direction')) .query_param(new_parameter(counterparty_id, key: 'counterparty_id')) .query_param(new_parameter(payment_type, key: 'payment_type')) .query_param(new_parameter(transactable_type, key: 'transactable_type')) .query_param(new_parameter(description, key: 'description')) .query_param(new_parameter(vendor_id, key: 'vendor_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(Transaction.method(:from_hash)) .is_api_response(true) .is_response_array(true)) .execute end |
#update_transaction(id, body: nil) ⇒ ApiResponse
Update a single transaction. type description here
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/modern_treasury/apis/transaction_api.rb', line 114 def update_transaction(id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/api/transactions/{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(Transaction.method(:from_hash)) .is_api_response(true) .local_error('404', 'not found', ErrorMessageException)) .execute end |