Class: Courier::Messages
- Inherits:
-
Object
- Object
- Courier::Messages
- Defined in:
- lib/trycourier/messages.rb
Constant Summary collapse
- KEY =
"/messages"
Instance Method Summary collapse
- #cancel(message_id:) ⇒ Object
- #get(message_id:) ⇒ Object
- #get_history(message_id:, type: nil) ⇒ Object
-
#initialize(session) ⇒ Messages
constructor
A new instance of Messages.
- #list(cursor: nil, event: nil, list_id: nil, message_id: nil, notification: nil, recipient: nil) ⇒ Object
Constructor Details
#initialize(session) ⇒ Messages
Returns a new instance of Messages.
5 6 7 |
# File 'lib/trycourier/messages.rb', line 5 def initialize(session) @session = session end |
Instance Method Details
#cancel(message_id:) ⇒ Object
41 42 43 44 45 |
# File 'lib/trycourier/messages.rb', line 41 def cancel(message_id:) path = "#{KEY}/#{}/cancel" res = @session.send(path, "POST") ErrorHandler.check_err(res) end |
#get(message_id:) ⇒ Object
35 36 37 38 39 |
# File 'lib/trycourier/messages.rb', line 35 def get(message_id:) path = "#{KEY}/#{}" res = @session.send(path, "GET") ErrorHandler.check_err(res) end |
#get_history(message_id:, type: nil) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/trycourier/messages.rb', line 47 def get_history(message_id:, type: nil) path = "#{KEY}/#{}/history" params = {} if type params["type"] = type end res = @session.send(path, "GET", params: params) ErrorHandler.check_err(res) end |
#list(cursor: nil, event: nil, list_id: nil, message_id: nil, notification: nil, recipient: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trycourier/messages.rb', line 9 def list(cursor: nil, event: nil, list_id: nil, message_id: nil, notification: nil, recipient: nil) params = {} if cursor params["cursor"] = cursor end if event params["event"] = event end if list_id params["list"] = list_id end if params["messageId"] = end if notification params["notification"] = notification end if recipient params["recipient"] = recipient end res = @session.send(KEY, "GET", params: params) ErrorHandler.check_err(res) end |