@drfrost/bods-js
Version:
JavaScript client for the UK's Bus Open Data Service (BODS) API
52 lines • 1.39 kB
TypeScript
import type { ApiConfig } from '../types/common.js';
/**
* HTTP response wrapper
*/
export interface HttpResponse<T> {
data: T;
status: number;
statusText: string;
headers: Headers;
}
/**
* HTTP client error
*/
export declare class HttpClientError extends Error {
status: number;
response?: any | undefined;
constructor(message: string, status: number, response?: any | undefined);
}
/**
* Base HTTP client for BODS API requests
*/
export declare class HttpClient {
private readonly apiKey;
private readonly baseUrl;
private readonly timeout;
constructor(config: ApiConfig);
/**
* Build URL with query parameters
*/
private buildUrl;
/**
* Make HTTP request with timeout and error handling
*/
private request;
/**
* Perform GET request
*/
get<T>(endpoint: string, params?: Record<string, any>): Promise<HttpResponse<T>>;
/**
* Perform POST request
*/
post<T>(endpoint: string, body?: any, params?: Record<string, any>): Promise<HttpResponse<T>>;
/**
* Perform PUT request
*/
put<T>(endpoint: string, body?: any, params?: Record<string, any>): Promise<HttpResponse<T>>;
/**
* Perform DELETE request
*/
delete<T>(endpoint: string, params?: Record<string, any>): Promise<HttpResponse<T>>;
}
//# sourceMappingURL=http-client.d.ts.map