Class: GeniusReferrals::Page
- Inherits:
-
Struct
- Object
- Struct
- GeniusReferrals::Page
- Defined in:
- lib/genius_referrals/response.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#page ⇒ Object
Returns the value of attribute page.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#results ⇒ Object
Returns the value of attribute results.
-
#total ⇒ Object
Returns the value of attribute total.
Class Method Summary collapse
-
.from_api(payload) ⇒ Object
Build a pagination wrapper from the standard list response shape.
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit
13 14 15 |
# File 'lib/genius_referrals/response.rb', line 13 def limit @limit end |
#page ⇒ Object
Returns the value of attribute page
13 14 15 |
# File 'lib/genius_referrals/response.rb', line 13 def page @page end |
#raw ⇒ Object
Returns the value of attribute raw
13 14 15 |
# File 'lib/genius_referrals/response.rb', line 13 def raw @raw end |
#results ⇒ Object
Returns the value of attribute results
13 14 15 |
# File 'lib/genius_referrals/response.rb', line 13 def results @results end |
#total ⇒ Object
Returns the value of attribute total
13 14 15 |
# File 'lib/genius_referrals/response.rb', line 13 def total @total end |
Class Method Details
.from_api(payload) ⇒ Object
Build a pagination wrapper from the standard list response shape.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/genius_referrals/response.rb', line 15 def self.from_api(payload) envelope = APIResponse.from_api(payload) data = envelope.data if data.is_a?(Hash) new( results: data['results'] || [], page: data['page'], limit: data['limit'], total: data['total'], raw: payload ) elsif data.is_a?(Array) new(results: data, page: nil, limit: nil, total: nil, raw: payload) else new(results: [], page: nil, limit: nil, total: nil, raw: payload) end end |