Class: Dasher::Client
- Inherits:
-
Object
- Object
- Dasher::Client
- Defined in:
- lib/dasher/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #add_list_item(square, identifier, properties = {}) ⇒ Object
-
#initialize(host, token, options = {}) ⇒ Client
constructor
A new instance of Client.
- #insert_list_item(square, index, identifier, properties = {}) ⇒ Object
- #replace_list(square, items = []) ⇒ Object
- #screen(id) ⇒ Object
- #screens ⇒ Object
- #update_property(square, key, value) ⇒ Object
Constructor Details
#initialize(host, token, options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 |
# File 'lib/dasher/client.rb', line 8 def initialize(host, token, = {}) @host = host @token = token @port = [:port] @ssl = [:ssl] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/dasher/client.rb', line 6 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/dasher/client.rb', line 6 def port @port end |
#ssl ⇒ Object (readonly)
Returns the value of attribute ssl.
6 7 8 |
# File 'lib/dasher/client.rb', line 6 def ssl @ssl end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/dasher/client.rb', line 6 def token @token end |
Instance Method Details
#add_list_item(square, identifier, properties = {}) ⇒ Object
29 30 31 |
# File 'lib/dasher/client.rb', line 29 def add_list_item(square, identifier, properties = {}) api.lists.add!(:square => square, :identifier => identifier, :properties => properties) end |
#insert_list_item(square, index, identifier, properties = {}) ⇒ Object
33 34 35 |
# File 'lib/dasher/client.rb', line 33 def insert_list_item(square, index, identifier, properties = {}) api.lists.add!(:square => square, :index => index, :identifier => identifier, :properties => properties) end |
#replace_list(square, items = []) ⇒ Object
37 38 39 40 41 |
# File 'lib/dasher/client.rb', line 37 def replace_list(square, items = []) api.lists.replace!(:square => square, :items => items) rescue MoonropeClient::RequestError => e puts e.result.data end |
#screen(id) ⇒ Object
19 20 21 |
# File 'lib/dasher/client.rb', line 19 def screen(id) api.screens.details!(:id => id).data end |
#screens ⇒ Object
15 16 17 |
# File 'lib/dasher/client.rb', line 15 def screens api.screens.list!.data end |
#update_property(square, key, value) ⇒ Object
23 24 25 26 27 |
# File 'lib/dasher/client.rb', line 23 def update_property(square, key, value) api.squares.update_property!(:square => square, :key => key, :value => value).data rescue MoonropeClient::RequestError => e e.result.data["code"] == "ValidationError" ? false : raise end |