Representation of a webhook.
- E
- H
- I
- N
- R
- T
- U
ERROR_RESPONSE | = | -1 |
CODEX | = | codex.freeze |
[R] | access_token | The String access token for authenticated user. |
[R] | code | The Integer code denoting the type of webhook this is. E.g. 0 |
[R] | message | The String human readable explanation of this webhook request. E.g. “Initial transaction pull finished”. |
[R] | total_transactions | The Integer number of transactions available in Plaid. E.g. 124 |
Initialize a Webhook instance.
- fields
-
The Hash with fields.
Source: show
# File lib/plaid/webhook.rb, line 21 def initialize(fields) @message = fields['message'] @access_token = fields['access_token'] @total_transactions = fields['total_transactions'] @code = fields['code'] # present only for Removed Transaction Webhook @removed_transactions = fields['removed_transactions'] # present only for Error Response Webhook @resolve = fields['resolve'] end
Get a Plaid::Error instance if this is an Error Response Webhook
Returns
Returns Plaid::Error or nil
Source: show
# File lib/plaid/webhook.rb, line 114 def error if error_response? Plaid::PlaidError.new @code, @message, @resolve end end
Detect if the webhook is Error Response Webhook. Triggered when an error has occurred. Includes the relevant Plaid error code with details on both the error type and steps for error resolution.
Returns
Returns true if it is.
Source: show
# File lib/plaid/webhook.rb, line 100 def error_response? Webhook::CODEX[code].nil? end
Detect if the webhook is Historical Transaction Webhook. Occurs once the historical transaction pull has completed, shortly after the initial transaction pull.
Returns
Returns true if it is.
Source: show
# File lib/plaid/webhook.rb, line 52 def historical_transaction? code == Webhook::HISTORICAL_TRANSACTION end
Source: show
# File lib/plaid/webhook.rb, line 84 def income? code == Webhook::INCOME end
Detect if the webhook is Initial Transaction Webhook. Occurs once the initial transaction pull has finished.
Returns
Returns true if it is.
Source: show
# File lib/plaid/webhook.rb, line 43 def initial_transaction? code == Webhook::INITIAL_TRANSACTION end
Get a String representation of the transaction.
Returns
Returns a String.
Source: show
# File lib/plaid/webhook.rb, line 123 def inspect "#<Plaid::Webhook type=#{type.inspect} code=#{code.inspect}, access_token=#{access_token.inspect}, " "total_transactions=#{total_transactions.inspect}, message=#{message.inspect}>" end
Detect if the webhook is Normal Transaction Webhook. Occurs at set intervals throughout the day as data is updated from the financial institutions.
Returns
Returns true if it is.
Source: show
# File lib/plaid/webhook.rb, line 61 def normal_transaction? code == Webhook::NORMAL_TRANSACTION end
Detect if the webhook is Removed Transaction Webhook. Occurs when transactions have been removed from our system.
Returns
Returns true if it is.
Source: show
# File lib/plaid/webhook.rb, line 69 def removed_transaction? code == Webhook::REMOVED_TRANSACTION end
Source: show
# File lib/plaid/webhook.rb, line 107 def removed_transactions_ids @removed_transactions end
Get a String representation of the transaction.
Returns
Returns a String.
Source: show
# File lib/plaid/webhook.rb, line 35 def type Webhook::CODEX[code] || 'ERROR_RESPONSE' end
Detect if the webhook is User's Webhook Updated. Occurs when an user's webhook is updated via a PATCH request without credentials.
Returns
Returns true if it is.
Source: show
# File lib/plaid/webhook.rb, line 77 def user_webhook_updated? code == Webhook::USER_WEBHOOK_UPDATED end