Sha256: efae17cb108f1a908a3047b7480bd7f7d16f0869a073aff1b2ff4b4ec14070ae

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

require 'json'

# Webhook Events are triggered by changes in objects you've created via the API.
class EasyPost::Event < EasyPost::Resource
  # Converts a raw webhook event into an EasyPost object.
  def self.receive(values)
    EasyPost::Util.convert_to_easypost_object(JSON.parse(values), nil)
  end

  # Retrieve all payloads for an event.
  def retrieve_all_payloads(api_key = nil)
    response = EasyPost.make_request(:get, "#{url}/payloads", api_key)
    EasyPost::Util.convert_to_easypost_object(response, api_key)
  end

  # Retrieve a specific payload for an event.
  def retrieve_payload(payload_id, api_key = nil)
    response = EasyPost.make_request(:get, "#{url}/payloads/#{payload_id}", api_key)
    EasyPost::Util.convert_to_easypost_object(response, api_key)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
easypost-4.12.0 lib/easypost/event.rb
easypost-4.11.0 lib/easypost/event.rb