Class: Colossus::HTTPWriterClient
- Inherits:
-
Object
- Object
- Colossus::HTTPWriterClient
- Defined in:
- lib/colossus/http_writer_client.rb
Instance Attribute Summary collapse
-
#time_out ⇒ Object
readonly
Returns the value of attribute time_out.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#writer_token ⇒ Object
readonly
Returns the value of attribute writer_token.
Instance Method Summary collapse
-
#initialize(url, writer_token = Colossus.config.writer_token, time_out = 2) ⇒ HTTPWriterClient
constructor
A new instance of HTTPWriterClient.
- #presence(optional_user_ids = nil) ⇒ Object
- #push(user_ids, message) ⇒ Object
Constructor Details
#initialize(url, writer_token = Colossus.config.writer_token, time_out = 2) ⇒ HTTPWriterClient
Returns a new instance of HTTPWriterClient.
5 6 7 8 9 10 11 |
# File 'lib/colossus/http_writer_client.rb', line 5 def initialize(url, writer_token = Colossus.config.writer_token, time_out = 2) @url = url @writer_token = writer_token @time_out = time_out end |
Instance Attribute Details
#time_out ⇒ Object (readonly)
Returns the value of attribute time_out.
3 4 5 |
# File 'lib/colossus/http_writer_client.rb', line 3 def time_out @time_out end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/colossus/http_writer_client.rb', line 3 def url @url end |
#writer_token ⇒ Object (readonly)
Returns the value of attribute writer_token.
3 4 5 |
# File 'lib/colossus/http_writer_client.rb', line 3 def writer_token @writer_token end |
Instance Method Details
#presence(optional_user_ids = nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/colossus/http_writer_client.rb', line 13 def presence(optional_user_ids = nil) user_ids = Array(optional_user_ids) if optional_user_ids connection.post('/presence_request') do |req| req.body = { user_ids: user_ids, writer_token: writer_token } end.body end |
#push(user_ids, message) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/colossus/http_writer_client.rb', line 20 def push(user_ids, ) user_ids = Array(user_ids) connection.post('/message') do |req| req.body = { user_ids: user_ids, message: , writer_token: writer_token} end.body end |