Class: Plaid::CashflowReport::Client
- Inherits:
-
Object
- Object
- Plaid::CashflowReport::Client
- Defined in:
- lib/plaid/cashflow_report/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportGetResponse
The
/cashflow_report/getendpoint retrieves transactions data associated with an Item. -
#get_insights(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportInsightsGetResponse
The
/cashflow_report/insights/getendpoint retrieves insights data associated with an Item. -
#get_transactions(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportTransactionsGetResponse
The
/cashflow_report/transactions/getendpoint retrieves transactions data associated with an Item. - #initialize(client:) ⇒ void constructor
-
#refresh(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportRefreshResponse
/cashflow_report/refreshis an endpoint that initiates an on-demand extraction to fetch the newest transactions for an Item (given anitem_id).
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/plaid/cashflow_report/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportGetResponse
The /cashflow_report/get endpoint retrieves transactions data associated with an Item. Transactions data is
standardized across financial institutions.
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 /cashflow_report/get. For more details, see Pending and posted
transactions.
Due to the potentially large number of transactions associated with an Item, results are paginated. Manipulate
the count and cursor parameters in conjunction with the has_more response body field to fetch all
available transactions.
Note that data isn't likely to be immediately available to /cashflow_report/get. Plaid will begin to prepare
transactions data upon Item link, if Link was initialized with cashflow_report, or if it wasn't, upon the
first call to /cashflow_report/refresh. To be alerted when transaction data is ready to be fetched, listen for
the CASHFLOW_REPORT_READY webhook.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/plaid/cashflow_report/client.rb', line 109 def get(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "cashflow_report/get", body: Plaid::CashflowReport::Types::CashflowReportGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::CashflowReportGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_insights(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportInsightsGetResponse
The /cashflow_report/insights/get endpoint retrieves insights data associated with an Item. Insights are only
calculated on credit and depository accounts.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/plaid/cashflow_report/client.rb', line 222 def get_insights(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "cashflow_report/insights/get", body: Plaid::CashflowReport::Types::CashflowReportInsightsGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::CashflowReportInsightsGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get_transactions(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportTransactionsGetResponse
The /cashflow_report/transactions/get endpoint retrieves transactions data associated with an Item.
Transactions data is standardized across financial institutions.
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 /cashflow_report/transactions/get. For more details, see Pending and
posted transactions.
Due to the potentially large number of transactions associated with an Item, results are paginated. Manipulate
the count and cursor parameters in conjunction with the has_more response body field to fetch all
available transactions.
Note that data isn't likely to be immediately available to /cashflow_report/transactions/get. Plaid will begin
to prepare transactions data upon Item link, if Link was initialized with cashflow_report, or if it wasn't,
upon the first call to /cashflow_report/refresh. To be alerted when transaction data is ready to be fetched,
listen for the CASHFLOW_REPORT_READY webhook.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/plaid/cashflow_report/client.rb', line 171 def get_transactions(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "cashflow_report/transactions/get", body: Plaid::CashflowReport::Types::CashflowReportTransactionsGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::CashflowReportTransactionsGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#refresh(request_options: {}, **params) ⇒ Plaid::Types::CashflowReportRefreshResponse
/cashflow_report/refresh is an endpoint that initiates an on-demand extraction to fetch the newest
transactions for an Item (given an item_id). The Item must already have Cashflow Report added as a product in
order to call /cashflow_report/refresh.
After calling /cashflow_report/refresh, Plaid will fire a webhook CASHFLOW_REPORT_READY alerting clients
that new transactions data can then be ingested via /cashflow_report/get or the webhook will contain an error
code informing there was an error in refreshing transactions data.
Note that the /cashflow_report/refresh endpoint is not supported for Capital One (ins_128026) non-depository
accounts and will result in a PRODUCTS_NOT_SUPPORTED error if called on an Item that contains only
non-depository accounts from that institution.
As this endpoint triggers a synchronous request for fresh data, latency may be higher than for other Plaid endpoints (typically less than 10 seconds, but up to 30 seconds or more). If you encounter errors, you may find it necessary to adjust your timeout period for requests.
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 |
# File 'lib/plaid/cashflow_report/client.rb', line 44 def refresh(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "cashflow_report/refresh", body: Plaid::CashflowReport::Types::CashflowReportRefreshRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::CashflowReportRefreshResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |