Class: Hahamut::Sender
- Inherits:
-
Object
- Object
- Hahamut::Sender
- Defined in:
- lib/hahamut/sender.rb
Overview
Chat Message Sender
Constant Summary collapse
- ENDPOINT =
'https://us-central1-hahamut-8888.cloudfunctions.net/' \ 'messagePush?access_token=%<token>s'
Instance Method Summary collapse
-
#initialize(token) ⇒ Sender
constructor
A new instance of Sender.
- #send(recipient, message) ⇒ Object
- #ssl? ⇒ Boolean
- #uri ⇒ Object
Constructor Details
#initialize(token) ⇒ Sender
Returns a new instance of Sender.
11 12 13 |
# File 'lib/hahamut/sender.rb', line 11 def initialize(token) @token = token end |
Instance Method Details
#send(recipient, message) ⇒ Object
23 24 25 26 27 |
# File 'lib/hahamut/sender.rb', line 23 def send(recipient, ) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = ssl? http.request build_request(recipient, ) end |
#ssl? ⇒ Boolean
19 20 21 |
# File 'lib/hahamut/sender.rb', line 19 def ssl? uri.scheme == 'https' end |
#uri ⇒ Object
15 16 17 |
# File 'lib/hahamut/sender.rb', line 15 def uri @uri ||= URI(format(ENDPOINT, token: @token)) end |