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
-
.build_next_page_params(_collection, current_page_items, page_size = nil) ⇒ Object
Build the next page parameters.
-
.get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of events.
-
.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, get_next_page_exec, #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
.build_next_page_params(_collection, current_page_items, page_size = nil) ⇒ Object
Build the next page parameters.
30 31 32 33 34 35 36 37 |
# File 'lib/easypost/event.rb', line 30 def self.build_next_page_params(_collection, current_page_items, page_size = nil) params = {} params[:before_id] = current_page_items.last.id unless page_size.nil? params[:page_size] = page_size end params end |
.get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of events.
25 26 27 |
# File 'lib/easypost/event.rb', line 25 def self.get_next_page(collection, page_size = nil) get_next_page_exec(method(:all), collection, collection.events, page_size) end |
.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 |