Class: Plaid::WebhookEvents::Client
- Inherits:
-
Object
- Object
- Plaid::WebhookEvents::Client
- Defined in:
- lib/plaid/webhook_events/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Plaid::Types::BetaWebhookEventsListResponse
/beta/webhook_events/listreturns the webhooks Plaid sent to your account in the last 7 days, including webhooks that weren't delivered.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/plaid/webhook_events/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#list(request_options: {}, **params) ⇒ Plaid::Types::BetaWebhookEventsListResponse
/beta/webhook_events/list returns the webhooks Plaid sent to your account in the last 7 days, including
webhooks that weren't delivered. Use it to recover webhooks your endpoint missed. Events are returned oldest
first.
TRANSACTIONS webhooks are not included. To recover Transactions updates, use
/transactions/sync.
To page through events, omit cursor on your first request, then pass the previous response's next_cursor on
each later request. Store next_cursor even when has_more is false, so your next poll returns only newer
events.
Filters are optional. An event matches a filter if it matches any of the filter's values, and must match every filter you provide.
Events older than 7 days are not retained. If your cursor or start_time is older than that, the request fails
with WEBHOOK_EVENTS_CURSOR_EXPIRED or WEBHOOK_EVENTS_START_TIME_OUT_OF_RANGE.
This endpoint is in beta and may change in backwards-incompatible ways. Send feedback to [email protected].
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/webhook_events/client.rb', line 44 def list(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "beta/webhook_events/list", body: Plaid::WebhookEvents::Types::BetaWebhookEventsListRequest.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::BetaWebhookEventsListResponse.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 |