@tangany/waas
Version:
node.js SDK for Tangany Wallet as a Service API
67 lines (66 loc) • 4.14 kB
TypeScript
import { IAsyncRequestStatus, ISearchOptions } from "./interfaces/common";
import { IRequestSearchParams } from "./interfaces/requests";
import { RequestIterable } from "./iterables/auto-pagination/request-iterable";
import { RequestPageIterable } from "./iterables/pagewise/request-page-iterable";
import { Waas } from "./waas";
import { IWaasMethod } from "./waas-method";
/**
* Instantiates a new interface to interact with asynchronous requests
* CAUTION: This class is the default implementation and just passes through the result received from the API when {@link get} is called.
* Thus, if a type is supplied for `TOutput` that does not match the format of the API response in `output`, the return type suggests that a conversion occurred.
* However, this is not the case. Therefore, use a child class with appropriate overrides (like {@link EthTransactionRequest}) if a conversion of the output is necessary.
* @param waas - {@link Waas} instance
* @param [id] - Asynchronous request id
* @template TOutput - Type of the request output (for child classes the type **after** conversion)
*/
export declare class Request<TOutput extends Record<string, any>> implements IWaasMethod {
waas: Waas;
readonly id?: string | undefined;
constructor(waas: Waas, id?: string | undefined);
/**
* Retrieves the current status for a long-running asynchronous request
* @see [docs]{@link https://docs.tangany.com/#a6351116-3e2c-4f02-add8-d424c6212f60}
*/
get(): Promise<IAsyncRequestStatus<TOutput>>;
protected fetchStatus<S>(): Promise<IAsyncRequestStatus<S>>;
/**
* Waits until the asynchronous request is completed and then resolves or rejects on error or timeout.
* This method does _not_ evaluate the output of the process (for example, the transaction status)
* because asynchronous requests are used for arbitrary calls and their output therefore varies.
* Attention: The method polls the API frequently and may result in excessive quota usage.
* @param [timeout] - Number of seconds after which the method stops waiting and rejects
* @param [pollingInterval] - Delay between API calls for polling (in milliseconds)
*/
wait(timeout?: number, pollingInterval?: number): Promise<IAsyncRequestStatus<TOutput>>;
__test_convertSearchParamsToURL: (...args: any) => string;
/**
* Converts an {@link IRequestSearchParams} object to a valid url with query parameter
* @param [params] - Query parameters for filtering the request statuses
* @private
*/
private static convertSearchParamsToURL;
/**
* Returns an asynchronous iterable to iterate **page by page** through the request statuses that matched the search parameters.
* @see [docs]{@link https://docs.tangany.com/#72b95742-6682-4dae-a802-4bbd504df9f4}
* @param [params] - Optional search parameters
*/
list(params?: IRequestSearchParams): RequestPageIterable;
/**
* Returns an asynchronous iterable that yields **one request status object per iteration**.
* A page of request statuses that match the search parameters is fetched and saved once, so that all items can be returned one by one.
* After that, the next page is loaded from the API and processed item by item again.
* @param [params] - Optional search parameters
* @param [options] - Additional options that do not affect the API request but the SDK-side processing
* @see [docs]{@link https://docs.tangany.com/#72b95742-6682-4dae-a802-4bbd504df9f4}
*/
list(params?: IRequestSearchParams, options?: {
autoPagination: true;
}): RequestIterable;
/**
* Returns an asynchronous iterable to iterate **page by page** through the request statuses that matched the search parameters.
* @param [params] - Optional search parameters
* @param [options] - Additional options that do not affect the API request but the SDK-side processing
* @see [docs]{@link https://docs.tangany.com/#72b95742-6682-4dae-a802-4bbd504df9f4}
*/
list(params?: IRequestSearchParams, options?: ISearchOptions): RequestPageIterable;
}