Class: DeviceCloud::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/device_cloud/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



9
10
11
# File 'lib/device_cloud/client.rb', line 9

def initialize(config)
  @config = DeviceCloud::Config.new(config)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



7
8
9
# File 'lib/device_cloud/client.rb', line 7

def config
  @config
end

Instance Method Details

#base_urlObject



41
42
43
# 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 = {}) ⇒ Object



21
22
23
# 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 = {}) ⇒ Object



17
18
19
# 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) ⇒ Object



37
38
39
# File 'lib/device_cloud/client.rb', line 37

def delete(path, *args)
  RestClient.delete base_url + path, *args
end

#devices(device, params = {}) ⇒ Object



13
14
15
# 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) ⇒ Object



25
26
27
# File 'lib/device_cloud/client.rb', line 25

def get(path, *args)
  RestClient.get base_url + path, *args
end

#post(path, *args) ⇒ Object



33
34
35
# File 'lib/device_cloud/client.rb', line 33

def post(path, *args)
  RestClient.post base_url + path, *args
end

#put(path, *args) ⇒ Object



29
30
31
# File 'lib/device_cloud/client.rb', line 29

def put(path, *args)
  RestClient.put base_url + path, *args
end