Class: XivelyApiClient::Client
- Inherits:
-
Object
- Object
- XivelyApiClient::Client
- Defined in:
- lib/xively_api_client.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#instance ⇒ Object
Returns the value of attribute instance.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #create_device(serial_id, options = {}) ⇒ Object
-
#destroy_device(serial) ⇒ Object
def put body HTTParty.put device_url, :body => body, :basic_auth => credentials, :headers => => ‘application/json’ end.
- #index_devices ⇒ Object
-
#initialize(args = {}) ⇒ Client
constructor
A new instance of Client.
- #show_device(serial_id) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 |
# File 'lib/xively_api_client.rb', line 9 def initialize args = {} @instance = args[:instance] || ENV['XIVELY_INSTANCE'] @domain = args[:domain] || ENV['XIVELY_DOMAIN'] @user = args[:user] || ENV['XIVELY_USER'] @pass = args[:pass] || ENV['XIVELY_PASS'] end |
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain.
7 8 9 |
# File 'lib/xively_api_client.rb', line 7 def domain @domain end |
#instance ⇒ Object
Returns the value of attribute instance.
7 8 9 |
# File 'lib/xively_api_client.rb', line 7 def instance @instance end |
#pass ⇒ Object
Returns the value of attribute pass.
7 8 9 |
# File 'lib/xively_api_client.rb', line 7 def pass @pass end |
#user ⇒ Object
Returns the value of attribute user.
7 8 9 |
# File 'lib/xively_api_client.rb', line 7 def user @user end |
Instance Method Details
#create_device(serial_id, options = {}) ⇒ Object
25 26 27 |
# File 'lib/xively_api_client.rb', line 25 def create_device serial_id, = {} json_parse(post(build_json serial_id, )).first end |
#destroy_device(serial) ⇒ Object
def put body
HTTParty.put device_url,
:body => body,
:basic_auth => credentials,
:headers => {'Content-Type' => 'application/json'}
end
45 46 47 |
# File 'lib/xively_api_client.rb', line 45 def destroy_device serial delete device_url(serial) end |
#index_devices ⇒ Object
16 17 18 |
# File 'lib/xively_api_client.rb', line 16 def index_devices json_parse(get device_url) end |
#show_device(serial_id) ⇒ Object
20 21 22 23 |
# File 'lib/xively_api_client.rb', line 20 def show_device serial_id response = get device_url serial_id json_parse(response).first end |