Class: Plaid::TransactionsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/plaid/apis/transactions_api.rb

Overview

TransactionsApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

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 Plaid::BaseApi

Instance Method Details

#transactions_get(body) ⇒ ApiResponse

The ‘/transactions/get` endpoint allows developers to receive user-authorized transaction data for credit, depository, and some loan-type accounts (only those with account subtype `student`; coverage may be limited). For transaction history from investments accounts, use the [Investments endpoint](plaid.com/docs/api/products#investments) instead. Transaction data is standardized across financial institutions, and in many cases transactions are linked to a clean name, entity type, location, and category. Similarly, account data is standardized and returned with a clean name, number, balance, and other meta information where available. Transactions are returned in reverse-chronological order, and the sequence of transaction ordering is stable and will not shift. Transactions are not immutable and can also be removed altogether by the institution; a removed transaction will no longer appear in `/transactions/get`. For more details, see [Pending and posted transactions](plaid.com/docs/transactions/transactions-data/#pendi ng-and-posted-transactions). Due to the potentially large number of transactions associated with an Item, results are paginated. Manipulate the `count` and `offset` parameters in conjunction with the `total_transactions` response body field to fetch all available transactions. Data returned by `/transactions/get` will be the data available for the Item as of the most recent successful check for new transactions. Plaid typically checks for new data multiple times a day, but these checks may occur less frequently, such as once a day, depending on the institution. An Item’s ‘status.transactions.last_successful_update` field will show the timestamp of the most recent successful update. To force Plaid to check for new transactions, you can use the `/transactions/refresh` endpoint. Note that data may not be immediately available to `/transactions/get`. Plaid will begin to prepare transactions data upon Item link, if Link was initialized with `transactions`, or upon the first call to `/transactions/get`, if it wasn’t. To be alerted when transaction data is ready to be fetched, listen for the [‘INITIAL_UPDATE`](plaid.com/docs/api/webhooks#transactions-initia l_update) and [`HISTORICAL_UPDATE`](plaid.com/docs/api/webhooks#transactions-his torical_update) webhooks. If no transaction history is ready when `/transactions/get` is called, it will return a `PRODUCT_NOT_READY` error. description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/plaid/apis/transactions_api.rb', line 90

def transactions_get(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/transactions/get',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('PLAID-CLIENT-ID', 'PLAID-SECRET', 'Plaid-Version')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TransactionsGetResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Error response',
                             ErrorErrorException))
    .execute
end

#transactions_refresh(body) ⇒ ApiResponse

‘/transactions/refresh` is an optional endpoint for users of the Transactions product. It initiates an on-demand extraction to fetch the newest transactions for an Item. This on-demand extraction takes place in addition to the periodic extractions that automatically occur multiple times a day for any Transactions-enabled Item. If changes to transactions are discovered after calling `/transactions/refresh`, Plaid will fire a webhook: [`TRANSACTIONS_REMOVED`](plaid.com/docs/api/webhooks#deleted-trans actions-detected) will be fired if any removed transactions are detected, and [`DEFAULT_UPDATE`](plaid.com/docs/api/webhooks#transactions-defaul t_update) will be fired if any new transactions are detected. New transactions can be fetched by calling `/transactions/get`. Access to `/transactions/refresh` in Production is specific to certain pricing plans. If you cannot access `/transactions/refresh` in Production, [contact Sales](www.plaid.com/contact) for assistance. description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/plaid/apis/transactions_api.rb', line 28

def transactions_refresh(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/transactions/refresh',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('PLAID-CLIENT-ID', 'PLAID-SECRET', 'Plaid-Version')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TransactionsRefreshResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Error response',
                             ErrorErrorException))
    .execute
end