@tangany/waas
Version:
node.js SDK for Tangany Wallet as a Service API
26 lines (25 loc) • 1.15 kB
TypeScript
import { IPaginationResponse, ISearchRequestConfig } from "../../interfaces/common";
import { Waas } from "../../waas";
export interface IDefaultIteratorValue<T> {
hits: {
total: number;
};
list: T[];
}
/**
* Custom asynchronous iterable that reads WaaS resources based on the passed URL and search parameters.
* The iterator returns the entire page of the API pagination mechanism and is able to iterate through next and previous pages.
*/
export declare abstract class ResourcePageIterable<TApiResponse extends IPaginationResponse, TIteratorValue> implements AsyncIterableIterator<TIteratorValue> {
protected readonly waas: Waas;
private readonly initialRequest;
private nextPageUrl;
private previousPageUrl;
private isInitialRequestExecuted;
constructor(waas: Waas, initialRequest: ISearchRequestConfig);
[Symbol.asyncIterator](): ResourcePageIterable<TApiResponse, TIteratorValue>;
next(): Promise<IteratorResult<TIteratorValue>>;
previous(): Promise<IteratorResult<TIteratorValue>>;
protected abstract convertApiResponse(res: TApiResponse): TIteratorValue;
private iteratePage;
}