forked from Yara724/api
Require structured inquiry participant inputs
This commit is contained in:
@@ -1,182 +1,14 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import {
|
||||
IsBoolean,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateIf,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
import { InquiryParticipantFieldsDto } from "src/common/dto/inquiry-participants.dto";
|
||||
|
||||
class PlateV6Dto {
|
||||
@ApiProperty({ example: "44", description: "Left two digits" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
leftDigits: string;
|
||||
|
||||
@ApiProperty({ example: "ب", description: "Center alphabet letter" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerAlphabet: string;
|
||||
|
||||
@ApiProperty({ example: "111", description: "Center three digits" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerDigits: string;
|
||||
|
||||
@ApiProperty({
|
||||
example: "22",
|
||||
description: "Right two digits (Iran region code)",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
ir: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inquiry body for the V6 call-center flow.
|
||||
* Same as V3 but without `sheba` — the user adds their own IBAN later via the link.
|
||||
*/
|
||||
export class RunCallCenterInquiryV6Dto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
type: PlateV6Dto,
|
||||
description: "Plate segments — Tejarat block / third-party inquiry.",
|
||||
})
|
||||
@ValidateNested()
|
||||
@Type(() => PlateV6Dto)
|
||||
@ValidateIf((dto) => !dto.vehicle?.currentPlate)
|
||||
plate: PlateV6Dto;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy third-party policyholder national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.thirdPartyPolicyholder)
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy driver national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: true,
|
||||
description: "Legacy role relationship",
|
||||
})
|
||||
@IsBoolean()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description: "Legacy policyholder birth date (Jalali)",
|
||||
})
|
||||
insurerBirthday: number | string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description:
|
||||
"Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Driver license (required when driverIsInsurer is false).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
driverLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Insurer license (required when driverIsInsurer is true).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
insurerLicense?: string;
|
||||
}
|
||||
export class RunCallCenterInquiryV6Dto extends InquiryParticipantFieldsDto {}
|
||||
|
||||
/**
|
||||
* VIN / chassis variant of the V6 call-center inquiry.
|
||||
* Identical to `RunCallCenterInquiryV6Dto` but replaces `plate` with `vin`.
|
||||
* Sheba (IBAN) is intentionally absent — the user provides it themselves via the link.
|
||||
*/
|
||||
export class RunCallCenterInquiryVinV6Dto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
example: "NAAM01E15HK123456",
|
||||
description: "17-character VIN / chassis number (شماره شاسی)",
|
||||
maxLength: 17,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(17)
|
||||
@ValidateIf((dto) => !dto.vehicle?.vin)
|
||||
vin: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy third-party policyholder national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.thirdPartyPolicyholder)
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy driver national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: true,
|
||||
description: "Legacy role relationship",
|
||||
})
|
||||
@IsBoolean()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description: "Legacy policyholder birth date (Jalali)",
|
||||
})
|
||||
insurerBirthday: number | string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description:
|
||||
"Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Driver license (required when driverIsInsurer is false).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
driverLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Insurer license (required when driverIsInsurer is true).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
insurerLicense?: string;
|
||||
}
|
||||
export class RunCallCenterInquiryVinV6Dto extends InquiryParticipantFieldsDto {}
|
||||
|
||||
Reference in New Issue
Block a user