Class: Unit::Resource::BaseResource
- Inherits:
-
Object
- Object
- Unit::Resource::BaseResource
- Defined in:
- lib/unit/api_resources/base_resource.rb
Direct Known Subclasses
Class Method Summary collapse
-
.response_handler(response) ⇒ Object
Check the response code and return a UnitResponse or UnitError.
Class Method Details
.response_handler(response) ⇒ Object
Check the response code and return a UnitResponse or UnitError
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/unit/api_resources/base_resource.rb', line 11 def response_handler(response) included = response["included"].nil? ? nil : response["included"] = response["meta"].nil? ? nil : response["meta"] case response.code when 200...300 Unit::UnitResponse.new(response["data"], included, ) else Unit::UnitError.from_json_api(response) end end |