Class: Unit::Resource::EventResource

Inherits:
BaseResource show all
Defined in:
lib/unit/api_resources/event_resource.rb

Class Method Summary collapse

Methods inherited from BaseResource

file_response_handler, response_handler

Class Method Details

.fire(event_id) ⇒ UnitResponse, UnitError

Fire an event by calling Unit’s API

Parameters:

  • event_id (String)

Returns:



33
34
35
36
# File 'lib/unit/api_resources/event_resource.rb', line 33

def fire(event_id)
  response = HttpHelper.post("#{api_url}/events/#{event_id}", headers: headers)
  response_handler(response)
end

.get(event_id) ⇒ UnitResponse, UnitError

Get an event by id by calling Unit’s API

Parameters:

  • event_id (String)

Returns:



17
18
19
20
# File 'lib/unit/api_resources/event_resource.rb', line 17

def get(event_id)
  response = HttpHelper.get("#{api_url}/events/#{event_id}", headers: headers)
  response_handler(response)
end

.list(params = nil) ⇒ UnitResponse, UnitError

List events by calling Unit’s API

Parameters:

  • params (ListEventParams) (defaults to: nil)

Returns:



25
26
27
28
# File 'lib/unit/api_resources/event_resource.rb', line 25

def list(params = nil)
  response = HttpHelper.get("#{api_url}/events", params: params&.to_hash, headers: headers)
  response_handler(response)
end