1 |
|
2 |
|
3 | import { AxiosResponse, AxiosRequestConfig } from "axios";
|
4 | import { Readable } from "node:stream";
|
5 | interface httpClientConfig extends Partial<AxiosRequestConfig> {
|
6 | baseURL?: string;
|
7 | defaultHeaders?: any;
|
8 | responseParser?: <T>(res: AxiosResponse) => T;
|
9 | }
|
10 | export default class HTTPClient {
|
11 | private instance;
|
12 | private readonly config;
|
13 | constructor(config?: httpClientConfig);
|
14 | get<T>(url: string, params?: any): Promise<T>;
|
15 | getStream(url: string, params?: any): Promise<Readable>;
|
16 | post<T>(url: string, body?: any, config?: Partial<AxiosRequestConfig>): Promise<T>;
|
17 | private responseParse;
|
18 | put<T>(url: string, body?: any, config?: Partial<AxiosRequestConfig>): Promise<T>;
|
19 | postForm<T>(url: string, body?: any): Promise<T>;
|
20 | postFormMultipart<T>(url: string, form: FormData): Promise<T>;
|
21 | putFormMultipart<T>(url: string, form: FormData, config?: Partial<AxiosRequestConfig>): Promise<T>;
|
22 | toBuffer(data: Buffer | Readable): Promise<Buffer>;
|
23 | postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>;
|
24 | postBinaryContent<T>(url: string, body: Blob): Promise<T>;
|
25 | delete<T>(url: string, params?: any): Promise<T>;
|
26 | private wrapError;
|
27 | }
|
28 | export {};
|