Class: TrackUnit::Resource
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- TrackUnit::Resource
- Defined in:
- lib/trackunit/resource.rb
Direct Known Subclasses
Class Method Summary collapse
Class Method Details
.serialize_response(response) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/trackunit/resource.rb', line 3 def self.serialize_response(response) raise TrackUnit::Error if response.blank? raise TrackUnit::AuthorizationError.new(response.) if response.code == 401 raise TrackUnit::Error.new(response.) unless response.code == 200 serialized_data = [] response.deep_transform_keys(&:underscore)['list'].each do |unit| serialized_data << new(unit) end serialized_data end |