Class: Singleplatform::Response
- Inherits:
-
Object
- Object
- Singleplatform::Response
- Defined in:
- lib/singleplatform/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
-
#next_page ⇒ Object
Returns the value of attribute next_page.
-
#origin ⇒ Object
Returns the value of attribute origin.
Instance Method Summary collapse
-
#initialize(args) ⇒ Response
constructor
A new instance of Response.
-
#next ⇒ Hashie::Mash
An iterator for retrieving the next page of results from API response.
Constructor Details
#initialize(args) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 |
# File 'lib/singleplatform/response.rb', line 7 def initialize(args) @code = args[:code] @body = args[:body] @next_page = args[:body].respond_to?(:next) ? args[:body].next : nil @origin = args[:origin].to_s end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/singleplatform/response.rb', line 5 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
5 6 7 |
# File 'lib/singleplatform/response.rb', line 5 def code @code end |
#next_page ⇒ Object
Returns the value of attribute next_page.
5 6 7 |
# File 'lib/singleplatform/response.rb', line 5 def next_page @next_page end |
#origin ⇒ Object
Returns the value of attribute origin.
5 6 7 |
# File 'lib/singleplatform/response.rb', line 5 def origin @origin end |
Instance Method Details
#next ⇒ Hashie::Mash
Note:
Will only work with Client#locations_updated_since and
An iterator for retrieving the next page of results from API response.
#photos_updated_since at this time.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/singleplatform/response.rb', line 21 def next return nil if next_page.nil? || next_page.empty? params = prepare_params(next_page) client = Singleplatform.new( client_id: ENV['SINGLEPLATFORM_CLIENT_ID'], client_secret: ENV['SINGLEPLATFORM_CLIENT_SECRET'] ) new_page = client.public_send( origin.to_sym, params.delete('date').first, params ) refresh(new_page) end |