Class: EasyPost::Services::Event
- Defined in:
- lib/easypost/services/event.rb
Constant Summary collapse
Instance Method Summary collapse
-
#all(params = {}) ⇒ Object
Retrieve all Event objects.
-
#get_next_page(collection, page_size = nil) ⇒ Object
Get the next page of events.
-
#retrieve(id) ⇒ Object
Retrieve an Event object.
-
#retrieve_all_payloads(event_id) ⇒ Object
Retrieve all payloads for an event.
-
#retrieve_payload(event_id, payload_id) ⇒ Object
Retrieve a specific payload for an event.
Methods inherited from Service
Constructor Details
This class inherits a constructor from EasyPost::Services::Service
Instance Method Details
#all(params = {}) ⇒ Object
Retrieve all Event objects
16 17 18 19 20 |
# 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) ⇒ Object
Get the next page of events.
37 38 39 40 41 42 43 44 |
# 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) ⇒ Object
Retrieve an Event object
9 10 11 12 13 |
# 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) ⇒ Object
Retrieve all payloads for an event.
23 24 25 26 27 |
# 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) ⇒ Object
Retrieve a specific payload for an event.
30 31 32 33 34 |
# 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 |