UNPKG

dood-stream-client

Version:

🚀 A feature-rich client for the DoodStream API with caching, logging, and error handling

102 lines (101 loc) â€ĸ 3.13 kB
import { ErrorFactory } from "../errors/error-factory"; /** * 📄 File-related API functionality */ export class FileApi { /** * Create a new File API instance * * @param client - HTTP client */ constructor(client) { this.client = client; } /** * 📋 List files * * @param params - File list parameters (pagination, folder, etc.) * @returns Promise with file list response */ async list(params = {}) { return this.client.get("/file/list", params); } /** * ✅ Check file status * * @param params - File status parameters * @returns Promise with file status response */ async checkStatus(params) { if (!params.file_code) { throw ErrorFactory.createValidationError("File code is required to check status"); } return this.client.get("/file/check", params); } /** * â„šī¸ Get file information * * @param params - File info parameters * @returns Promise with file info response */ async getInfo(params) { if (!params.file_code) { throw ErrorFactory.createValidationError("File code is required to get file info"); } return this.client.get("/file/info", params); } /** * đŸ–ŧī¸ Get file images (thumbnail, splash, etc.) * * @param params - File image parameters * @returns Promise with file image response */ async getImages(params) { if (!params.file_code) { throw ErrorFactory.createValidationError("File code is required to get file images"); } return this.client.get("/file/image", params); } /** * 📝 Rename a file * * @param params - File rename parameters * @returns Promise with boolean response */ async rename(params) { if (!params.file_code) { throw ErrorFactory.createValidationError("File code is required to rename a file"); } if (!params.title) { throw ErrorFactory.createValidationError("New title is required to rename a file"); } return this.client.get("/file/rename", params); } /** * 📂 Move a file to a different folder * * @param params - File move parameters * @returns Promise with boolean response */ async move(params) { if (!params.file_code) { throw ErrorFactory.createValidationError("File code is required to move a file"); } if (params.fld_id === undefined) { throw ErrorFactory.createValidationError("Destination folder ID is required to move a file"); } return this.client.get("/file/move", params); } /** * 🔍 Search for files * * @param params - File search parameters * @returns Promise with file list response */ async search(params) { if (!params.search_term) { throw ErrorFactory.createValidationError("Search term is required to search files"); } return this.client.get("/search/videos", params); } }