UNPKG

afrimomo-sdk

Version:

A unified SDK for African payment providers

39 lines 1.75 kB
import { AxiosInstance, AxiosRequestConfig, InternalAxiosRequestConfig } from "axios"; export interface HttpClientConfig { baseUrl: string; serviceName: string; timeoutMs?: number; defaultHeaders?: Record<string, string>; } export interface AuthStrategy { type: "bearer" | "basic" | "custom" | "none"; getAuthHeader?: () => Promise<string> | string; token?: string; username?: string; password?: string; } export interface RequestHook { onRequest?: (config: InternalAxiosRequestConfig) => Promise<InternalAxiosRequestConfig> | InternalAxiosRequestConfig; onRequestError?: (error: unknown) => Promise<unknown>; } export interface NetworkErrorResponse { errorMessage: string; statusCode: number; errorObject: string; } export declare class HttpClient { private readonly requestHook?; protected readonly axiosInstance: AxiosInstance; private readonly serviceName; private readonly authStrategy; constructor(config: HttpClientConfig, authStrategy?: AuthStrategy, requestHook?: RequestHook | undefined); private setupInterceptors; handleApiError(error: unknown, context: string): NetworkErrorResponse; get<T>(endpoint: string, context?: string, config?: AxiosRequestConfig): Promise<T>; post<T>(endpoint: string, data: unknown, context?: string, config?: AxiosRequestConfig): Promise<T>; put<T>(endpoint: string, data: unknown, context?: string, config?: AxiosRequestConfig): Promise<T>; patch<T>(endpoint: string, data?: unknown, context?: string, config?: AxiosRequestConfig): Promise<T>; delete<T>(endpoint: string, context?: string, config?: AxiosRequestConfig): Promise<T>; getInstance(): AxiosInstance; } //# sourceMappingURL=httpClient.d.ts.map