import { IsNotEmpty, IsNumber, IsString, IsObject, IsOptional, IsIn, IsBoolean, IsArray, ValidateNested, } from 'class-validator'; import { Type } from 'class-transformer'; export class CreateConfigDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; @IsNotEmpty() @IsString() integration_type: string; @IsNotEmpty() @IsString() integration_provider: string; @IsNotEmpty() @IsNumber() integration_source_id: number; @IsNotEmpty() @IsObject() config: { // OAuth Control useOAuth?: boolean; // Set to true to force OAuth flow even if tokens are provided // Gmail API Config clientId?: string; clientSecret?: string; refreshToken?: string; accessToken?: string; // Outlook API Config tenantId?: string; // WhatsApp Config phoneNumberId?: string; apiVersion?: string; // Twilio Config accountSid?: string; authToken?: string; fromNumber?: string; // AWS SES Config accessKeyId?: string; secretAccessKey?: string; region?: string; fromEmail?: string; // SMTP Config (Gmail, Outlook, Generic) email?: string; password?: string; host?: string; port?: number; secure?: boolean; user?: string; from?: string; tls?: any; // SendGrid SMTP Config apiKey?: string; templateId?: string; dynamicTemplateData?: any; // Knowlarity Config callerNumber?: string; apiSecret?: string; baseUrl?: string; callType?: 'voice' | 'sms'; voiceMessage?: string; language?: string; // Common optional fields [key: string]: any; }; @IsOptional() @IsNumber() priority?: number; @IsOptional() @IsBoolean() is_default?: boolean; } export class UpdateConfigStatusDto { @IsNotEmpty() @IsNumber() status: number; } export class UpdateConfigDto { @IsOptional() @IsObject() config?: { // OAuth Control useOAuth?: boolean; // Gmail API Config clientId?: string; clientSecret?: string; refreshToken?: string; accessToken?: string; // Outlook API Config tenantId?: string; // WhatsApp Config phoneNumberId?: string; apiVersion?: string; // Twilio Config accountSid?: string; authToken?: string; fromNumber?: string; // AWS SES Config accessKeyId?: string; secretAccessKey?: string; region?: string; fromEmail?: string; // SMTP Config (Gmail, Outlook, Generic) email?: string; password?: string; host?: string; port?: number; secure?: boolean; user?: string; from?: string; tls?: any; // SendGrid SMTP Config apiKey?: string; templateId?: string; dynamicTemplateData?: any; // Knowlarity Config callerNumber?: string; apiSecret?: string; baseUrl?: string; callType?: 'voice' | 'sms'; voiceMessage?: string; language?: string; // Common optional fields [key: string]: any; }; @IsOptional() @IsNumber() priority?: number; @IsOptional() @IsBoolean() is_default?: boolean; @IsOptional() @IsNumber() status?: number; } export class GenericSendMessageDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; @IsNotEmpty() to: string | string[]; @IsNotEmpty() @IsString() message: string; @IsOptional() @IsNumber() user_id?: number; @IsOptional() @IsString() subject?: string; @IsOptional() @IsIn(['EMAIL', 'SMS', 'WA', 'TELEPHONE']) type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE'; @IsOptional() @IsIn(['high', 'medium', 'low']) priority?: 'high' | 'medium' | 'low'; @IsOptional() cc?: string | string[]; @IsOptional() bcc?: string | string[]; @IsOptional() @IsString() html?: string; @IsOptional() attachments?: any[]; @IsOptional() @IsString() mediaUrl?: string; @IsOptional() @IsString() templateId?: string; @IsOptional() @IsObject() variables?: Record; } export class BulkMessageDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; @IsNotEmpty() recipients: string[]; @IsNotEmpty() @IsString() message: string; @IsOptional() @IsNumber() user_id?: number; @IsOptional() @IsString() subject?: string; @IsOptional() @IsIn(['EMAIL', 'SMS', 'WA', 'TELEPHONE']) type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE'; @IsOptional() @IsIn(['high', 'medium', 'low']) priority?: 'high' | 'medium' | 'low'; @IsOptional() @IsString() html?: string; @IsOptional() @IsString() templateId?: string; @IsOptional() @IsObject() variables?: Record; @IsOptional() @IsNumber() batchSize?: number; } export class GmailOAuthInitDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; @IsOptional() @IsString() email?: string; } export class OAuthCallbackDto { @IsNotEmpty() @IsString() code: string; @IsNotEmpty() @IsString() state: string; } export class OutlookOAuthInitDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; @IsOptional() @IsString() email?: string; } export class SendGridVerifiedSendersDto { @IsNotEmpty() @IsString() apiKey: string; } export class SendGridTemplatesDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; } export class GetIntegrationTemplatesDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; @IsNotEmpty() @IsString() integration_type: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE'; } export class VerifiedSenderDto { @IsString() label: string; @IsString() value: string; } export class TemplateDto { @IsString() id: string; @IsString() name: string; @IsString() generation: string; } export class VerifiedSendersResponseDto { @IsBoolean() success: boolean; @IsOptional() data?: VerifiedSenderDto[]; @IsOptional() @IsString() error?: string; } export class TemplatesResponseDto { @IsBoolean() success: boolean; @IsOptional() data?: TemplateDto[]; @IsOptional() @IsString() error?: string; } export class CreateUserIntegrationDto { @IsNotEmpty() @IsNumber() user_id: number; @IsNotEmpty() @IsNumber() integration_config_id: number; @IsOptional() @IsString() external_user_id?: string; @IsOptional() @IsObject() external_user_data?: { // Ozonetel agent mapping (admin creds like userName, campaignName stay in config) agentId?: string; agentEmail?: string; agentPhone?: string; // Tubelight agent mapping (admin creds like userName/password stay in config) agentNumber?: string; extension?: string; department?: string; // Common agent fields (no admin credentials stored here) displayName?: string; role?: string; skillLevel?: string; metadata?: any; [key: string]: any; }; @IsOptional() @IsBoolean() is_active?: boolean; } export class UpdateUserIntegrationDto { @IsOptional() @IsString() external_user_id?: string; @IsOptional() @IsObject() external_user_data?: { // Ozonetel agent mapping (admin creds like userName, campaignName stay in config) agentId?: string; agentEmail?: string; agentPhone?: string; // Tubelight agent mapping (admin creds like userName/password stay in config) agentNumber?: string; extension?: string; department?: string; // Common agent fields (no admin credentials stored here) displayName?: string; role?: string; skillLevel?: string; metadata?: any; [key: string]: any; }; @IsOptional() @IsNumber() status?: number; @IsOptional() @IsBoolean() is_active?: boolean; } export class CheckAgentStatusDto { @IsNotEmpty() @IsNumber() levelId: number; @IsNotEmpty() @IsString() levelType: string; @IsNotEmpty() @IsString() app_code: string; @IsNotEmpty() @IsNumber() user_id: number; @IsOptional() @IsIn(['TELEPHONE']) type?: 'TELEPHONE'; } export class BulkCreateUserIntegrationDto { @IsNotEmpty() @IsArray() @ValidateNested({ each: true }) @Type(() => CreateUserIntegrationDto) user_integrations: CreateUserIntegrationDto[]; }