Sha256: d20639bceee79b730a32bfe8b870b4946a1b82249f163a3ff857e0da757ac180

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module Onering
  module API
    class Devices < Base
      class<<self
        def connect(host=nil)
          super(host)
        end

        def get(id)
          request("devices/#{id}")
        end

        def get_field(id, field)
          request("devices/#{id}/get/#{field}")
        end

        def set_field(id, field, value)
          request("devices/#{id}/set/#{field}/#{value}")
        end

        def list(field, options={
          :unique => true,
          :sort   => true,
          :filter => nil
        })
          qs = {
            :q => make_filter(options[:filter])
          } if options[:filter]

          rv = request("devices/list/#{field}", {
            :fields => qs
          })

          rv = rv.uniq if options[:unique]
          rv = rv.sort if options[:sort]

          rv
        end

        def find(filter, options={})
          request("devices/find/#{make_filter(filter)}")
        end

        def save(id, data)
          request("devices/#{id}", {
            :method => :post,
            :data   => data
          })
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onering-client-0.0.16 lib/onering/plugins/devices.rb
onering-client-0.0.15 lib/onering/plugins/devices.rb