import { AxiosRequestConfig, AxiosInstance, AxiosError } from 'axios'; import { default as Logger } from '../tools/log/logger'; import { IToken } from '../type/index'; export interface IResponseSuccess { code: number; data: any; } export interface IResponseFailed { code: number; data: any; } export interface IAxiosRequestConfig extends AxiosRequestConfig { sign?: 0 | 1; clientSecret?: string; clientId?: string; baseUrl?: string; callback?: (data: any) => void; } export declare const invalidError: { token_expired: number; gateway_timestamp_expired: number; }; declare class HttpClient { commonOption: IAxiosRequestConfig; axios: AxiosInstance; tokenInfo: any; logger: Logger | null; private clientId; private clientSecret; private retryCount; private nua; private xyApiGatewaySDK; constructor(commonOption: IAxiosRequestConfig); /** * 获取SDK n-ua 信息 * * @param { string } version - SDK版本号 * @returns { string } n-ua */ private getNuaInfo; getTokenInfo(): any; getClientInfo(): { clientType: string; clientId: string; clientSecret: string; 'n-ua': string; }; setTokenInfo(tokenInfo: IToken | null): void; setLogger(logger: Logger): void; setBaseUrl(url: string): void; setClientInfo({ clientId, clientSecret }: { clientId: string; clientSecret: string; }): void; private initXyApiGatewaySDK; private setSignHeader; /** * 处理需要退出登录的情况 */ private handleAuthError; refreshToken({ baseURL, refresh_token }: { baseURL?: string | undefined; refresh_token?: string | undefined; }): Promise; /** * 处理网关时间戳过期 * * @param { AxiosError } error - response * @returns { AxiosRequestConfig | null } */ handleGatewayTimestampExpired(error: AxiosError): Promise; /** * token失效,刷新token * * @param { AxiosError } error - response * @returns */ handleTokenExpired(error: AxiosError): Promise | undefined>; assignOptions: (option?: AxiosRequestConfig) => IAxiosRequestConfig & AxiosRequestConfig & { params: any; }; request: (url: string, option?: IAxiosRequestConfig) => any; get: (url: string, option?: IAxiosRequestConfig) => any; put: (url: string, data?: any, option?: AxiosRequestConfig) => any; post: (url: string, data?: any, option?: AxiosRequestConfig) => any; delete: (url: string, option?: AxiosRequestConfig) => any; } export default HttpClient;