Module: Nearmiss::Client::Companies

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

Overview

Methods for the Companies API

Instance Method Summary collapse

Instance Method Details

#companies(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_companies

Note:

Shows a list of companies for the users organization aka account

List companies

Returns:

  • (Array<Sawyer::Resource>)

    List of companys



13
14
15
# File 'lib/toolhound-ruby/client/companies.rb', line 13

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

#company(company, options = {}) ⇒ Sawyer::Resource

Get a single company

Parameters:

  • company (String)

    UUID of company to fetch

Returns:

  • (Sawyer::Resource)

    Project information



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

def company(company, options = {})
  get "#{company_path(company)}", options
end

#create_company(options = {}) ⇒ Sawyer::Resource

Create a company

Parameters:

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

    Project information.

Options Hash (options):

  • :name (String)

    e.g. Berkeley Art Museum

  • :company_id (String)

    e.g. 10611.70

Returns:

  • (Sawyer::Resource)

    Newly created company info



33
34
35
# File 'lib/toolhound-ruby/client/companies.rb', line 33

def create_company(options = {})
  post 'companies', options
end

#delete_company(company, options = {}) ⇒ Boolean Also known as: remove_company

Delete a company

Parameters:

  • company (String)

    Project ID

Returns:

  • (Boolean)

    Indicating success of deletion



60
61
62
# File 'lib/toolhound-ruby/client/companies.rb', line 60

def delete_company(company, options = {})
  boolean_from_response :delete, "companies/#{company}", options
end

#edit_company(company, options = {}) ⇒ Object

Edit a company

Examples:

Update a company

@client.edit_company('some_id', {
  name: "New name of company",
  company_id: "1043.32"
})

Parameters:

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

    Project information.

Options Hash (options):

  • :name (String)

    e.g. Berkeley Art Museum

  • :company_id (String)

    e.g. 10611.70

Returns:

  • Sawyer::Resource

    Newly created company info



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

def edit_company(company, options = {})
  patch "#{company_path(company)}", options
end