UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account v3.0, ZNS with Full Type Safety, Consultation Service, Broadcast Service, Group Messaging with List APIs, Social APIs, Enhanced Article Management, Promotion Service v3.0 with Multip

622 lines 15.2 kB
/** * ZNS (Zalo Notification Service) Type Definitions */ export declare enum ZNSTemplateType { /** ZNS tùy chỉnh */ CUSTOM = 1, /** ZNS xác thực */ AUTHENTICATION = 2, /** ZNS yêu cầu thanh toán */ PAYMENT_REQUEST = 3, /** ZNS voucher */ VOUCHER = 4, /** ZNS Đánh giá dịch vụ */ SERVICE_RATING = 5 } export declare enum ZNSTemplateTag { /** Transaction */ TRANSACTION = "1", /** Customer care */ CUSTOMER_CARE = "2", /** Promotion */ PROMOTION = "3" } export declare enum ZNSButtonType { /** URL */ URL = 1, /** Phone */ PHONE = 2, /** SMS */ SMS = 3, /** App */ APP = 4, /** Deeplink */ DEEPLINK = 5, /** Map */ MAP = 6, /** Calendar */ CALENDAR = 7, /** Copy */ COPY = 8 } export declare enum ZNSParamType { /** Tên khách hàng (30) */ CUSTOMER_NAME = "1", /** Số điện thoại (15) */ PHONE_NUMBER = "2", /** Địa chỉ (200) */ ADDRESS = "3", /** số (30) */ CODE = "4", /** Nhãn tùy chỉnh (30) */ CUSTOM_LABEL = "5", /** Trạng thái giao dịch (30) */ TRANSACTION_STATUS = "6", /** Thông tin liên hệ (50) */ CONTACT_INFO = "7", /** Giới tính / Danh xưng (5) */ GENDER_TITLE = "8", /** Tên sản phẩm / Thương hiệu (200) */ PRODUCT_BRAND = "9", /** Số lượng / Số tiền (20) */ QUANTITY_AMOUNT = "10", /** Thời gian (20) */ TIME = "11", /** OTP (10) */ OTP = "12", /** URL (200) */ URL = "13", /** Tiền tệ (VNĐ) (12) */ CURRENCY = "14", /** Bank transfer note (90) */ BANK_TRANSFER_NOTE = "15" } export interface ZNSMessage { phone: string; template_id: string; template_data: Record<string, any>; tracking_id?: string; } export interface ZNSHashPhoneMessage { phone_hash: string; template_id: string; template_data: Record<string, any>; tracking_id?: string; } export interface ZNSDevModeMessage { phone: string; template_id: string; template_data: Record<string, any>; tracking_id?: string; mode: "development"; } export interface ZNSRsaMessage { phone_rsa: string; template_id: string; template_data: Record<string, any>; tracking_id?: string; } export interface ZNSJourneyMessage { phone: string; template_id: string; template_data: Record<string, any>; tracking_id?: string; journey_id: string; } export interface ZNSSendResult { error: number; message: string; data?: { msg_id: string; sent_time: string; quota?: { remainingQuota: number; dailyQuota: number; }; }; } export interface ZNSTemplate { templateId: string; templateName: string; status: "PENDING_REVIEW" | "ENABLE" | "REJECT" | "DISABLE"; listParams: Array<{ name: string; require: boolean; type: "STRING" | "NUMBER" | "DATE"; maxLength?: number; minLength?: number; }>; timeout?: number; previewUrl?: string; templateQuality?: "HIGH" | "MEDIUM" | "LOW"; templateTag?: string; price?: number; applyTemplateQuota?: boolean; templateDailyQuota?: number; templateRemainingQuota?: number; } export interface ZNSTemplateDetails { error: number; message: string; data: { templateId: string; templateName: string; status: "ENABLE" | "PENDING_REVIEW" | "DELETE" | "REJECT" | "DISABLE"; reason?: string; listParams: Array<{ name: string; require: boolean; type: string; maxLength: number; minLength: number; acceptNull: boolean; }>; listButtons: Array<{ type: number; title: string; content: string; }>; timeout: number; previewUrl: string; templateQuality: string; templateTag: "TRANSACTION" | "CUSTOMER_CARE" | "PROMOTION"; price: string; }; } export interface ZNSTemplateList { error: number; message: string; data: Array<{ templateId: string; templateName: string; createdTime: number; status: "PENDING_REVIEW" | "DISABLE" | "ENABLE" | "REJECT"; templateQuality: "HIGH" | "MEDIUM" | "LOW" | "UNDEFINED"; }>; metadata: { total: number; }; } /** * ZNS Template Create Request - theo chuẩn Zalo API * API: POST https://business.openapi.zalo.me/template/create */ export interface ZNSCreateTemplateRequest { /** Tên mẫu tin (10-60 tự) */ template_name: string; /** Loại mẫu tin */ template_type: 1 | 2 | 3 | 4 | 5; /** Tag mẫu tin */ tag: "1" | "2" | "3"; /** Layout của template */ layout: ZNSTemplateLayout; /** Thông tin về param (optional) */ params?: ZNSTemplateParam[]; /** Ghi chú kiểm duyệt (1-400 tự, optional) */ note?: string; /** tracking do đối tác tự định nghĩa */ tracking_id: string; } /** * ZNS Template Edit Request - theo chuẩn Zalo API * API: POST https://business.openapi.zalo.me/template/edit * Chỉ thể chỉnh sửa template trạng thái REJECT */ export interface ZNSUpdateTemplateRequest { /** Template ID được hệ thống tự tạo */ template_id: string; /** Tên mẫu tin (10-60 tự) */ template_name: string; /** Loại mẫu tin */ template_type: 1 | 2 | 3 | 4 | 5; /** Tag mẫu tin */ tag: "1" | "2" | "3"; /** Layout của template */ layout: ZNSTemplateLayout; /** Thông tin về param (optional) */ params?: ZNSTemplateParam[]; /** Ghi chú kiểm duyệt (1-400 tự, optional) */ note?: string; /** tracking do đối tác tự định nghĩa */ tracking_id: string; } /** * Layout của ZNS Template */ export interface ZNSTemplateLayout { /** Header components (optional) */ header?: { components: ZNSLayoutComponent[]; }; /** Body components (required) */ body: { components: ZNSLayoutComponent[]; }; /** Footer components (optional) */ footer?: { components: ZNSLayoutComponent[]; }; } /** * Component trong layout */ export interface ZNSLayoutComponent { /** Logo component */ LOGO?: { light: { type: "IMAGE"; media_id: string; }; dark: { type: "IMAGE"; media_id: string; }; }; /** Images component */ IMAGES?: { items: Array<{ type: "IMAGE"; media_id: string; }>; }; /** Title component */ TITLE?: { value: string; }; /** Paragraph component */ PARAGRAPH?: { value: string; }; /** OTP component */ OTP?: { value: string; }; /** Table component */ TABLE?: { rows: Array<{ value: string; title: string; row_type?: number; }>; }; /** Voucher component */ VOUCHER?: { name: string; condition: string; voucher_code: string; start_date: string; end_date: string; display_code: 0 | 1; }; /** Payment component */ PAYMENT?: { bank_code: string; account_name: string; account_number: string; amount: string; note: string; }; /** Buttons component */ BUTTONS?: { items: Array<{ content: string; type: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; title: string; }>; }; } /** * Template parameter theo chuẩn Zalo API */ export interface ZNSTemplateParam { /** Loại param */ type: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15"; /** Tên của param */ name: string; /** Dữ liệu mẫu của param */ sample_value: string; } /** * Response từ API create/edit template */ export interface ZNSTemplateCreateEditResponse { error: number; message: string; data: { /** Template ID */ template_id: string; /** Tên template */ template_name: string; /** Loại template */ template_type: number; /** Trạng thái template sau khi submit */ status: "PENDING_REVIEW"; /** Template tag */ tag: number; /** App ID của template */ app_id: string; /** OA ID của template */ oa_id: string; /** Giá của template */ price: string; /** Timeout của template */ timeout: number; /** Link preview template */ preview_url: string; }; } export interface ZNSUploadImageResult { error: number; message: string; data?: { media_id: string; }; } export interface ZNSStatusInfo { error: number; message: string; data?: { status: "PENDING" | "SENT" | "RECEIVED" | "FAILED"; sent_time?: string; received_time?: string; fail_reason?: string; }; } export interface ZNSMessageStatusInfo { error: number; message: string; data?: { delivery_time: string; message: string; status: number; }; } export interface ZNSBatchMessageStatusRequest { message_ids: string[]; } export interface ZNSBatchMessageStatusResponse { error: number; message: string; data?: { [messageId: string]: { delivery_time: string; message: string; status: number; }; }; } export interface ZNSQuotaInfo { error: number; message: string; data?: { dailyQuota: string; remainingQuota: string; dailyQuotaPromotion: string | null; remainingQuotaPromotion: string | null; monthlyPromotionQuota: number; remainingMonthlyPromotionQuota: number; estimatedNextMonthPromotionQuota: number; }; } export interface ZNSAllowedContentTypes { error: number; message: string; data?: string[]; } export interface ZNSTemplateSampleData { error: number; message: string; data: Record<string, any>; } export interface ZNSCustomerRatingResponse { error: number; data: { total: number; data: Array<{ note: string; rate: number; submitDate: string; msgId: string; feedbacks: string[]; trackingId: string; }>; }; } export interface ZNSOAQualityInfo { error: number; message: string; data: { oaCurrentQuality: "HIGH" | "MEDIUM" | "LOW" | "UNDEFINED"; oa7dayQuality: "HIGH" | "MEDIUM" | "LOW" | "UNDEFINED"; }; } export interface ZNSQualityHistoryList { error: number; message: string; data?: { history: Array<{ date: string; quality: "HIGH" | "MEDIUM" | "LOW"; qualityScore: number; metrics: { sent: number; delivered: number; read: number; responded: number; complained: number; }; }>; }; } export interface ZNSTemplateStatus { templateId: string; status: "PENDING_REVIEW" | "ENABLE" | "REJECT" | "DISABLE"; rejectReason?: string; enabledTime?: string; disabledTime?: string; } export interface ZNSComponent { type: "HEADER" | "BODY" | "FOOTER"; format?: "TEXT" | "IMAGE" | "VIDEO"; text?: string; url?: string; example?: { header_text?: string[]; body_text?: string[][]; header_handle?: string[]; }; } export interface ZNSTemplateComponent { type: "TITLE" | "PARAGRAPH" | "TABLE" | "LOGO" | "IMAGE" | "BUTTONS"; content?: string; url?: string; buttons?: Array<{ title: string; type: "PHONE_NUMBER" | "URL"; payload: string; }>; table?: { headers: string[]; rows: string[][]; }; } export interface ZNSError { error: number; message: string; details?: { field?: string; code?: string; description?: string; }; } export interface ZNSAnalytics { templateId: string; period: { from: string; to: string; }; metrics: { sent: number; delivered: number; read: number; clicked: number; failed: number; deliveryRate: number; readRate: number; clickRate: number; }; breakdown?: { daily?: Array<{ date: string; sent: number; delivered: number; read: number; clicked: number; failed: number; }>; hourly?: Array<{ hour: number; sent: number; delivered: number; read: number; clicked: number; failed: number; }>; }; } /** Attachment object cho LOGO IMAGES */ export interface ZNSAttachment { type: "IMAGE"; media_id: string; } /** TITLE component */ export interface ZNSTitleComponent { value: string; } /** PARAGRAPH component */ export interface ZNSParagraphComponent { value: string; } /** OTP component */ export interface ZNSOTPComponent { value: string; } /** TABLE component */ export interface ZNSTableComponent { rows: ZNSTableRow[]; } export interface ZNSTableRow { title: string; value: string; row_type?: 0 | 1 | 2 | 3 | 4 | 5; } /** LOGO component */ export interface ZNSLogoComponent { light: ZNSAttachment; dark: ZNSAttachment; } /** IMAGES component */ export interface ZNSImagesComponent { items: ZNSAttachment[]; } /** BUTTONS component */ export interface ZNSButtonsComponent { items: ZNSButtonItem[]; } export interface ZNSButtonItem { type: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; title: string; content: string; } /** PAYMENT component */ export interface ZNSPaymentComponent { bank_code: string; account_name: string; bank_account: string; amount: string | number; note?: string; } /** VOUCHER component */ export interface ZNSVoucherComponent { name: string; condition: string; start_date?: string; end_date: string; voucher_code: string; display_code?: 1 | 2 | 3; } /** RATING component */ export interface ZNSRatingComponent { items: ZNSRatingItem[]; } export interface ZNSRatingItem { star: 1 | 2 | 3 | 4 | 5; title: string; question?: string; answers?: string[]; thanks: string; description: string; } /** Union type cho tất cả các component */ export type ZNSValidationComponent = { TITLE: ZNSTitleComponent; } | { PARAGRAPH: ZNSParagraphComponent; } | { OTP: ZNSOTPComponent; } | { TABLE: ZNSTableComponent; } | { LOGO: ZNSLogoComponent; } | { IMAGES: ZNSImagesComponent; } | { BUTTONS: ZNSButtonsComponent; } | { PAYMENT: ZNSPaymentComponent; } | { VOUCHER: ZNSVoucherComponent; } | { RATING: ZNSRatingComponent; }; //# sourceMappingURL=zns.d.ts.map