Sha256: 36dbf25601fa3aa8f3e1874489257a664fe229fd4bac46d52cc4a408266909e4
Contents?: true
Size: 1.16 KB
Versions: 21
Compression:
Stored size: 1.16 KB
Contents
module Onering class API class Devices < API def show(id) get("/devices/#{id}").parsed_response end def get_field(id, field) rv = get("/devices/#{id}/get/#{field}") rv.parsed_response rescue rv.response.body end def set_field(id, field, value) rv = get("/devices/#{id}/set/#{field}/#{value}") rv.parsed_response rescue rv.response.body end def list(field, options={ :unique => true, :sort => true, :filter => nil }) qs = { :q => make_filter(options[:filter]) } if options[:filter] rv = get("/devices/list/#{field}", { :query => qs }).parsed_response rv = rv.uniq if options[:unique] rv = rv.sort if options[:sort] return rv end def find(filter, options={}) get("/devices/find/#{make_filter(filter)}").parsed_response end def save(id, data=nil, &block) if block_given? post("/devices/#{id}", {}, &block) else post("/devices/#{id}", { :body => data }) end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems