lib/codat/models/company.rb in codat-0.1.4 vs lib/codat/models/company.rb in codat-0.1.5

- old
+ new

@@ -16,30 +16,28 @@ # Returns the list of companies in the Codat account. def self.all(params = {}) result = get(ENDPOINTS[:collection], params) - return [] if result.status == 404 + return [] unless successful_response?(result) - return result.body if result.status == 400 - result.body[:results].map { |company| new(json: company) } end def self.find(company_id) url = format_url(ENDPOINTS[:single], company_id: company_id) result = get(url) - return nil if result.status == 404 + return nil unless successful_response?(result) new(json: result.body) end def self.create(params = {}) result = post(ENDPOINTS[:collection], params) - return { error: 'An error occured.' } if result.status == 404 || result.status == 400 + return { error: 'An error occured.' } unless successful_response?(result) new(json: result.body) end end end