Class: GeniusReferrals::APIResponse
- Inherits:
-
Struct
- Object
- Struct
- GeniusReferrals::APIResponse
- Defined in:
- lib/genius_referrals/response.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#data ⇒ Object
Returns the value of attribute data.
-
#raw ⇒ Object
Returns the value of attribute raw.
Class Method Summary collapse
-
.from_api(payload) ⇒ Object
Build a response envelope from the public API
{code, data}shape.
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
2 3 4 |
# File 'lib/genius_referrals/response.rb', line 2 def code @code end |
#data ⇒ Object
Returns the value of attribute data
2 3 4 |
# File 'lib/genius_referrals/response.rb', line 2 def data @data end |
#raw ⇒ Object
Returns the value of attribute raw
2 3 4 |
# File 'lib/genius_referrals/response.rb', line 2 def raw @raw end |
Class Method Details
.from_api(payload) ⇒ Object
Build a response envelope from the public API {code, data} shape.
4 5 6 7 8 9 10 |
# File 'lib/genius_referrals/response.rb', line 4 def self.from_api(payload) if payload.is_a?(Hash) && payload.key?('code') && payload.key?('data') new(code: payload['code'], data: payload['data'], raw: payload) else new(code: nil, data: payload, raw: payload) end end |