UNPKG

@warriorteam/zalo-webhook-types

Version:

TypeScript types for Zalo Personal webhook events from automation-web

219 lines 6.22 kB
/** * Content Types for Zalo Messages * * Specific content interfaces for different message types. */ import { ZaloAttachmentProperties } from './base'; /** * Generic attachment content interface * Used as base for all media attachments (image, video, GIF, doodle) */ export interface ZaloAttachmentContent { /** Main attachment URL */ href: string; /** Thumbnail URL (optional) */ thumbHref?: string; /** High definition URL (optional) */ hdHref?: string; /** Width in pixels (optional for some types) */ width?: number; /** Height in pixels (optional for some types) */ height?: number; /** Duration in milliseconds (for video/GIF) */ duration?: number; /** File size in bytes */ fileSize: number; /** Original filename */ fileName: string; /** File checksum */ checksum: string; /** Caption text (optional) */ caption?: string; /** Attachment properties */ properties?: ZaloAttachmentProperties; } /** * Image-specific attachment content * Used for chat.photo messages */ export interface ZaloImageContent extends ZaloAttachmentContent { /** Image width in pixels */ width: number; /** Image height in pixels */ height: number; /** Image caption (optional) */ caption?: string; /** Thumbnail URL */ thumbHref?: string; /** HD version URL */ hdHref?: string; /** Properties specific to images */ properties?: ZaloAttachmentProperties & { /** Image type (0=image) */ type: 0; }; } /** * Video-specific attachment content * Used for chat.video.msg messages */ export interface ZaloVideoContent extends ZaloAttachmentContent { /** Video width in pixels */ width: number; /** Video height in pixels */ height: number; /** Video duration in milliseconds */ duration: number; /** Video thumbnail URL */ thumbHref?: string; /** Properties specific to videos */ properties?: ZaloAttachmentProperties & { /** Video type (1=video) */ type: 1; }; } /** * Voice-specific content * Used for chat.voice messages */ export interface ZaloVoiceContent { /** Voice file URL */ href: string; /** Duration in milliseconds */ duration: number; /** File size in bytes */ fileSize: number; /** Original filename */ fileName: string; /** File checksum */ checksum: string; /** Properties specific to voice */ properties?: ZaloAttachmentProperties & { /** Voice type (2=voice) */ type: 2; }; } /** * File-specific content * Used for share.file messages */ export interface ZaloFileContent { /** File download URL */ href: string; /** Original filename */ fileName: string; /** File size in bytes */ fileSize: number; /** MIME type */ fileType: string; /** File checksum */ checksum: string; /** Properties specific to files */ properties?: ZaloAttachmentProperties & { /** File type (3=file) */ type: 3; }; } /** * GIF-specific attachment content * Used for chat.gif messages */ export interface ZaloGifContent extends ZaloAttachmentContent { /** GIF width in pixels */ width: number; /** GIF height in pixels */ height: number; /** Animation duration in milliseconds */ duration?: number; /** GIF thumbnail URL (first frame) */ thumbHref?: string; /** Properties specific to GIFs */ properties?: ZaloAttachmentProperties & { /** GIF type (4=gif) */ type: 4; }; } /** * Doodle-specific attachment content * Used for chat.doodle messages */ export interface ZaloDoodleContent extends ZaloAttachmentContent { /** Doodle width in pixels */ width: number; /** Doodle height in pixels */ height: number; /** Properties specific to doodles */ properties?: ZaloAttachmentProperties & { /** Doodle type (5=doodle) */ type: 5; }; } /** * Sticker content * Used for chat.sticker messages */ export interface ZaloStickerContent { /** Sticker ID or sticker object */ stickerId?: string; /** Type of sticker */ stickerType?: "static" | "animated"; /** Sticker URL (optional) */ stickerUrl?: string; /** Sticker pack ID (optional) */ stickerPackId?: string; /** Sticker pack name (optional) */ stickerPackName?: string; } /** * Location content * Used for chat.location.new messages */ export interface ZaloLocationContent { /** Latitude coordinate */ latitude: number; /** Longitude coordinate */ longitude: number; /** Address string (optional) */ address?: string; /** Location name (optional) */ name?: string; /** GPS accuracy in meters (optional) */ accuracy?: number; /** Whether this is live location */ isLiveLocation?: boolean; /** Live location duration in milliseconds */ duration?: number; } /** * Union type for all content types */ export type ZaloMessageContent = string | ZaloAttachmentContent | ZaloImageContent | ZaloVideoContent | ZaloVoiceContent | ZaloFileContent | ZaloGifContent | ZaloDoodleContent | ZaloStickerContent | ZaloLocationContent; /** * Type guard to check if content is attachment */ export declare function isAttachmentContent(content: any): content is ZaloAttachmentContent; /** * Type guard to check if content is image */ export declare function isImageContent(content: any): content is ZaloImageContent; /** * Type guard to check if content is video */ export declare function isVideoContent(content: any): content is ZaloVideoContent; /** * Type guard to check if content is voice */ export declare function isVoiceContent(content: any): content is ZaloVoiceContent; /** * Type guard to check if content is file */ export declare function isFileContent(content: any): content is ZaloFileContent; /** * Type guard to check if content is sticker */ export declare function isStickerContent(content: any): content is ZaloStickerContent; /** * Type guard to check if content is location */ export declare function isLocationContent(content: any): content is ZaloLocationContent; //# sourceMappingURL=content.d.ts.map