class APIHub::Company

Public Class Methods

[](values, options = {})
Alias for: find
find(values, options = {}) click to toggle source
# File lib/apihub/company.rb, line 6
def self.find(values, options = {})
  unless values.is_a?(Hash)
    values = {:id => values}
  end

  options = options.dup
  params  = options.delete(:params) || {}

  if domain = values[:domain]
    response = get(uri(:domain, domain), params, options)

  elsif id = values[:id]
    response = get(id, params, options)

  else
    raise ArgumentError, 'Invalid values'
  end

  if response.status == 202
    self.new(pending: true)
  else
    self.new(response)
  end

rescue Nestful::ResourceNotFound
end
Also aliased as: []