/** * HTTP client for Yahoo Fantasy Sports API * @module */ import type { OAuth1Client } from './OAuth1Client.js'; import type { OAuth2Client, OAuth2Tokens } from './OAuth2Client.js'; /** * HTTP request options */ export interface RequestOptions { /** * HTTP method */ method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; /** * Request body (for POST/PUT) */ body?: Record | string; /** * Additional headers */ headers?: Record; /** * Query parameters */ params?: Record; /** * Request timeout in milliseconds */ timeout?: number; /** * Maximum retry attempts */ maxRetries?: number; /** * Skip OAuth authentication for this request */ skipAuth?: boolean; } /** * Callback for reading the current OAuth 2.0 tokens */ export type TokenProvider = () => OAuth2Tokens | null | undefined; /** * Callback for refreshing expired tokens */ export type TokenRefreshCallback = () => Promise; /** * HTTP client for making API requests with retry logic and rate limiting * * @example * ```typescript * const http = new HttpClient( * oauth2Client, * () => tokens, * refreshCallback, * ); * const data = await http.get('/users;use_login=1/games'); * ``` */ export declare class HttpClient { private oauth2Client?; private oauth1Client?; private tokenProvider?; private tokenRefreshCallback?; private rateLimiter; private timeout; private maxRetries; private debug; private rawXml; /** * Creates a new HTTP client * * @param oauth2Client - OAuth 2.0 client for token management (optional in public mode) * @param tokenProvider - Callback that returns the current OAuth 2.0 tokens * @param tokenRefreshCallback - Callback to refresh tokens when expired * @param options - Additional options */ constructor(oauth2Client?: OAuth2Client, tokenProvider?: TokenProvider, tokenRefreshCallback?: TokenRefreshCallback, options?: { timeout?: number; maxRetries?: number; debug?: boolean; oauth1Client?: OAuth1Client; rawXml?: boolean; }); /** * Sets the OAuth 2.0 token provider * * @param provider - Callback returning the latest OAuth 2.0 tokens */ setTokenProvider(provider: TokenProvider): void; /** * Sets the token refresh callback * * @param callback - Callback to refresh tokens */ setTokenRefreshCallback(callback: TokenRefreshCallback): void; /** * Makes a GET request * * @param path - API path (relative to base URL) * @param options - Request options * @returns Response data * * @example * ```typescript * const leagues = await http.get('/users;use_login=1/games/leagues'); * ``` */ get(path: string, options?: RequestOptions): Promise; /** * Makes a POST request * * @param path - API path (relative to base URL) * @param body - Request body * @param options - Request options * @returns Response data * * @example * ```typescript * const result = await http.post('/league/423.l.12345/transactions', { * transaction: { type: 'add', player_key: '423.p.8888' } * }); * ``` */ post(path: string, body?: Record | string, options?: RequestOptions): Promise; /** * Makes a PUT request * * @param path - API path (relative to base URL) * @param body - Request body * @param options - Request options * @returns Response data * * @example * ```typescript * const result = await http.put('/team/423.l.12345.t.1/roster', { * roster: { coverage_type: 'date', date: '2024-11-15', players: [...] } * }); * ``` */ put(path: string, body?: Record | string, options?: RequestOptions): Promise; /** * Makes a DELETE request * * @param path - API path (relative to base URL) * @param options - Request options * @returns Response data * * @example * ```typescript * await http.delete('/league/423.l.12345/transactions/123'); * ``` */ delete(path: string, options?: RequestOptions): Promise; /** * Makes an HTTP request with retry logic */ private request; /** * Builds a full URL from path and parameters */ private buildUrl; /** * Calculates retry delay with exponential backoff */ private getRetryDelay; /** * Sleep helper */ private sleep; } //# sourceMappingURL=HttpClient.d.ts.map