hexabot/api/src/chat/dto/subscriber.dto.ts
2024-09-10 10:50:11 +01:00

117 lines
3.3 KiB
TypeScript

/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
* 3. SaaS Restriction: This software, or any derivative of it, may not be used to offer a competing product or service (SaaS) without prior written consent from Hexastack. Offering the software as a service or using it in a commercial cloud environment without express permission is strictly prohibited.
*/
import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
import {
IsArray,
IsNotEmpty,
IsNumber,
IsString,
IsOptional,
IsDate,
} from 'class-validator';
import { IsObjectId } from '@/utils/validation-rules/is-object-id';
import { ChannelData } from '../schemas/types/channel';
import { IsChannelData } from '../validation-rules/is-channel-data';
export class SubscriberCreateDto {
@ApiProperty({ description: 'Subscriber first name', type: String })
@IsNotEmpty()
@IsString()
first_name: string;
@ApiProperty({ description: 'Subscriber last name', type: String })
@IsNotEmpty()
@IsString()
last_name: string;
@ApiPropertyOptional({ description: 'Subscriber locale', type: String })
@IsOptional()
@IsString()
locale: string;
@ApiPropertyOptional({ description: 'Subscriber timezone', type: Number })
@IsOptional()
@IsNumber()
timezone?: number;
@ApiPropertyOptional({ description: 'Subscriber language', type: String })
@IsNotEmpty()
@IsString()
language: string;
@ApiPropertyOptional({ description: 'Subscriber gender', type: String })
@IsOptional()
@IsString()
gender: string;
@ApiPropertyOptional({ description: 'Subscriber country', type: String })
@IsOptional()
@IsString()
country: string;
@ApiPropertyOptional({ description: 'Subscriber foreign id', type: String })
@IsOptional()
@IsString()
foreign_id: string;
@ApiProperty({ description: 'Subscriber labels', type: Array })
@IsNotEmpty()
@IsArray()
@IsObjectId({ each: true, message: 'Label must be a valid ObjectId' })
labels: string[];
@ApiPropertyOptional({
description: 'Subscriber assigned to',
type: String,
default: null,
})
@IsOptional()
@IsString()
@IsObjectId({ message: 'AssignedTo must be a valid ObjectId' })
assignedTo?: string | null;
@ApiPropertyOptional({
description: 'Subscriber assigned at',
type: Date,
default: null,
})
@IsOptional()
@IsDate()
assignedAt: Date | null;
@ApiPropertyOptional({
description: 'Subscriber last visit',
type: Date,
})
@IsOptional()
@IsDate()
lastvisit: Date;
@ApiPropertyOptional({
description: 'Subscriber retained from',
type: Date,
})
@IsOptional()
@IsDate()
retainedFrom: Date;
@ApiProperty({
description: 'Subscriber channel',
type: Object,
})
@IsNotEmpty()
@IsChannelData()
channel: ChannelData;
}
export class SubscriberUpdateDto extends PartialType(SubscriberCreateDto) {}