import { AxiosInstance, AxiosRequestConfig } from 'axios'; import { AuthHandler } from './auth'; import { JsonApiResponse, QueryParams, RequestBody, JsonApiRelationship, JsonApiMeta, JsonApiResource } from './types'; /** * Configuration options for the ITGlueClient. * @typedef {Object} ITGlueClientConfig * @property {string} apiKey - Your IT Glue API key. * @property {string} [baseUrl] - Base URL for the IT Glue API (default: 'https://api.itglue.com/'). * @property {number} [timeout] - Request timeout in milliseconds (default: 30000). * @property {number} [maxRetries] - Maximum number of retry attempts for failed requests (default: 3). * @property {number} [retryDelay] - Initial delay in milliseconds for retries (default: 500). * @property {number[]} [retryStatusCodes] - HTTP status codes that should trigger a retry (default: [429, 500, 502, 503, 504]). */ export interface ITGlueClientConfig { apiKey: string; baseUrl?: string; timeout?: number; maxRetries?: number; retryDelay?: number; retryStatusCodes?: number[]; } /** * Core HTTP client for interacting with the IT Glue API. * Handles authentication, retries, and request formatting. * * @class * @example * const client = new ITGlueClient({ apiKey: 'your-api-key' }); * const orgs = await client.get('/organizations'); * @category Core */ export declare class ITGlueClient { /** @private */ private apiKey; /** @private */ private baseUrl; /** @private */ private timeout; /** @private */ private axiosInstance; /** @private */ private maxRetries; /** @private */ private retryDelay; /** @private */ private retryStatusCodes; /** @private */ private authHandler; /** * Create a new ITGlueClient instance. * @param {ITGlueClientConfig} config - Client configuration options. * @param {AuthHandler} [authHandler] - Optional custom authentication handler. */ constructor(config: ITGlueClientConfig, authHandler?: AuthHandler); /** * Returns the underlying axios instance for advanced usage. * @returns {AxiosInstance} The axios instance used by the client. */ getAxiosInstance(): AxiosInstance; /** * Make a request with custom headers merged in. * @template T * @param {AxiosRequestConfig} config - Axios request configuration. * @returns {Promise} The response data. */ requestWithHeaders(config: AxiosRequestConfig): Promise; /** * Retry wrapper for HTTP requests. * @private * @template T * @param {() => Promise} fn - The function to retry. * @param {number} [attempt=0] - Current attempt number. * @returns {Promise} The result of the function if successful. * @throws Will throw if all retries fail. */ private withRetry; /** * Make a GET request. * @template T * @param {string} endpoint - API endpoint path. * @param {Record} [params] - Query parameters. * @returns {Promise} The response data. */ get(endpoint: string, params?: QueryParams): Promise; /** * Make a POST request. * @template T * @param {string} endpoint - API endpoint path. * @param {any} [data] - Request body data. * @returns {Promise} The response data. */ post(endpoint: string, data?: RequestBody): Promise; /** * Make a PATCH request. * @template T * @param {string} endpoint - API endpoint path. * @param {any} [data] - Request body data. * @returns {Promise} The response data. */ patch(endpoint: string, data?: RequestBody): Promise; /** * Make a DELETE request. * @template T * @param {string} endpoint - API endpoint path. * @returns {Promise} The response data. */ delete(endpoint: string): Promise; /** * Error handler for HTTP methods. * @private * @param {unknown} error - The error object. * @throws Will always throw an error with a descriptive message. */ private handleError; } /** * Factory function to create a new ITGlueClient instance. * @param {ITGlueClientConfig} config - Client configuration options. * @returns {ITGlueClient} A new ITGlueClient instance. * @category Core * @example * const client = createITGlueClient({ apiKey: 'your-api-key' }); */ export declare function createITGlueClient(config: ITGlueClientConfig): ITGlueClient; /** * Format data according to JSON:API spec for requests. * @param {string} type - The resource type. * @param {Record} attributes - Resource attributes. * @param {Record} [relationships] - Resource relationships. * @returns {object} Formatted request data for JSON:API. * @example * const data = formatRequestData('organization', { name: 'Acme' }); */ export declare function formatRequestData(type: string, attributes: Record, relationships?: Record): RequestBody; /** * Parse JSON:API response to extract data, meta, and included fields. * @template T * @param {JsonApiResponse} response - The JSON:API response object. * @returns {{ data: T, meta?: JsonApiMeta, included?: JsonApiResource[] }} Parsed response object. * @example * const parsed = parseJsonApiResponse(response); */ export declare function parseJsonApiResponse(response: JsonApiResponse): { data: T; meta?: JsonApiMeta; included?: JsonApiResource[]; };