autotrader-connect-api
Version:
Production-ready TypeScript wrapper for Auto Trader UK Connect APIs
86 lines • 2.52 kB
TypeScript
/**
* HTTP client for AutoTrader API
* Configures Axios with authentication, rate limiting, and error handling
*/
import { ApiClientConfig, RequestOptions } from './types/common';
/**
* HTTP client class with rate limiting and authentication
*/
export declare class ApiClient {
private axiosInstance;
private rateLimiter;
private config;
constructor(config: ApiClientConfig);
/**
* Make a GET request
*/
get<T>(url: string, options?: RequestOptions): Promise<T>;
/**
* Make a POST request
*/
post<T>(url: string, data?: unknown, options?: RequestOptions): Promise<T>;
/**
* Make a PUT request
*/
put<T>(url: string, data?: unknown, options?: RequestOptions): Promise<T>;
/**
* Make a PATCH request
*/
patch<T>(url: string, data?: unknown, options?: RequestOptions): Promise<T>;
/**
* Make a DELETE request
*/
delete<T>(url: string, options?: RequestOptions): Promise<T>;
/**
* Make a generic HTTP request with rate limiting
*/
private request;
/**
* Setup request interceptor for authentication
*/
private setupRequestInterceptor;
/**
* Setup response interceptor for error handling and token refresh
*/
private setupResponseInterceptor;
/**
* Update rate limit information from response headers
*/
private updateRateLimitInfo;
/**
* Handle API errors and convert to standardized format
*/
private handleApiError;
/**
* Determine if a request should be retried
*/
private shouldRetryRequest;
/**
* Get current rate limiter status
*/
getRateLimitStatus(): {
reservoir: number;
running: number;
queued: number;
};
/**
* Get client configuration
*/
getConfig(): Required<ApiClientConfig>;
}
/**
* Get or create the default API client
*/
export declare function getClient(config?: ApiClientConfig): ApiClient;
/**
* Default client instance export
*/
declare const client: {
get: <T>(url: string, options?: RequestOptions) => Promise<T>;
post: <T_1>(url: string, data?: unknown, options?: RequestOptions) => Promise<T_1>;
put: <T_2>(url: string, data?: unknown, options?: RequestOptions) => Promise<T_2>;
patch: <T_3>(url: string, data?: unknown, options?: RequestOptions) => Promise<T_3>;
delete: <T_4>(url: string, options?: RequestOptions) => Promise<T_4>;
};
export default client;
//# sourceMappingURL=client.d.ts.map