UNPKG

@revmax/agent-sdk

Version:

Official Node.js SDK for RevMax - billing, customer management, and usage tracking

92 lines (91 loc) 2.55 kB
import { ClientOptions, TrackEventParams, TrackEventResponse } from './types'; import { Customers, Usage } from './resources'; /** * Interface for organization information */ export interface OrganizationInfo { id: string; name: string; [key: string]: any; } /** * Main RevMax client class */ export declare class RevMaxClient { /** * API client for making requests */ private readonly apiClient; /** * Logger instance */ private readonly logger; /** * Authentication method */ private readonly auth; /** * Customer resource */ readonly customers: Customers; /** * Usage resource */ readonly usage: Usage; /** * Organization information from API key verification */ private _orgInfo; /** * Creates a new RevMax client instance without connecting * You must call connect() before using any API methods * * @param apiKey - API key for authentication * @param options - Client options */ constructor(apiKey: string, options?: ClientOptions); /** * Connect to the RevMax API and verify credentials * This must be called once before using any API methods * * @returns Promise resolving to the client instance for chaining * @throws RevMaxAuthenticationError if API key is invalid * @throws RevMaxInitializationError for other initialization errors */ connect(): Promise<RevMaxClient>; /** * Get organization information * @returns Organization information from API key verification * @throws Error if organization info is not available */ getOrganization(): OrganizationInfo; /** * Track event for a customer (shorthand method) * @param params - Event tracking parameters * @returns Tracked event data */ trackEvent(params: TrackEventParams): Promise<TrackEventResponse>; /** * Re-verify the API key * Useful if you suspect the API key status might have changed * * @returns Updated organization information */ verifyApiKey(): Promise<OrganizationInfo>; /** * Get current telemetry statistics * @returns Telemetry statistics */ getTelemetryStats(): { requestCount: number; successCount: number; errorCount: number; successRate: number; averageDuration: number; errorBreakdown: Record<string, number>; }; /** * Reset telemetry statistics */ resetTelemetryStats(): void; }