class DeviceCloud::Monitor

Constants

RESOURCE_PATH

Attributes

element[RW]
id[RW]
topic[RW]

Public Class Methods

all(client) click to toggle source
# File lib/device_cloud/monitor.rb, line 9
def self.all(client)
  xml_result = Nokogiri::XML.parse client.get RESOURCE_PATH
  xml_result.xpath("//result/Monitor").map { |monitor| parse monitor }
end
new(topic, element = nil) click to toggle source
# File lib/device_cloud/monitor.rb, line 19
def initialize(topic, element = nil)
  @topic = topic
  @element = element
end
parse(xml) click to toggle source
# File lib/device_cloud/monitor.rb, line 14
def self.parse(xml)
  topic = xml.xpath("monTopic").text
  DeviceCloud::Monitor.new(topic, xml)
end

Public Instance Methods

build() click to toggle source
# File lib/device_cloud/monitor.rb, line 44
def build
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.Monitor {
      xml.monTopic @topic
      xml.monTransportType "http"
      xml.monTransportUrl "https://staging.cleanintel.com/ivx/sync"
      xml.monFormatType "json"
      xml.monBatchSize 100
      xml.monCompression "none"
      xml.monBatchDuration 10
    }
  end
end
delete(client) click to toggle source
# File lib/device_cloud/monitor.rb, line 35
def delete(client)
  raise NotImplementedError, "Incomplete"
  puts client.delete resource_path
end
resource_path() click to toggle source
# File lib/device_cloud/monitor.rb, line 24
def resource_path
  RESOURCE_PATH
end
save(client) click to toggle source
# File lib/device_cloud/monitor.rb, line 29
def save(client)
  response = client.post resource_path, build.to_xml
  xml_res = Nokogiri::XML.parse response
  @id = xml_res.xpath("//result/location").text
end
update() click to toggle source
# File lib/device_cloud/monitor.rb, line 40
def update

end