Class: EasyPost::Event
- Inherits:
-
Resource
- Object
- EasyPostObject
- Resource
- EasyPost::Event
- Defined in:
- lib/easypost/event.rb
Overview
Webhook Events are triggered by changes in objects you’ve created via the API.
Instance Attribute Summary
Attributes inherited from EasyPostObject
#api_key, #name, #parent, #unsaved_values
Class Method Summary collapse
-
.receive(values) ⇒ Object
Converts a raw webhook event into an EasyPost object.
Instance Method Summary collapse
-
#retrieve_all_payloads(api_key = nil) ⇒ Object
Retrieve all payloads for an event.
-
#retrieve_payload(payload_id, api_key = nil) ⇒ Object
Retrieve a specific payload for an event.
Methods inherited from Resource
all, class_name, create, #delete, each, #refresh, retrieve, #save, url, #url
Methods inherited from EasyPostObject
#[], #[]=, #as_json, construct_from, #deconstruct_keys, #each, #id, #id=, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values
Constructor Details
This class inherits a constructor from EasyPost::EasyPostObject
Class Method Details
.receive(values) ⇒ Object
Converts a raw webhook event into an EasyPost object.
8 9 10 |
# File 'lib/easypost/event.rb', line 8 def self.receive(values) EasyPost::Util.convert_to_easypost_object(JSON.parse(values), nil) end |
Instance Method Details
#retrieve_all_payloads(api_key = nil) ⇒ Object
Retrieve all payloads for an event.
13 14 15 16 |
# File 'lib/easypost/event.rb', line 13 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_payload(payload_id, api_key = nil) ⇒ Object
Retrieve a specific payload for an event.
19 20 21 22 |
# File 'lib/easypost/event.rb', line 19 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 |