UNPKG

@warriorteam/redai-zalo-sdk

Version:

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

96 lines 3.95 kB
import { ZaloClient } from "../clients/zalo-client"; import { VideoUploadResponse, VideoStatusResponse } from "../types/article"; /** * Service for handling Zalo Official Account Video Upload APIs * * CONDITIONS FOR USING ZALO VIDEO UPLOAD: * * 1. GENERAL CONDITIONS: * - OA must have permission to upload videos * - Access token must have "manage_article" scope * - OA must have active status and be verified * * 2. VIDEO FILE REQUIREMENTS: * - File formats: MP4, AVI only * - Maximum file size: 50MB * - Video processing: asynchronous, use token to check status * - Processing time: varies based on video size and quality * * 3. UPLOAD PROCESS: * - Step 1: Upload video file and get token * - Step 2: Use token to check processing status * - Step 3: Get video_id when processing is complete * - Step 4: Use video_id in article creation * * 4. STATUS CODES: * - 0: Trạng thái không xác định * - 1: Video đã được xử lý thành công và có thể sử dụng * - 2: Video đã bị khóa * - 3: Video đang được xử lý * - 4: Video xử lý thất bại * - 5: Video đã bị xóa */ export declare class VideoUploadService { private readonly client; private readonly endpoints; constructor(client: ZaloClient); /** * Upload video file for article * @param accessToken OA access token * @param file Video file (Buffer or File) * @param filename Original filename (optional, will be generated if not provided) * @returns Token for tracking upload progress */ uploadVideo(accessToken: string, file: Buffer | File, filename?: string): Promise<VideoUploadResponse>; /** * Check video upload status * @param accessToken OA access token * @param token Token from video upload response * @returns Video status information */ checkVideoStatus(accessToken: string, token: string): Promise<VideoStatusResponse>; /** * Wait for video upload completion with polling * @param accessToken OA access token * @param token Token from video upload response * @param maxWaitTime Maximum wait time in milliseconds (default: 5 minutes) * @param pollInterval Polling interval in milliseconds (default: 5 seconds) * @returns Final video status when completed */ waitForUploadCompletion(accessToken: string, token: string, maxWaitTime?: number, // 5 minutes pollInterval?: number): Promise<VideoStatusResponse>; /** * Upload video from URL * @param accessToken OA access token * @param videoUrl URL of the video to upload * @returns Token for tracking upload progress */ uploadVideoFromUrl(accessToken: string, videoUrl: string): Promise<VideoUploadResponse>; /** * Get video information by video ID * @param accessToken OA access token * @param videoId Video ID * @returns Video information */ getVideoInfo(accessToken: string, videoId: string): Promise<any>; /** * Upload video and wait for completion - Combined method * @param accessToken OA access token * @param file Video file (Buffer or File) * @param filename Original filename (optional, will be generated if not provided) * @param maxWaitTime Maximum wait time in milliseconds (default: 5 minutes) * @param pollInterval Polling interval in milliseconds (default: 5 seconds) * @returns Final video status when completed */ uploadVideoAndWaitForCompletion(accessToken: string, file: Buffer | File, filename?: string, maxWaitTime?: number, // 5 minutes pollInterval?: number): Promise<VideoStatusResponse>; /** * Validate video file */ private validateVideoFile; private getMimeTypeFromFilename; private extractFilenameFromUrl; private sleep; private handleVideoUploadError; } //# sourceMappingURL=video-upload.service.d.ts.map