UNPKG

2.93 kBTypeScriptView Raw
1import { ErrorHandler } from "./errors/ErrorHandler";
2import { Callback, ClientOptions, FilteringParameters, HttpClient } from "./models";
3/**
4 * Base client class from which client classes can be implemented, in our case, AccountClient and ServerClient classes.
5 * This class is NOT intended to be instantiated directly.
6 */
7export default abstract class BaseClient {
8 clientVersion: string;
9 httpClient: HttpClient;
10 protected errorHandler: ErrorHandler;
11 private readonly authHeader;
12 private readonly token;
13 protected constructor(token: string, authHeader: string, configOptions?: ClientOptions.Configuration);
14 setClientOptions(configOptions: ClientOptions.Configuration): void;
15 getClientOptions(): ClientOptions.Configuration;
16 /**
17 * Process http request with sending body - data.
18 *
19 * @see processRequest for more details.
20 */
21 protected processRequestWithBody<T>(method: ClientOptions.HttpMethod, path: string, body: (null | object), callback?: Callback<T>): Promise<T>;
22 /**
23 * Process http request without sending body - data.
24 *
25 * @see processRequest for more details.
26 */
27 protected processRequestWithoutBody<T>(method: ClientOptions.HttpMethod, path: string, queryParameters?: object, callback?: Callback<T>): Promise<T>;
28 /**
29 * Process request for Postmark ClientOptions.
30 *
31 * @param method - see processHttpRequest for details
32 * @param path - see processHttpRequest for details
33 * @param queryParameters - see processHttpRequest for details
34 * @param body - see processHttpRequest for details
35 * @param callback - callback function to be executed.
36 *
37 * @returns A promise that will complete when the API responds (or an error occurs).
38 */
39 private processRequest;
40 /**
41 * Process HTTP request.
42 *
43 * @param method - Which type of http request will be executed.
44 * @param path - API URL endpoint.
45 * @param queryParameters - Querystring parameters used for http request.
46 * @param body - Data sent with http request.
47 *
48 * @returns A promise that will complete when the API responds (or an error occurs).
49 */
50 private processHttpRequest;
51 /**
52 * Process callback function for HTTP request.
53 *
54 * @param httpRequest - HTTP request for which callback will be executed
55 * @param callback - callback function to be executed.
56 */
57 private processCallbackRequest;
58 /**
59 * JSON object with default headers sent by HTTP request.
60 */
61 private getComposedHttpRequestHeaders;
62 /**
63 * Token can't be empty.
64 *
65 * @param {string} token - HTTP request token
66 */
67 private verifyToken;
68 /**
69 * Set default values for count and offset when doing filtering with API requests if they are not specified by filter.
70 */
71 protected setDefaultPaginationValues(filter: FilteringParameters): void;
72}