class EasyPost::Services::Event

Constants

MODEL_CLASS

Webhook Events are triggered by changes in objects you’ve created via the API.

Public Instance Methods

all(params = {}) click to toggle source

Retrieve all Event objects

# File lib/easypost/services/event.rb, line 16
def all(params = {})
  filters = { key: 'events' }

  get_all_helper('events', MODEL_CLASS, params, filters)
end
get_next_page(collection, page_size = nil) click to toggle source

Get the next page of events.

# File lib/easypost/services/event.rb, line 37
def get_next_page(collection, page_size = nil)
  raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection)

  params = { before_id: collection.events.last.id }
  params[:page_size] = page_size unless page_size.nil?

  all(params)
end
retrieve(id) click to toggle source

Retrieve an Event object

# File lib/easypost/services/event.rb, line 9
def retrieve(id)
  response = @client.make_request(:get, "events/#{id}")

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end
retrieve_all_payloads(event_id) click to toggle source

Retrieve all payloads for an event.

# File lib/easypost/services/event.rb, line 23
def retrieve_all_payloads(event_id)
  response = @client.make_request(:get, "events/#{event_id}/payloads")

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::Payload)
end
retrieve_payload(event_id, payload_id) click to toggle source

Retrieve a specific payload for an event.

# File lib/easypost/services/event.rb, line 30
def retrieve_payload(event_id, payload_id)
  response = @client.make_request(:get, "events/#{event_id}/payloads/#{payload_id}")

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::Payload)
end