PaginatedData
public protocol PaginatedData
The paginated data protocol defines a common interface for result types of paginated requests. The properties of the protocol can be leveraged to enable handling paginated requests automatically by observing the provided properties.
-
The actual type of the requested data (usually provided as a field of the top-level JSON).
Declaration
Swift
associatedtype DataType
-
The actual data that is received by the request.
Declaration
Swift
var data: DataType { get }
-
The index of the current page. By convention, an index of 1 indicates the first page. You will need to overwrite the
zeroBasedPageIndex
property to returntrue
when you want to use an API where the first page has index 0.Declaration
Swift
var page: Int { get }
-
The index of the first element of the data (inclusive).
Declaration
Swift
var from: Int { get }
-
The index of the last element of the data (exclusive).
Declaration
Swift
var to: Int { get }
-
The requested number of items on the page. Might be larger than the actual number of elements.
Declaration
Swift
var chunk: Int { get }
-
The total number of elements that are available.
Declaration
Swift
var totalCount: Int { get }
-
The total number of pages that are available given the chunk.
Declaration
Swift
var totalPageCount: Int { get }
-
zeroBasedPageIndex
Default implementationWhether the first page of the paginated request is indexed with 0. By default, this property is
false
and indicates that the first page is indexed with 1.Default Implementation
Declaration
Swift
var zeroBasedPageIndex: Bool { get }
-
count
Extension methodThe number of elements currently returned.
Declaration
Swift
public var count: Int { get }
-
isLastPage
Extension methodReturns whether the returned page of the data is the last page available.
Declaration
Swift
public var isLastPage: Bool { get }