Class: Courier::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/events.rb

Constant Summary collapse

KEY =
"/events"

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Events

Returns a new instance of Events.



5
6
7
# File 'lib/trycourier/events.rb', line 5

def initialize(session)
  @session = session
end

Instance Method Details

#add(event_id:, id:, type: "notification") ⇒ Object



20
21
22
# File 'lib/trycourier/events.rb', line 20

def add(event_id:, id:, type: "notification")
  replace(event_id: event_id, id: id, type: type)
end

#get(event_id:) ⇒ Object



14
15
16
17
18
# File 'lib/trycourier/events.rb', line 14

def get(event_id:)
  path = "#{KEY}/#{event_id}"
  res = @session.send(path, "GET")
  ErrorHandler.check_err(res)
end

#listObject



9
10
11
12
# File 'lib/trycourier/events.rb', line 9

def list
  res = @session.send(KEY, "GET")
  ErrorHandler.check_err(res)
end

#replace(event_id:, id:, type: "notification") ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/trycourier/events.rb', line 24

def replace(event_id:, id:, type: "notification")
  path = "#{KEY}/#{event_id}"

  payload = {
    "id" => id,
    "type" => type
  }
  res = @session.send(path, "PUT", body: payload)
  ErrorHandler.check_err_non_json(res)
end