/// import { AxiosError, AxiosInstance, AxiosResponse } from 'axios'; import * as https from 'https'; import { CsrfToken } from '..'; import { SASjsRequest, HttpClient, VerboseMode } from '../types'; export declare class RequestClient implements HttpClient { protected baseUrl: string; private requests; private requestsLimit; private httpInterceptor?; private verboseMode; protected csrfToken: CsrfToken; protected fileUploadCsrfToken: CsrfToken | undefined; protected httpClient: AxiosInstance; constructor(baseUrl: string, httpsAgentOptions?: https.AgentOptions, requestsLimit?: number, verboseMode?: VerboseMode); setConfig(baseUrl: string, httpsAgentOptions?: https.AgentOptions): void; saveLocalStorageToken(accessToken: string, refreshToken: string): void; getCsrfToken(type?: 'general' | 'file'): CsrfToken | undefined; clearCsrfTokens(): void; clearLocalStorageTokens(): void; getBaseUrl(): string; /** * this method returns all requests, an array of SASjsRequest type * @returns SASjsRequest[] */ getRequests: () => SASjsRequest[]; /** * this method clears the requests array, i.e set to empty */ clearRequests: () => void; /** * this method appends the response from sasjs request to requests array * @param response - response from sasjs request * @param program - name of program * @param debug - a boolean that indicates whether debug was enabled or not */ appendRequest(response: any, program: string, debug: boolean): void; get(url: string, accessToken: string | undefined, contentType?: string, overrideHeaders?: { [key: string]: string | number; }, debug?: boolean): Promise<{ result: T; etag: string; status: number; }>; post(url: string, data: any, accessToken: string | undefined, contentType?: string, overrideHeaders?: { [key: string]: string | number; }, additionalSettings?: { [key: string]: string | number; }): Promise<{ result: T; etag: string; }>; put(url: string, data: any, accessToken: string | undefined, overrideHeaders?: { [key: string]: string | number; }): Promise<{ result: T; etag: string; }>; delete(url: string, accessToken?: string): Promise<{ result: T; etag: string; }>; patch(url: string, data?: any, accessToken?: string): Promise<{ result: T; etag: string; }>; uploadFile(url: string, content: string, accessToken?: string): Promise; authorize: (response: string) => Promise; /** * Adds colors to the string. * If verboseMode is set to 'bleached', colors should be disabled * @param str - string to be prettified. * @returns - prettified string */ private prettifyString; /** * Formats HTTP request/response body. * @param body - HTTP request/response body. * @returns - formatted string. */ private parseInterceptedBody; private defaultInterceptionCallBack; /** * Sets verbose mode. * @param verboseMode - value of the verbose mode, can be true, false or bleached(without extra colors). */ setVerboseMode: (verboseMode: VerboseMode) => void; /** * Turns on verbose mode to log every HTTP response. * @param successCallBack - function that should be triggered on every HTTP response with the status 2**. * @param errorCallBack - function that should be triggered on every HTTP response with the status different from 2**. */ enableVerboseMode: (successCallBack?: (axiosResponse: AxiosResponse | AxiosError) => AxiosResponse | AxiosError, errorCallBack?: (axiosResponse: AxiosResponse | AxiosError) => AxiosResponse | AxiosError) => void; /** * Turns off verbose mode to log every HTTP response. */ disableVerboseMode: () => void; protected getHeaders: (accessToken: string | undefined, contentType: string) => any; protected parseAndSetFileUploadCsrfToken: (response: AxiosResponse) => void; protected parseAndSetCsrfToken: (response: AxiosResponse) => void; private parseCsrfToken; protected handleError: (e: any, callback: any, debug?: boolean) => Promise; protected parseResponse(response: AxiosResponse): { result: T; etag: any; log?: string | undefined; status: number; }; private createHttpClient; } export declare const throwIfError: (response: AxiosResponse) => void;