UNPKG

@rudderstack/integrations-lib

Version:

A comprehensive TypeScript library providing shared utilities, SDKs, and tools for RudderStack integrations and destinations.

38 lines 1.99 kB
import { ApiResponse, HttpClient, ResponseParser, AxiosClientObservabilityConfig, RequestConfig } from './types'; /** * A wrapper around axios to make http requests * * @class AxiosClient * @classdesc * The `AxiosClient` class is a wrapper around the axios library that provides a simplified interface for making HTTP requests. It handles various types of errors and provides a consistent response format. * * @param {AxiosRequestConfig} options - The default options for the http client * * @example * const axiosClient = new AxiosClient({ timeout: 1000 * 10 }); * const response = await axiosClient.post("https://example.com", { foo: "bar" }); * if (response.type === "success") { * console.log(response.statusCode); * console.log(response.responseBody); * } else if (response.type === "application-error") { * console.log(response.statusCode); * console.log(response.message); * console.log(response.responseBody); * } else if (response.type === "client-error") { * console.log(response.statusCode); * console.log(response.message); * } */ export declare class AxiosClient implements HttpClient { private options; private instance; private observabilityConfig; constructor(options?: RequestConfig, observabilityConfig?: AxiosClientObservabilityConfig); private makeRequest; get<T>(url: string, options?: RequestConfig, responseParser?: ResponseParser<T>): Promise<ApiResponse<T>>; post<T>(url: string, data?: unknown, options?: RequestConfig, responseParser?: ResponseParser<T>): Promise<ApiResponse<T>>; put<T>(url: string, data?: unknown, options?: RequestConfig, responseParser?: ResponseParser<T>): Promise<ApiResponse<T>>; patch<T>(url: string, data?: unknown, options?: RequestConfig, responseParser?: ResponseParser<T>): Promise<ApiResponse<T>>; delete<T>(url: string, options?: RequestConfig, responseParser?: ResponseParser<T>): Promise<ApiResponse<T>>; } //# sourceMappingURL=axios_client.d.ts.map