akua-sdk
Version:
TypeScript SDK for Akua Acquiring Processor
46 lines (45 loc) • 2.12 kB
TypeScript
import { AxiosRequestConfig } from 'axios';
import { ApiResponse, ClientConfig, Environment } from '../types';
/**
* HttpClient is a class that provides a client for making HTTP requests to the Akua API.
* It handles the creation of Axios instances for the API endpoints,
* and provides methods for making GET, POST, PUT, PATCH, and DELETE requests.
* It also includes interceptors for error handling and environment validation.
*/
export declare class HttpClient {
private client;
private pointsClient;
private readonly baseUrl;
private readonly pointsBaseUrl;
private readonly environment;
private readonly clientConfig;
private tokenData;
private tokenGenerationTime;
private isRefreshingToken;
constructor(config: ClientConfig);
private refreshToken;
private setupInterceptors;
private getClient;
get<T>(path: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
post<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
put<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
patch<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
delete<T>(path: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
/**
* Gets the audience URL for the current environment
* @returns {string} The audience URL
*/
getAudienceUrl(): string;
/**
* Gets the current environment (sandbox or production)
* @returns {Environment} The current environment
*/
getEnvironment(): Environment;
/**
* Validates if the current environment matches the required environment
* @param {Environment} requiredEnvironment - The environment that is required for the operation
* @param {string} operationName - The name of the operation being validated
* @returns {ApiResponse<T> | null} Returns an error response if validation fails, null if validation passes
*/
validateEnvironment<T>(requiredEnvironment: Environment, operationName: string): ApiResponse<T> | null;
}