class DeviceCloud::Client
Attributes
config[RW]
Public Class Methods
new(config)
click to toggle source
# File lib/device_cloud/client.rb, line 9 def initialize(config) @config = DeviceCloud::Config.new(config) end
Public Instance Methods
base_url()
click to toggle source
# File lib/device_cloud/client.rb, line 41 def base_url "#{config.protocol}://#{config.username}:#{config.password}@#{config.host}" end
data_points(stream_id, params = {})
click to toggle source
# File lib/device_cloud/client.rb, line 21 def data_points(stream_id, params = {}) DataPoint.parse(get "/ws/DataPoint/#{stream_id}?#{ to_params params }") end
data_streams(stream_path, params = {})
click to toggle source
# File lib/device_cloud/client.rb, line 17 def data_streams(stream_path, params = {}) DataStream.parse(get "#{DataStream::RESOURCE_PATH}/#{stream_path}?#{ to_params params }") end
delete(path, *args)
click to toggle source
# File lib/device_cloud/client.rb, line 37 def delete(path, *args) RestClient.delete base_url + path, *args end
devices(device, params = {})
click to toggle source
# File lib/device_cloud/client.rb, line 13 def devices(device, params = {}) DeviceCore.parse(get "/ws/DeviceCore/#{device}?#{ to_params params }") end
get(path, *args)
click to toggle source
# File lib/device_cloud/client.rb, line 25 def get(path, *args) RestClient.get base_url + path, *args end
post(path, *args)
click to toggle source
# File lib/device_cloud/client.rb, line 33 def post(path, *args) RestClient.post base_url + path, *args end
put(path, *args)
click to toggle source
# File lib/device_cloud/client.rb, line 29 def put(path, *args) RestClient.put base_url + path, *args end
Private Instance Methods
to_params(hash)
click to toggle source
# File lib/device_cloud/client.rb, line 46 def to_params(hash) hash.each_pair.map do |key, value| key + "=" + value end.inject { |a, b| a + "&" + b } end