import { ResponseType } from './constants'; import type { HookErrorFn, HookFn, HookReqFn, HookResFn } from './hook'; import type { RequestBaseOptions, RequestOptions } from './request'; import type { Response, ResponseData } from './response'; import { HookManager, HookName } from './hook'; import type { AuthorizationHeader } from './header'; export declare class Client { readonly '@instanceof': symbol; defaults: RequestBaseOptions; protected headers: Headers; protected hookManager: HookManager; constructor(input?: RequestBaseOptions); /** * Return base url * * @return string */ getBaseURL(): string | undefined; /** * Overwrite existing base url. * * @param url */ setBaseURL(url: string): this; /** * Set a header for all upcoming requests. * * @param key * @param value */ setHeader(key: string, value: any): this; /** * Get a header for all upcoming requests. * * @param key */ getHeader(key: string): string | null; /** * Unset a specific for all upcoming requests. * * @param key */ unsetHeader(key: string): this; /** * Unset all defined headers for the upcoming requests. */ unsetHeaders(): this; /** * Set an authorization header (basic, api-key, bearer). * * @param options */ setAuthorizationHeader(options: AuthorizationHeader): this; /** * Get authorization header. */ getAuthorizationHeader(): string | undefined; /** * Unset an authorization header. */ unsetAuthorizationHeader(): this; /** * Make a custom request. * * @param config */ request>>(config: RequestOptions): Promise; /** * Request a resource with the GET method. * * @param url * @param config */ get>>(url: string, config?: RequestBaseOptions): Promise; /** * Delete a resource with the DELETE method. * * @param url * @param config */ delete>>(url: string, config?: RequestBaseOptions): Promise; /** * Make a verification resource with the HEAD method. * * @param url * @param config */ head>>(url: string, config?: RequestBaseOptions): Promise; /** * Create a resource with the POST method. * * @param url * @param body * @param config */ post>>(url: string, body?: any, config?: RequestBaseOptions): Promise; /** * Update a resource with the PUT method. * * @param url * @param body * @param config */ put>>(url: string, body?: any, config?: RequestBaseOptions): Promise; /** * Update a resource with the PATCH method. * * @param url * @param body * @param config */ patch>>(url: string, body?: any, config?: RequestBaseOptions): Promise; /** * Register a hook fn. * * @param name * @param fn */ on(name: `${HookName.REQUEST}`, fn: HookReqFn): number; on(name: `${HookName.RESPONSE}`, fn: HookResFn): number; on(name: `${HookName.RESPONSE_ERROR}` | `${HookName.REQUEST_ERROR}`, fn: HookErrorFn): number; /** * Remove single or specific hook fn(s). * * @param name * @param fn */ off(name: `${HookName}`, fn?: HookFn | number): this; }