Module: Nearmiss::Client::Categories

Defined in:
lib/toolhound-ruby/client/categories.rb

Overview

Methods for the Categories API

Instance Method Summary collapse

Instance Method Details

#categories(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_categories, list_cats, cats

List categories

Returns:

  • (Array<Sawyer::Resource>)

    List of categories



11
12
13
# File 'lib/toolhound-ruby/client/categories.rb', line 11

def categories(options = {})
  paginate "categories", options
end

#category(category, options = {}) ⇒ Sawyer::Resource Also known as: cat

Get a single category

Parameters:

  • category (String)

    ID of category to fetch

Returns:

  • (Sawyer::Resource)

    Category information



23
24
25
# File 'lib/toolhound-ruby/client/categories.rb', line 23

def category(category, options={})
  get "categories/#{category}", options
end

#create_category(options = {}) ⇒ Sawyer::Resource Also known as: create_cat

Create a category

Parameters:

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

    Category information.

Options Hash (options):

  • :name (String)

    e.g. Name of category

Returns:

  • (Sawyer::Resource)

    Newly created category info



34
35
36
# File 'lib/toolhound-ruby/client/categories.rb', line 34

def create_category(options = {})
  post 'categories', options
end

#delete_category(category, options = {}) ⇒ Boolean Also known as: delete_cat, remove_category, remove_cat

Delete a category

Parameters:

  • category (String)

    Project ID

Returns:

  • (Boolean)

    Indicating success of deletion



62
63
64
# File 'lib/toolhound-ruby/client/categories.rb', line 62

def delete_category(category, options = {})
  boolean_from_response :delete, "categories/#{category}", options
end

#edit_category(category, options = {}) ⇒ Object Also known as: edit_cat

Edit a category

Examples:

Update a category

@client.edit_category('some_id', {
  name: "New name of category",
})

Parameters:

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

    Project information.

Options Hash (options):

  • :name (String)

    e.g. Tools

Returns:

  • Sawyer::Resource

    Edited category info



51
52
53
# File 'lib/toolhound-ruby/client/categories.rb', line 51

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