import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import { EventEmitter } from 'events'; import { AccessTokenData, AccessTokenStore, InvalidTokenError, MissingCookieError } from '../auth/'; import { Config } from '../Config'; import { BackendError, ConnectionState } from '../http/'; declare enum TOPIC { ON_CONNECTION_STATE_CHANGE = "HttpClient.TOPIC.ON_CONNECTION_STATE_CHANGE", ON_INVALID_TOKEN = "HttpClient.TOPIC.ON_INVALID_TOKEN" } type SendRequest = { config: AxiosRequestConfig; isFirstTry?: boolean; abortController?: AbortController; }; export interface HttpClient { on(event: TOPIC.ON_CONNECTION_STATE_CHANGE, listener: (state: ConnectionState) => void): this; on(event: TOPIC.ON_INVALID_TOKEN, listener: (error: InvalidTokenError | MissingCookieError) => void): this; } export declare class HttpClient extends EventEmitter { private readonly config; accessTokenStore: AccessTokenStore; readonly client: AxiosInstance; private readonly logger; private connectionState; private readonly requestQueue; private readonly backOffQueue; static readonly TOPIC: typeof TOPIC; private versionPrefix; private enableGzip; constructor(config: Config, accessTokenStore: AccessTokenStore); /** * Toggle gzip compression for sendJSON requests. * @param enabled - true to enable gzip, false to disable */ toggleGzip(enabled: boolean): void; isGzipEnabled(): boolean; getBaseUrl(): string; useVersion(version: number): void; private updateConnectionState; _sendRequest({ config, isFirstTry, abortController }: SendRequest): Promise>; static isAxiosError(errorCandidate: any): errorCandidate is AxiosError; static isBackendError(errorCandidate: any): errorCandidate is AxiosError & { response: BackendError; }; /** * Will return true if the stored access token is still valid (not expired) * * @param {number} errorMargin - Since the expiration date is subject to time shift between client and server, an error margin can be used. Defaults to 10s */ hasValidAccessToken(errorMargin?: number): boolean; refreshAccessToken(): Promise; postAccess(expiredAccessToken?: AccessTokenData, clientId?: string): Promise; /** * Will associate specified client id with session and return newly created access token. * * @param {string} clientId - id of the client with which the new login session will be associated */ associateClientWithSession(clientId: string): Promise; sendRequest(config: AxiosRequestConfig, isSynchronousRequest?: boolean, abortController?: AbortController): Promise>; sendJSON(config: AxiosRequestConfig, isSynchronousRequest?: boolean, abortController?: AbortController): Promise>; sendXML(config: AxiosRequestConfig): Promise>; sendProtocolBuffer(config: AxiosRequestConfig, isSynchronousRequest?: boolean): Promise>; sendProtocolMls(config: AxiosRequestConfig, isSynchronousRequest?: boolean): Promise>; } export {}; //# sourceMappingURL=HttpClient.d.ts.map