import { ErrorHandler } from "./ErrorHandler"; import { Callback, ClientOptions, FilteringParameters } from "./models"; /** * Base client class from which client classes can be implemented, in our case, AccountClient and ServerClient classes. * This class is NOT intended to be instantiated directly. */ export default abstract class BaseClient { /** * Client connection configuration options. * You may modify these values and new clients will use them. * Any values provided to a Client constructor will override default options. */ static DefaultOptions: ClientOptions.Configuration; clientOptions: ClientOptions.Configuration; clientVersion: string; protected errorHandler: ErrorHandler; private readonly authHeader; private readonly token; protected constructor(token: string, authHeader: string, configOptions?: ClientOptions.Configuration); /** * Process http request with sending body - data. * * @see processRequest for more details. */ protected processRequestWithBody(method: ClientOptions.HttpMethod, path: string, body: (null | object), callback?: Callback): Promise; /** * Process http request without sending body - data. * * @see processRequest for more details. */ protected processRequestWithoutBody(method: ClientOptions.HttpMethod, path: string, queryParameters?: object, callback?: Callback): Promise; /** * Set default values for count and offset when doing filtering with API requests if they are not specified by filter. */ protected setDefaultPaginationValues(filter: FilteringParameters): void; /** * Process request for Postmark ClientOptions. * * @param method - see processHttpRequest for details * @param path - see processHttpRequest for details * @param queryParameters - see processHttpRequest for details * @param body - see processHttpRequest for details * @param callback - callback function to be executed. * * @returns A promise that will complete when the API responds (or an error occurs). */ private processRequest; /** * Process HTTP request. * * @param method - Which type of http request will be executed. * @param path - API URL endpoint. * @param queryParameters - Querystring parameters used for http request. * @param body - Data sent with http request. * * @returns A promise that will complete when the API responds (or an error occurs). */ private processHttpRequest; /** * Process callback function for HTTP request. * * @param httpRequest - HTTP request for which callback will be executed * @param callback - callback function to be executed. */ private processCallbackRequest; /** * Process http request. * * @param method - Which type of http request will be executed. * @param path - API URL endpoint. * @param queryParameters - Querystring parameters used for http request. * @param body - Data sent with http request. */ private httpRequest; /** * Handle http request to return it as Promise. * * @param method - Which type of http request will be executed. * @param path - API URL endpoint. * @param queryParameters - Querystring parameters used for http request. * @param body - Data sent with http request. * * @returns A promise that will complete when the API responds. */ private promisifiedHttpRequest; private getRequestTimeoutInSeconds; private getHttpRequestURL; /** * JSON object with default headers sent by HTTP request. */ private getComposedHttpRequestHeaders; /** * Token can't be empty. * * @param {string} token - HTTP request token */ private verifyToken; }