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