module Nearmiss::Client::Companies

Methods for the Companies API

Public Instance Methods

companies(options = {}) click to toggle source

List companies

@note Shows a list of companies for the users organization aka account

@return [Array<Sawyer::Resource>] List of companys

# File lib/toolhound-ruby/client/companies.rb, line 13
def companies(options = {})
  paginate "companies", options
end
Also aliased as: list_companies
company(company, options = {}) click to toggle source

Get a single company

@param company [String] UUID of company to fetch @return [Sawyer::Resource] Project information

# File lib/toolhound-ruby/client/companies.rb, line 23
def company(company, options = {})
  get "#{company_path(company)}", options
end
create_company(options = {}) click to toggle source

Create a company

@param options [Hash] Project information. @option options [String] :name e.g. Berkeley Art Museum @option options [String] :company_id e.g. 10611.70 @return [Sawyer::Resource] Newly created company info

# File lib/toolhound-ruby/client/companies.rb, line 33
def create_company(options = {})
  post 'companies', options
end
delete_company(company, options = {}) click to toggle source

Delete a company

@param company [String] Project ID @return [Boolean] Indicating success of deletion

# File lib/toolhound-ruby/client/companies.rb, line 60
def delete_company(company, options = {})
  boolean_from_response :delete, "companies/#{company}", options
end
Also aliased as: remove_company
edit_company(company, options = {}) click to toggle source

Edit a company

@param options [Hash] Project information. @option options [String] :name e.g. Berkeley Art Museum @option options [String] :company_id e.g. 10611.70

@return

[Sawyer::Resource] Newly created company info

@example Update a company

@client.edit_company('some_id', {
  name: "New name of company",
  company_id: "1043.32"
})
# File lib/toolhound-ruby/client/companies.rb, line 51
def edit_company(company, options = {})
  patch "#{company_path(company)}", options
end
list_companies(options = {})
Alias for: companies
remove_company(company, options = {})
Alias for: delete_company

Private Instance Methods

company_path(id) click to toggle source
# File lib/toolhound-ruby/client/companies.rb, line 67
def company_path(id)
  if uuid?(id)
    "companies/#{id}"
  else
    "company/#{id}"
  end
end