dcb-service-core-api/src/modules/challenge/dto/challenge.request.dto.ts
Mamadou Khoussa [028918 DSI/DAC/DIF/DS] f87650dcc2 fix it otp challenge
2025-10-24 22:39:02 +00:00

82 lines
1.3 KiB
TypeScript

import { IsString, IsNotEmpty, IsOptional, IsEnum, ValidateNested, IsArray, IsNumber, Min, Max } from 'class-validator';
import { Type } from 'class-transformer';
export enum OtpMethodEnum {
SMS = 'SMS',
USSD = 'USSD',
IVR = 'IVR'
}
export enum IdentifierTypeEnum {
MSISDN = 'MSISDN',
ISE2 = 'ISE2',
SUBSCRIBER_ID = 'SUBSCRIBER_ID'
}
export class IdentifierDto {
@IsEnum(IdentifierTypeEnum)
@IsNotEmpty()
type: IdentifierTypeEnum;
@IsString()
@IsNotEmpty()
value: string;
}
export class OtpConfigDto {
@IsOptional()
@IsString()
message?: string;
@IsOptional()
@IsNumber()
@Min(4)
@Max(8)
length?: number;
@IsOptional()
@IsString()
senderName?: string;
@IsOptional()
@IsString()
language?: string;
}
export class OtpChallengeRequestDto {
@IsString()
@IsNotEmpty()
merchantId: string;
@IsString()
@IsNotEmpty()
transactionId: string;
@ValidateNested()
@Type(() => IdentifierDto)
identifier: IdentifierDto;
@IsEnum(OtpMethodEnum)
@IsNotEmpty()
method: OtpMethodEnum;
@IsString()
@IsNotEmpty()
country: string;
@IsString()
@IsNotEmpty()
service: string;
@IsOptional()
@ValidateNested()
@Type(() => OtpConfigDto)
config?: OtpConfigDto;
@IsOptional()
@IsString()
confirmationCode?: string;
@IsOptional()
metadata?: Record<string, any>;
}