UNPKG

@eka-care/patient-ts-sdk

Version:

TypeScript SDK for Trinity Patient Profile Management System

78 lines (77 loc) 1.8 kB
/** * Core HTTP client for Trinity Profiles SDK */ import { SdkConfig } from './types'; /** * HTTP method types */ export type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE'; /** * Request options */ export interface RequestOptions { method: HttpMethod; path: string; body?: any; params?: Record<string, string | number | boolean>; headers?: Record<string, string>; } /** * HTTP response interface */ export interface HttpResponse<T = any> { data: T; status: number; statusText: string; headers: Record<string, string>; } /** * Core HTTP client class */ export declare class HttpClient { private readonly baseUrl; private readonly accessToken; private readonly timeout; private readonly config; constructor(config: SdkConfig); /** * Get current configuration (for token updates) */ getConfig(): SdkConfig; /** * Make HTTP request */ request<T = any>(options: RequestOptions): Promise<HttpResponse<T>>; /** * GET request */ get<T = any>(path: string, params?: Record<string, string | number | boolean>): Promise<HttpResponse<T>>; /** * POST request */ post<T = any>(path: string, body?: any): Promise<HttpResponse<T>>; /** * PATCH request */ patch<T = any>(path: string, body?: any): Promise<HttpResponse<T>>; /** * DELETE request */ delete<T = any>(path: string): Promise<HttpResponse<T>>; /** * Build complete URL with query parameters */ private buildUrl; /** * Build request headers */ private buildHeaders; /** * Create abort signal for timeout */ private createAbortSignal; /** * Extract error message from response */ private extractErrorMessage; }