Spaces:
Runtime error
Runtime error
File size: 3,393 Bytes
4327358 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
import { ApiProperty } from '@nestjs/swagger';
import { MessageDestination } from '@waha/structures/chatting.dto';
import { WAMessageBase } from '@waha/structures/responses.dto';
import { Type } from 'class-transformer';
import {
IsBoolean,
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
ValidateNested,
} from 'class-validator';
import { ChatIdProperty, ReplyToProperty } from './properties.dto';
export class EventLocation {
@ApiProperty({
description: 'Name of the location',
example: 'Luxe Nail Studio π
',
})
@IsString()
@IsNotEmpty()
name: string;
//
// Doesn't work right now
//
// @ApiProperty({
// description: 'Latitude of the location',
// example: 38.8937255,
// })
// @IsNumber()
// @IsOptional()
// degreesLatitude?: number;
//
// @ApiProperty({
// description: 'Longitude of the location',
// example: -77.0969763,
// })
// @IsNumber()
// @IsOptional()
// degreesLongitude?: number;
}
export class EventMessage {
@ApiProperty({
description: 'Name of the event',
example: "John's Nail Appointment π
",
})
@IsString()
@IsNotEmpty()
name: string;
@ApiProperty({
description: 'Description of the event',
example:
"It's time for your nail care session! π\\n\\nYou'll be getting a *classic gel manicure* β clean, polished, and long-lasting. π\\n\\nπ *Location:* Luxe Nail Studio\\nWe're on the *2nd floor of the Plaza Mall*, next to the flower shop. Look for the *pink neon sign*!\\n\\nFeel free to arrive *5β10 mins early* so we can get started on time π",
required: false,
})
@IsString()
@IsOptional()
description?: string;
@ApiProperty({
description: 'Start time of the event (Unix timestamp in seconds)',
example: 2063137000,
})
@IsNumber()
@IsNotEmpty()
startTime: number;
@ApiProperty({
description: 'End time of the event (Unix timestamp in seconds)',
example: null,
required: false,
})
@IsNumber()
@IsOptional()
endTime?: number;
@ApiProperty({
description: 'Location of the event',
required: false,
type: EventLocation,
})
@ValidateNested()
@Type(() => EventLocation)
@IsOptional()
location?: EventLocation;
@ApiProperty({
description: 'Whether extra guests are allowed',
example: false,
required: false,
})
@IsBoolean()
@IsOptional()
extraGuestsAllowed?: boolean;
}
export class EventMessageRequest {
@ChatIdProperty()
chatId: string;
event: EventMessage;
@ReplyToProperty()
reply_to?: string;
}
export class EventCancelRequest {
@ApiProperty({
description: 'ID of the event message to cancel',
example: 'true_12345678901@c.us_ABCDEFGHIJKLMNOPQRST',
})
@IsString()
@IsNotEmpty()
id: string;
}
export enum EventResponseType {
UNKNOWN = 'UNKNOWN',
GOING = 'GOING',
NOT_GOING = 'NOT_GOING',
MAYBE = 'MAYBE',
}
export class EventResponse {
response: EventResponseType;
timestampMs: number;
extraGuestCount: number;
}
export class EventResponsePayload extends WAMessageBase {
eventCreationKey: MessageDestination;
eventResponse?: EventResponse;
/** Returns a message in a raw format */
@ApiProperty({
description:
'Message in a raw format that we get from WhatsApp. May be changed anytime, use it with caution! It depends a lot on the underlying backend.',
})
_data?: any;
}
|