UNPKG

@rudderstack/integrations-lib

Version:
32 lines 1.51 kB
import { AxiosRequestConfig, AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios'; type ResponseHeaders = RawAxiosResponseHeaders | AxiosResponseHeaders | undefined; export type ResponseParser<T> = (responseData: any) => T; export type SuccessfulApiResponse<T> = { type: 'success'; statusCode: number; responseBody: T; headers: ResponseHeaders; }; export type ClientErrorApiResponse = { type: 'client-error'; statusCode: number; message: string; }; export type ApplicationErrorApiResponse = { type: 'application-error'; statusCode: number; message: string; responseBody: any; headers: ResponseHeaders; }; export type ApiResponse<T> = SuccessfulApiResponse<T> | ClientErrorApiResponse | ApplicationErrorApiResponse; export type RequestConfig = AxiosRequestConfig; export interface HttpClient { post: <T>(url: string, data: any, options?: RequestConfig, responseParser?: ResponseParser<T>) => Promise<ApiResponse<T>>; get: <T>(url: string, options?: RequestConfig, responseParser?: ResponseParser<T>) => Promise<ApiResponse<T>>; put: <T>(url: string, data: any, options?: RequestConfig, responseParser?: ResponseParser<T>) => Promise<ApiResponse<T>>; patch: <T>(url: string, data: any, options?: RequestConfig, responseParser?: ResponseParser<T>) => Promise<ApiResponse<T>>; delete: <T>(url: string, options?: RequestConfig, responseParser?: ResponseParser<T>) => Promise<ApiResponse<T>>; } export {}; //# sourceMappingURL=types.d.ts.map