Zum Hauptinhalt springen

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:

  1. In processOrdersRequest use getPageToken
  2. In provideOrders use storeNextPageToken

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

NameTypeDescription
keystringAn unique identifier. This is used to fetch the data from the connection config.
pagenumberThe 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

NameTypeDescription
keystringAn unique identifier. This is used to store the data in the connection config.
currentPagenumberThe current requested page
token?stringThe token for the next page.

Returns

void

Defined in

src/utilities/page-number-converter.ts:56