UNPKG

mnotify-ts-sdk

Version:

Third-Party TypeScript SDK for mNotify BMS API

46 lines (45 loc) 1.6 kB
import { type AxiosInstance, type AxiosRequestConfig } from 'axios'; export interface MNotifyConfig { apiKey: string; baseUrl?: string; timeout?: number; maxRetries?: number; } /** * Core HTTP client for mNotify API communication * * @remarks * This class handles all low-level HTTP requests to the mNotify API, * including authentication, retries, and error handling. */ export declare class MNotifyClient { readonly axiosInstance: AxiosInstance; private readonly maxRetries; /** * Creates a new MNotifyClient instance * @param config - Configuration object * @param config.apiKey - Your mNotify API key * @param config.baseUrl - Base API URL (default: 'https://api.mnotify.com/api') * @param config.timeout - Request timeout in ms (default: 10000) * @param config.maxRetries - Maximum retry attempts for failed requests (default: 3) */ constructor(config: MNotifyConfig); /** * Makes an HTTP request to the mNotify API * @param config - Axios request configuration * @param retryCount - Current retry attempt (used internally) * @param T - Type of the response data * @returns Promise with the parsed response data * @throws {MNotifyError} When API returns an error response * * @example * ```typescript * const client = new MNotifyClient({ apiKey: 'your-key' }); * const response = await client.request<T>({ * method: 'GET', * url: '/account/balance' * }); * ``` */ request<T>(config: AxiosRequestConfig, retryCount?: number): Promise<T>; }