UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account, ZNS, Consultation Service, Group Messaging, and Social APIs

67 lines 2.11 kB
/** * Base HTTP client for Zalo API */ import { AxiosInstance } from "axios"; import { ZaloSDKConfig, Logger, RequestConfig } from "../types/common"; /** * Base client for making HTTP requests to Zalo API */ export declare class BaseClient { protected readonly axios: AxiosInstance; protected readonly logger: Logger; protected readonly config: Required<ZaloSDKConfig>; constructor(config: ZaloSDKConfig); /** * Setup axios interceptors for logging and error handling */ private setupInterceptors; /** * Sanitize headers for logging (remove sensitive information) */ private sanitizeHeaders; /** * Handle axios errors and log them */ private handleAxiosError; /** * Make a GET request */ protected get<T = any>(url: string, accessToken?: string, params?: Record<string, any>): Promise<T>; /** * Make a POST request */ protected post<T = any>(url: string, accessToken?: string, data?: any, params?: Record<string, any>): Promise<T>; /** * Make a PUT request */ protected put<T = any>(url: string, accessToken?: string, data?: any, params?: Record<string, any>): Promise<T>; /** * Make a DELETE request */ protected delete<T = any>(url: string, accessToken?: string, params?: Record<string, any>): Promise<T>; /** * Upload file using FormData */ protected uploadFile<T = any>(url: string, accessToken: string, file: Buffer | NodeJS.ReadableStream, filename: string, additionalFields?: Record<string, any>): Promise<T>; /** * Make a generic HTTP request with retry logic */ protected request<T = any>(config: RequestConfig): Promise<T>; /** * Validate Zalo API response for errors */ private validateZaloResponse; /** * Determine if request should be retried */ private shouldRetry; /** * Create SDK error from axios error */ private createSDKError; /** * Delay execution for specified milliseconds */ private delay; } //# sourceMappingURL=base-client.d.ts.map