56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import { IsNotEmpty, IsString, ValidateIf } from 'class-validator';
|
|
import {
|
|
OTP_ACTION_TYPE,
|
|
OTP_SOURCE,
|
|
OtpRequestEntity,
|
|
OtpVerifyEntity,
|
|
} from '../../domain/entities/otp-verification.entity';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
export class OtpRequestDto implements OtpRequestEntity {
|
|
@ApiProperty({
|
|
type: String,
|
|
required: true,
|
|
example: OTP_ACTION_TYPE.CANCEL_TRANSACTION,
|
|
description: 'CANCEL_TRANSACTION || CREATE_DISCOUNT',
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
action_type: OTP_ACTION_TYPE;
|
|
|
|
@ApiProperty({
|
|
type: String,
|
|
required: true,
|
|
example: OTP_SOURCE.POS,
|
|
description: 'POS || WEB',
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
source: OTP_SOURCE;
|
|
|
|
@ApiProperty({
|
|
name: 'target_id',
|
|
example: 'bccc0c6a-51a0-437f-abc8-dc18851604ee',
|
|
})
|
|
@IsString()
|
|
@ValidateIf((body) => body.target_id)
|
|
target_id: string;
|
|
|
|
@ApiProperty({ name: 'reference', example: '0625N21' })
|
|
@IsString()
|
|
@ValidateIf((body) => body.reference)
|
|
reference: string;
|
|
}
|
|
|
|
export class OtpVerifyDto extends OtpRequestDto implements OtpVerifyEntity {
|
|
@ApiProperty({
|
|
name: 'otp_code',
|
|
type: String,
|
|
required: true,
|
|
example: '2345',
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
otp_code: string;
|
|
}
|