UNPKG

@dbs-portal/core-api

Version:

HTTP client and API utilities for DBS Portal

73 lines 2.31 kB
/** * HTTP client implementation using Axios */ import { type AxiosInstance, type AxiosResponse } from 'axios'; import type { RequestConfig, ApiResponse } from '../types'; /** * HTTP client for making requests using Axios */ export declare class HttpClient { private axiosInstance; constructor(config?: Partial<RequestConfig>); /** * Transform Axios response to our ApiResponse format */ private transformAxiosResponse; /** * Transform Axios error to our ApiError format */ private transformAxiosError; /** * Makes an HTTP request using Axios */ request<T = any>(config: RequestConfig): Promise<ApiResponse<T>>; /** * GET request */ get<T = any>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * POST request */ post<T = any>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * PUT request */ put<T = any>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * PATCH request */ patch<T = any>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * DELETE request */ delete<T = any>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * HEAD request */ head<T = any>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * OPTIONS request */ options<T = any>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>; /** * Add request interceptor */ addRequestInterceptor(onFulfilled?: (config: any) => any | Promise<any>, onRejected?: (error: any) => any): number; /** * Add response interceptor */ addResponseInterceptor(onFulfilled?: (response: AxiosResponse) => any | Promise<any>, onRejected?: (error: any) => any): number; /** * Remove request interceptor */ removeRequestInterceptor(interceptorId: number): void; /** * Remove response interceptor */ removeResponseInterceptor(interceptorId: number): void; /** * Get the underlying Axios instance */ getAxiosInstance(): AxiosInstance; } //# sourceMappingURL=http-client.d.ts.map