Sha256: d93de1a7973594aa2c5862628555b8c6c03d4ee5b6dc6cefe7186286bc04c8be

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

module Evrythng
  class Client
    # Defines methods related to collections
    module Collections
      # Returns a list of collections
      #
      # @format :json, :xml
      # @authenticated true
      # @rate_limited true
      # @param options [Hash] A customizable set of options.
      # @return [Hashie::Mash] The requested list of collections.
      # @see http://dev.evrythng.net/doc/get/collections
      # @example Return the list of collections
      #   Evrythng.collections
      def collections(options={})
        response = get('collections', options)
        format.to_s.downcase == 'xml' ? response['collections'] : response
      end

      # Creates a collection
      #
      # @format :json, :xml
      # @authenticated true
      # @rate_limited false
      # @param name [String] The name of collection.
      # @param description [String] The description of collection.
      # @param options [Hash] A customizable set of options.
      # @return [Hashie::Mash] The created collection.
      # @see http://dev.evrythng.net/doc/post/collections
      # @example Create the authenticating user's collection
      #   Evrythng.collection_create("This is a new collection!", "Here comes the description.")
      def collection_create(name, description=nil, options={})
        response = post('collections', options.merge(:collection => { :name => name, :description => description }))
        format.to_s.downcase == 'xml' ? response['collection'] : response
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evrythng-0.0.5 lib/evrythng/client/collections.rb