Class: ScaleDrone
Instance Method Summary collapse
- #channel_stats ⇒ Object
-
#initialize(options = {}) ⇒ ScaleDrone
constructor
A new instance of ScaleDrone.
- #publish(data = {}, *rooms) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ScaleDrone
Returns a new instance of ScaleDrone.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/scaledrone.rb', line 6 def initialize( = {}) = { :base_url => 'https://api2.scaledrone.com', }.merge() @channel_id, @base_url = .values_at(:channel_id, :base_url) @options = { headers: {'Content-Type' => 'application/json'}, basic_auth: {username: [:channel_id], password: [:secret_key]} } end |
Instance Method Details
#channel_stats ⇒ Object
28 29 30 |
# File 'lib/scaledrone.rb', line 28 def channel_stats self.class.get("#{@base_url}/#{@channel_id}/stats", @options) end |
#publish(data = {}, *rooms) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/scaledrone.rb', line 17 def publish(data = {}, *rooms) if rooms.length === 1 url = "#{@base_url}/#{@channel_id}/#{rooms[0]}/publish" = {body: data.to_json}.merge(@options) else url = "#{@base_url}/#{@channel_id}/publish/rooms" = {body: data.to_json, query: {:r => rooms}}.merge(@options) end self.class.post(url, ) end |