Class: KlaviyoAPI::Collections::PaginatedCollection

Inherits:
ActiveResource::Collection
  • Object
show all
Defined in:
lib/klaviyo_api/collections/paginated_collection.rb

Overview

This collection is used for item types that rely on pagination and provide ‘page`, `page_size`, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = {}) ⇒ PaginatedCollection

Returns a new instance of PaginatedCollection.



9
10
11
12
13
14
15
16
17
# File 'lib/klaviyo_api/collections/paginated_collection.rb', line 9

def initialize(response = {})
  @total = response.delete 'total'
  @page = response.delete 'page'
  @page_size = response.delete 'page_size'
  @start = response.delete 'start'
  @end = response.delete 'end'

  @elements = response['data'] || []
end

Instance Attribute Details

#endObject

Returns the value of attribute end.



7
8
9
# File 'lib/klaviyo_api/collections/paginated_collection.rb', line 7

def end
  @end
end

#pageObject

Returns the value of attribute page.



7
8
9
# File 'lib/klaviyo_api/collections/paginated_collection.rb', line 7

def page
  @page
end

#page_sizeObject

Returns the value of attribute page_size.



7
8
9
# File 'lib/klaviyo_api/collections/paginated_collection.rb', line 7

def page_size
  @page_size
end

#startObject

Returns the value of attribute start.



7
8
9
# File 'lib/klaviyo_api/collections/paginated_collection.rb', line 7

def start
  @start
end

#totalObject

Returns the value of attribute total.



7
8
9
# File 'lib/klaviyo_api/collections/paginated_collection.rb', line 7

def total
  @total
end