class StarkBank::Event::Attempt

# Event::Attempt object

When an Event delivery fails, an event attempt will be registered. It carries information meant to help you debug event reception issues.

## Attributes:

Attributes

code[R]
created[R]
event_id[R]
id[R]
message[R]
webhook_id[R]

Public Class Methods

get(id, user: nil) click to toggle source

# Retrieve a specific Event::Attempt

Receive a single Event::Attempt object previously created by the Stark Bank API by its id

## Parameters (required):

  • id [string]: object unique id. ex: '5656565656565656'

## Parameters (optional):

## Return:

# File lib/event/attempt.rb, line 45
def self.get(id, user: nil)
  StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
end
new(id:, code:, message:, event_id:, webhook_id:, created:) click to toggle source
Calls superclass method StarkBank::Utils::Resource::new
# File lib/event/attempt.rb, line 24
def initialize(id:, code:, message:, event_id:, webhook_id:, created:)
  super(id)
  @code = code
  @message = message
  @event_id = event_id
  @webhook_id = webhook_id
  @created = StarkBank::Utils::Checks.check_datetime(created)
end
page(cursor: nil, limit: nil, after: nil, before: nil, event_ids: nil, webhook_ids: nil, user: nil) click to toggle source

# Retrieve paged Attempts

Receive a list of up to 100 Attempt objects previously created in the Stark Bank API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.

## Parameters (optional):

  • cursor [string, default nil]: cursor returned on the previous page function call

  • limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35

  • after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)

  • before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)

  • event_ids [list of strings, default None]: list of Event ids to filter attempts. ex: [“5656565656565656”, “4545454545454545”]

  • webhook_ids [list of strings, default None]: list of Webhook ids to filter attempts. ex: [“5656565656565656”, “4545454545454545”]

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

  • list of Attempt objects with updated attributes and cursor to retrieve the next page of Attempt objects

# File lib/event/attempt.rb, line 93
def self.page(cursor: nil, limit: nil, after: nil, before: nil, event_ids: nil, webhook_ids: nil, user: nil)
  after = StarkBank::Utils::Checks.check_date(after)
  before = StarkBank::Utils::Checks.check_date(before)
  return StarkBank::Utils::Rest.get_page(
    cursor: cursor,
    limit: limit,
    after: after,
    before: before,
    event_ids: event_ids,
    webhook_ids: webhook_ids,
    user: user,
    **resource
  )
end
query(limit: nil, after: nil, before: nil, event_ids: nil, webhook_ids: nil, user: nil) click to toggle source

# Retrieve Event::Attempts

Receive a generator of Event::Attempt objects previously created in the Stark Bank API

## Parameters (optional):

  • limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35

  • after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)

  • before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)

  • event_ids [list of strings, default None]: list of Event ids to filter attempts. ex: [“5656565656565656”, “4545454545454545”]

  • webhook_ids [list of strings, default None]: list of Webhook ids to filter attempts. ex: [“5656565656565656”, “4545454545454545”]

  • user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call

## Return:

# File lib/event/attempt.rb, line 63
def self.query(limit: nil, after: nil, before: nil, event_ids: nil, webhook_ids: nil, user: nil)
  after = StarkBank::Utils::Checks.check_date(after)
  before = StarkBank::Utils::Checks.check_date(before)
  StarkBank::Utils::Rest.get_stream(
    limit: limit,
    after: after,
    before: before,
    event_ids: event_ids,
    webhook_ids: webhook_ids,
    user: user,
    **resource
  )
end
resource() click to toggle source
# File lib/event/attempt.rb, line 108
def self.resource
  {
    resource_name: 'EventAttempt',
    resource_maker: proc { |json|
      Attempt.new(
        id: json['id'],
        code: json['code'],
        message: json['message'],
        event_id: json['event_id'],
        webhook_id: json['webhook_id'],
        created: json['created']
      )
    }
  }
end