Module: Evrythng::Client::Properties

Included in:
Evrythng::Client
Defined in:
lib/evrythng/client/properties.rb

Overview

Defines methods related to properties

Instance Method Summary collapse

Instance Method Details

#properties(thng_id, options = {}) ⇒ Array

Returns a list of properties for a given thng

Examples:

Return the list of properties for thng 4f2133f39f5c550c2000016a

Evrythng.properties('4f2133f39f5c550c2000016a')

Parameters:

  • thng_id (String)

    The id of the thng to get properties for.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Array)

    The requested list of properties.

See Also:



13
14
15
# File 'lib/evrythng/client/properties.rb', line 13

def properties(thng_id, options={})
  get("thngs/#{thng_id}/properties", options)
end

#property(thng_id, key, options = {}) ⇒ Hash

Returns a single property, specified by key

Examples:

Return the property with key ‘Volume’ for the thng with id 4f2133f39f5c550c2000016a

Evrythng.property('4f2133f39f5c550c2000016a', 'Volume')

Parameters:

  • thng_id (String)

    The id of the thng to get property for.

  • key (String)

    The key of a property to fetch.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Hash)

    The requested property.

See Also:



26
27
28
# File 'lib/evrythng/client/properties.rb', line 26

def property(thng_id, key, options={})
  get("thngs/#{thng_id}/properties/#{key}", options)
end

#property_create(thng_id, key, value, options = {}) ⇒ Hash

Creates a property

Examples:

Create a property for a thng with id 4f2133f39f5c550c2000016a

Evrythng.property_create('4f2133f39f5c550c2000016a', 'Volume', '30')

Parameters:

  • thng_id (String)

    The id of the thng to create property for.

  • key (String)

    The key of property.

  • value (String)

    The value of property.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Hash)

    The created property.

See Also:



40
41
42
# File 'lib/evrythng/client/properties.rb', line 40

def property_create(thng_id, key, value, options={})
  post("thngs/#{thng_id}/properties", options.merge(:key => key, :value => value))
end

#property_update(thng_id, key, value, options = {}) ⇒ Hash

Updates a property

Examples:

Update ‘Volume’ property for a thng with id 4f2133f39f5c550c2000016a

Evrythng.property_update('4f2133f39f5c550c2000016a', 'Volume', '40')

Parameters:

  • thng_id (String)

    The id of the thng to update property for.

  • key (String)

    The key of property.

  • value (String)

    The value of property.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Hash)

    The updated property.

See Also:



54
55
56
# File 'lib/evrythng/client/properties.rb', line 54

def property_update(thng_id, key, value, options={})
  put("thngs/#{thng_id}/properties/#{key}", options.merge(:value => value))
end