Sha256: c7c4a53b26ea5696867766d0b4bf1c8e47cd74877e4723ec4dc60e4497fb3f9c

Contents?: true

Size: 1.89 KB

Versions: 39

Compression:

Stored size: 1.89 KB

Contents

module Nearmiss
  class Client

    # Methods for the Categories API
    #
    module Categories

      # List categories
      #
      # @return [Array<Sawyer::Resource>] List of categories
      def categories(options = {})
        paginate "categories", options
      end
      alias :list_categories :categories
      alias :list_cats :categories
      alias :cats :categories           

      # Get a single category
      #
      # @param category [String] ID of category to fetch
      # @return [Sawyer::Resource] Category information
      #
      def category(category, options={})
        get "categories/#{category}", options
      end
      alias :cat :category           


      # Create a category
      #
      # @param options [Hash] Category information.
      # @option options [String] :name e.g. Name of category
      # @return [Sawyer::Resource] Newly created category info
      def create_category(options = {})
        post 'categories', options
      end
      alias :create_cat :create_category

      # Edit a category
      #
      # @param options [Hash] Project information.
      # @option options [String] :name e.g. Tools
      #
      # @return
      #   [Sawyer::Resource] Edited category info
      # @example Update a category
      #   @client.edit_category('some_id', {
      #     name: "New name of category",
      #   })

      def edit_category(category, options = {})
        patch "categories/#{category}", options
      end
      alias :edit_cat :edit_category


      # Delete a category
      #
      # @param category [String] Project ID
      # @return [Boolean] Indicating success of deletion
      #
      def delete_category(category, options = {})
        boolean_from_response :delete, "categories/#{category}", options
      end
      alias :delete_cat :delete_category
      alias :remove_category :delete_category
      alias :remove_cat :delete_category


    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
toolhound-ruby-1.0.37 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.36 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.35 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.34 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.33 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.32 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.31 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.30 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.29 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.28 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.27 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.26 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.25 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.24 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.23 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.22 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.21 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.20 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.19 lib/toolhound-ruby/client/categories.rb
toolhound-ruby-1.0.18 lib/toolhound-ruby/client/categories.rb