Representation of a webhook.

Sections
Methods
E
H
I
N
R
T
U
Constants
ERROR_RESPONSE = -1
 
CODEX = codex.freeze
 
Public
Attributes
[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

Class Public methods
new(fields)

Initialize a Webhook instance.

fields

The Hash with fields.

# 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
Instance Public methods
error()

Get a Plaid::Error instance if this is an Error Response Webhook

Returns

Returns Plaid::Error or nil

# File lib/plaid/webhook.rb, line 114
def error
  if error_response?
    Plaid::PlaidError.new @code, @message, @resolve
  end
end
error_response?()

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.

# File lib/plaid/webhook.rb, line 100
def error_response?
  Webhook::CODEX[code].nil?
end
historical_transaction?()

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.

# File lib/plaid/webhook.rb, line 52
def historical_transaction?
  code == Webhook::HISTORICAL_TRANSACTION
end
income?()

Detect if the webhook is Income. Occurs when Income data is ready.

Returns

Returns true if it is.

# File lib/plaid/webhook.rb, line 84
def income?
  code == Webhook::INCOME
end
initial_transaction?()

Detect if the webhook is Initial Transaction Webhook. Occurs once the initial transaction pull has finished.

Returns

Returns true if it is.

# File lib/plaid/webhook.rb, line 43
def initial_transaction?
  code == Webhook::INITIAL_TRANSACTION
end
inspect()

Get a String representation of the transaction.

Returns

Returns a String.

Also aliased as: to_s
# 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
normal_transaction?()

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.

# File lib/plaid/webhook.rb, line 61
def normal_transaction?
  code == Webhook::NORMAL_TRANSACTION
end
removed_transaction?()

Detect if the webhook is Removed Transaction Webhook. Occurs when transactions have been removed from our system.

Returns

Returns true if it is.

# File lib/plaid/webhook.rb, line 69
def removed_transaction?
  code == Webhook::REMOVED_TRANSACTION
end
removed_transactions_ids()

Get transaction IDs that were removed.

Returns

Returns Array or nil

# File lib/plaid/webhook.rb, line 107
def removed_transactions_ids
  @removed_transactions
end
risk?()

Detect if the webhook is Risk. Occurs when Risk data is ready.

Returns

Returns true if it is.

# File lib/plaid/webhook.rb, line 91
def risk?
  code == Webhook::RISK
end
to_s()

Get a String representation of the transaction.

Returns

Returns a String.

Alias for: inspect
type()

Share the type of Webhook this is from its code

Returns

Returns String webhook type

# File lib/plaid/webhook.rb, line 35
def type
  Webhook::CODEX[code] || 'ERROR_RESPONSE'
end
user_webhook_updated?()

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.

# File lib/plaid/webhook.rb, line 77
def user_webhook_updated?
  code == Webhook::USER_WEBHOOK_UPDATED
end