Class: KlaviyoAPI::Collections::MarkerCollection
- Inherits:
-
ActiveResource::Collection
- Object
- ActiveResource::Collection
- KlaviyoAPI::Collections::MarkerCollection
- Defined in:
- lib/klaviyo_api/collections/marker_collection.rb
Overview
This collection is used for item types that rely on markers to provide pagination.
Direct Known Subclasses
EventCollection, ListExclusionCollection, ListMembershipCollection
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#marker ⇒ Object
Returns the value of attribute marker.
-
#next ⇒ Object
Returns the value of attribute next.
Instance Method Summary collapse
-
#initialize(response = {}) ⇒ MarkerCollection
constructor
A new instance of MarkerCollection.
- #more_pages? ⇒ Boolean
- #next_page ⇒ Object
- #next_page_marker_name ⇒ Object
Constructor Details
#initialize(response = {}) ⇒ MarkerCollection
Returns a new instance of MarkerCollection.
9 10 11 12 13 14 15 16 17 |
# File 'lib/klaviyo_api/collections/marker_collection.rb', line 9 def initialize(response = {}) # May not exist @count = response.delete 'count' @next = response['next'] || response['marker'] @marker = @next @elements = response['data'] || response['records'] || [] end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
7 8 9 |
# File 'lib/klaviyo_api/collections/marker_collection.rb', line 7 def count @count end |
#marker ⇒ Object
Returns the value of attribute marker.
7 8 9 |
# File 'lib/klaviyo_api/collections/marker_collection.rb', line 7 def marker @marker end |
#next ⇒ Object
Returns the value of attribute next.
7 8 9 |
# File 'lib/klaviyo_api/collections/marker_collection.rb', line 7 def next @next end |
Instance Method Details
#more_pages? ⇒ Boolean
23 24 25 |
# File 'lib/klaviyo_api/collections/marker_collection.rb', line 23 def more_pages? !@next.nil? end |
#next_page ⇒ Object
27 28 29 30 31 32 |
# File 'lib/klaviyo_api/collections/marker_collection.rb', line 27 def next_page # Return empty collection if no other pages return self.class.new unless more_pages? first.class.all params: { **first., **original_params, "#{next_page_marker_name}": marker } end |
#next_page_marker_name ⇒ Object
19 20 21 |
# File 'lib/klaviyo_api/collections/marker_collection.rb', line 19 def next_page_marker_name 'marker' end |