Class: Codat::Models::Company
- Defined in:
- lib/codat/models/company.rb
Overview
Companies for a given company.
Constant Summary collapse
- ENDPOINT =
'/companies'
Class Method Summary collapse
Methods inherited from BaseModel
attributes, #format_url, format_url, get, #get, #initialize, post, #post
Constructor Details
This class inherits a constructor from Codat::BaseModel
Class Method Details
.all(params = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/codat/models/company.rb', line 14 def self.all(params = {}) result = get(ENDPOINT, params) return [] if result.status == 404 return result.body if result.status == 400 result.body[:results].map { |company| new(json: company) } end |
.create(params = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/codat/models/company.rb', line 24 def self.create(params = {}) url = format_url(ENDPOINT, {}) result = post(url, params) return { error: 'An error occured.' } if result.status == 404 || result.status == 400 new(json: result.body) end |