class Codat::Models::Company
Companies for a given company.
Constants
- ENDPOINTS
Public Class Methods
all(params = {})
click to toggle source
Returns the list of companies in the Codat
account.
# File lib/codat/models/company.rb, line 18 def self.all(params = {}) result = get(ENDPOINTS[:collection], params) return [] unless successful_response?(result) result.body[:results].map { |company| new(json: company) } end
create(params = {})
click to toggle source
# File lib/codat/models/company.rb, line 36 def self.create(params = {}) result = post(ENDPOINTS[:collection], params) return { error: 'An error occured.' } unless successful_response?(result) new(json: result.body) end
find(company_id)
click to toggle source
# File lib/codat/models/company.rb, line 26 def self.find(company_id) url = format_url(ENDPOINTS[:single], company_id: company_id) result = get(url) return nil unless successful_response?(result) new(json: result.body) end