lib/evrythng/client/thngs.rb in evrythng-0.0.5 vs lib/evrythng/client/thngs.rb in evrythng-0.1.0
- old
+ new
@@ -2,37 +2,41 @@
class Client
# Defines methods related to thngs
module Thngs
# Returns a list of thngs
#
- # @format :json, :xml
- # @authenticated true
- # @rate_limited true
# @param options [Hash] A customizable set of options.
- # @return [Hashie::Mash] The requested list of thngs.
- # @see http://developer.evrythng.net/thngs
+ # @return [Array] The requested list of thngs.
+ # @see http://dev.evrythng.com/thngs
# @example Return the list of thngs
# Evrythng.thngs
def thngs(options={})
- response = get('thngs', options)
- format.to_s.downcase == 'xml' ? response['thngs'] : response
+ get('thngs', options)
end
+ # Returns a single thng, specified by id
+ #
+ # @param id [String] The id of the desired thng.
+ # @param options [Hash] A customizable set of options.
+ # @return [Hash] The requested thng.
+ # @see http://dev.evrythng.com/thngs
+ # @example Return the thng with the id 4f2133f39f5c550c2000016a
+ # Evrythng.thng('4f2133f39f5c550c2000016a')
+ def thng(id, options={})
+ get("thngs/#{id}", options)
+ end
+
# Creates a thng
#
- # @format :json, :xml
- # @authenticated true
- # @rate_limited false
- # @param identifier [String] The identifier of thng.
+ # @param name [String] The name of thng.
# @param description [String] The description of thng.
# @param options [Hash] A customizable set of options.
- # @return [Hashie::Mash] The created thng.
- # @see http://developer.evrythng.net/thngs
+ # @return [Hash] The created thng.
+ # @see http://dev.evrythng.com/thngs
# @example Create the authenticating user's thng
# Evrythng.thng_create("my.test.thng", "Here comes the description.")
- def thng_create(identifier, description=nil, options={})
- response = post('thngs', options.merge(:thng => { :identifier => identifier, :description => description }))
- format.to_s.downcase == 'xml' ? response['thng'] : response
+ def thng_create(name, description=nil, options={})
+ post('thngs', options.merge(:name => name, :description => description))
end
end
end
end