Spaces:
Runtime error
Runtime error
| import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger'; | |
| import { WHATSAPP_DEFAULT_SESSION_NAME } from '@waha/structures/base.dto'; | |
| import { ChatRequest } from '@waha/structures/chatting.dto'; | |
| import { BinaryFile, RemoteFile } from '@waha/structures/files.dto'; | |
| import { ChatIdProperty } from '@waha/structures/properties.dto'; | |
| import { Type } from 'class-transformer'; | |
| import { | |
| ArrayMaxSize, | |
| ArrayMinSize, | |
| IsArray, | |
| IsEnum, | |
| IsNotEmpty, | |
| IsOptional, | |
| IsString, | |
| ValidateIf, | |
| ValidateNested, | |
| } from 'class-validator'; | |
| export enum ButtonType { | |
| REPLY = 'reply', | |
| URL = 'url', | |
| CALL = 'call', | |
| COPY = 'copy', | |
| } | |
| /** | |
| * buttons: | |
| * - type: reply|url|call|copy | |
| * text: Display Text | |
| * url: only for url (required) | |
| * phone_number: only for call (required) | |
| */ | |
| export class Button { | |
| (ButtonType) | |
| type: ButtonType = ButtonType.REPLY; | |
| ({ | |
| example: 'Button Text', | |
| }) | |
| () | |
| text: string; | |
| ({ | |
| example: '321321', | |
| }) | |
| () | |
| () | |
| id?: string; | |
| ({ | |
| example: 'https://example.com', | |
| }) | |
| ((o) => o.type === ButtonType.URL) | |
| () | |
| url?: string; | |
| ({ | |
| example: '+1234567890', | |
| }) | |
| ((o) => o.type === ButtonType.CALL) | |
| () | |
| phoneNumber?: string; | |
| ({ | |
| example: '4321', | |
| }) | |
| ((o) => o.type === ButtonType.COPY) | |
| () | |
| copyCode?: string; | |
| } | |
| (RemoteFile, BinaryFile) | |
| export class SendButtonsRequest { | |
| () | |
| session: string = WHATSAPP_DEFAULT_SESSION_NAME; | |
| () | |
| () | |
| chatId: string; | |
| ({ | |
| example: 'How are you?', | |
| }) | |
| () | |
| header: string; | |
| ({ | |
| oneOf: [ | |
| { $ref: getSchemaPath(RemoteFile) }, | |
| { $ref: getSchemaPath(BinaryFile) }, | |
| ], | |
| }) | |
| () | |
| headerImage?: RemoteFile | BinaryFile; | |
| ({ | |
| example: 'Tell us how are you please ๐', | |
| }) | |
| () | |
| body: string; | |
| ({ | |
| example: 'If you have any questions, please send it in the chat', | |
| }) | |
| () | |
| footer: string; | |
| ({ each: true }) | |
| (() => Button) | |
| () | |
| (1) | |
| (4) | |
| ({ | |
| example: [ | |
| { | |
| type: 'reply', | |
| text: 'I am good!', | |
| }, | |
| { | |
| type: 'call', | |
| text: 'Call us', | |
| phoneNumber: '+1234567890', | |
| }, | |
| { | |
| type: 'copy', | |
| text: 'Copy code', | |
| copyCode: '4321', | |
| }, | |
| { | |
| type: 'url', | |
| text: 'How did you do that?', | |
| url: 'https://waha.devlike.pro', | |
| }, | |
| ], | |
| }) | |
| buttons: Button[]; | |
| } | |