module Evrythng class Client # Defines methods related to properties module Properties # Returns a list of properties for a given thng # # @param thng_id [String] The id of the thng to get properties for. # @param options [Hash] A customizable set of options. # @return [Array] The requested list of properties. # @see http://dev.evrythng.com/properties # @example Return the list of properties for thng 4f2133f39f5c550c2000016a # Evrythng.properties('4f2133f39f5c550c2000016a') def properties(thng_id, options={}) get("thngs/#{thng_id}/properties", options) end # Returns a single property, specified by key # # @param thng_id [String] The id of the thng to get property for. # @param key [String] The key of a property to fetch. # @param options [Hash] A customizable set of options. # @return [Hash] The requested property. # @see http://dev.evrythng.com/properties # @example Return the property with key 'Volume' for the thng with id 4f2133f39f5c550c2000016a # Evrythng.property('4f2133f39f5c550c2000016a', 'Volume') def property(thng_id, key, options={}) get("thngs/#{thng_id}/properties/#{key}", options) end # Creates a property # # @param thng_id [String] The id of the thng to create property for. # @param key [String] The key of property. # @param value [String] The value of property. # @param options [Hash] A customizable set of options. # @return [Hash] The created property. # @see http://dev.evrythng.com/properties # @example Create a property for a thng with id 4f2133f39f5c550c2000016a # Evrythng.property_create('4f2133f39f5c550c2000016a', 'Volume', '30') def property_create(thng_id, key, value, options={}) post("thngs/#{thng_id}/properties", options.merge(:key => key, :value => value)) end # Updates a property # # @param thng_id [String] The id of the thng to update property for. # @param key [String] The key of property. # @param value [String] The value of property. # @param options [Hash] A customizable set of options. # @return [Hash] The updated property. # @see http://dev.evrythng.com/properties # @example Update 'Volume' property for a thng with id 4f2133f39f5c550c2000016a # Evrythng.property_update('4f2133f39f5c550c2000016a', 'Volume', '40') def property_update(thng_id, key, value, options={}) put("thngs/#{thng_id}/properties/#{key}", options.merge(:value => value)) end end end end