Class: PageNumberConverter
This class helps you to convert page numbers to page tokens. It should be used by classes that implement the OrderRequester interface to convert a page number to a page token.
A page token is an opaque string that is passed to an OrderProvider instance. The OrderProvider will also return a nextPageToken which is associated with the next page.
Usage:
- In
processOrdersRequest
use getPageToken - In
provideOrders
usestoreNextPageToken
Constructors
constructor
• new PageNumberConverter()
Methods
getPageToken
▸ Static
getPageToken(key
, page
): string
Returns the token for the requested page. If the first page is requested, null will be returned.
Parameters
Name | Type | Description |
---|---|---|
key | string | An unique identifier. This is used to fetch the data from the connection config. |
page | number | The requested page. |
Returns
string
If the page is 1, null, otherwise the page token for the next page.
Throws
Error
If the requested page is out of order (E.g. 1 -> 2 -> 5
)
Throws
Error If the connection config does not contain a token for the page.
Defined in
src/utilities/page-number-converter.ts:28
storeNextPageToken
▸ Static
storeNextPageToken(key
, currentPage
, token?
): void
Stores the token for the next page in the connection config.
Parameters
Name | Type | Description |
---|---|---|
key | string | An unique identifier. This is used to store the data in the connection config. |
currentPage | number | The current requested page |
token? | string | The token for the next page. |
Returns
void
Defined in
src/utilities/page-number-converter.ts:56