forked from Yara724/api
Implement role-complete inquiry participants
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator";
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateIf,
|
||||
} from "class-validator";
|
||||
import { Types } from "mongoose";
|
||||
import { AddPlateDto } from "src/profile/dto/user/AddPlateDto";
|
||||
import { StepsEnum } from "src/Types&Enums/blame-request-management/steps.enum";
|
||||
@@ -10,6 +16,7 @@ import {
|
||||
} from "src/Types&Enums/blame-request-management/accident-conditions.enum";
|
||||
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
|
||||
import { IsEnum } from "class-validator";
|
||||
import { InquiryParticipantFieldsDto } from "./inquiry-participants.dto";
|
||||
|
||||
export class InitialFormDto {
|
||||
@ApiProperty({ required: false, default: false })
|
||||
@@ -227,10 +234,10 @@ export class BlameConfessionDtoV2 {
|
||||
* All identity and license fields from {@link AddPlateDto} are preserved; only
|
||||
* `plate` is replaced by `vin` (the 17-character chassis / VIN string).
|
||||
*/
|
||||
export class InitialFormVinDto {
|
||||
@ApiProperty({
|
||||
export class InitialFormVinDto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
type: String,
|
||||
required: true,
|
||||
required: false,
|
||||
description: "17-character VIN / chassis number (شماره شاسی)",
|
||||
example: "NAAM01E15HK123456",
|
||||
maxLength: 17,
|
||||
@@ -238,30 +245,49 @@ export class InitialFormVinDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(17)
|
||||
@ValidateIf((dto) => !dto.vehicle?.vin)
|
||||
vin: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
@ApiPropertyOptional({
|
||||
type: String,
|
||||
description: "Legacy third-party policyholder national code",
|
||||
})
|
||||
@ValidateIf((dto) => !dto.thirdPartyPolicyholder)
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
@ApiPropertyOptional({
|
||||
type: String,
|
||||
description: "Legacy driver national code",
|
||||
})
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
@ApiPropertyOptional({ type: String })
|
||||
insurerLicense: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
@ApiPropertyOptional({ type: String })
|
||||
driverLicense: string;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true })
|
||||
@ApiPropertyOptional({
|
||||
type: Boolean,
|
||||
description: "Legacy role relationship",
|
||||
})
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true, default: false })
|
||||
@ApiPropertyOptional({ type: Boolean, default: false })
|
||||
isNewCar: boolean;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true })
|
||||
@ApiPropertyOptional({
|
||||
type: Boolean,
|
||||
description: "Legacy; use driver.hasDrivingLicense",
|
||||
})
|
||||
userNoCertificate: boolean;
|
||||
|
||||
@ApiProperty({ type: Number, required: true })
|
||||
@ApiPropertyOptional({
|
||||
type: Number,
|
||||
description: "Legacy policyholder birthday",
|
||||
})
|
||||
insurerBirthday: number;
|
||||
|
||||
@ApiPropertyOptional({ type: String, required: false })
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { Type } from "class-transformer";
|
||||
import {
|
||||
IsBoolean,
|
||||
IsEnum,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
|
||||
export enum InquiryParticipantRole {
|
||||
DRIVER = "DRIVER",
|
||||
VEHICLE_OWNER = "VEHICLE_OWNER",
|
||||
THIRD_PARTY_POLICYHOLDER = "THIRD_PARTY_POLICYHOLDER",
|
||||
CAR_BODY_POLICYHOLDER = "CAR_BODY_POLICYHOLDER",
|
||||
}
|
||||
|
||||
export enum VehicleRegistrationState {
|
||||
CURRENT = "CURRENT",
|
||||
RECENTLY_TRANSFERRED = "RECENTLY_TRANSFERRED",
|
||||
}
|
||||
|
||||
export class InquiryPlateDto {
|
||||
@ApiProperty({ example: "44" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
leftDigits: string;
|
||||
|
||||
@ApiProperty({ example: "ب" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerAlphabet: string;
|
||||
|
||||
@ApiProperty({ example: "111" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerDigits: string;
|
||||
|
||||
@ApiProperty({ example: "22" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
ir: string;
|
||||
}
|
||||
|
||||
export class InquiryParticipantInputDto {
|
||||
@ApiPropertyOptional({ enum: InquiryParticipantRole })
|
||||
@IsOptional()
|
||||
@IsEnum(InquiryParticipantRole)
|
||||
sameAs?: InquiryParticipantRole;
|
||||
|
||||
@ApiPropertyOptional({ example: "0012345678" })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
nationalCode?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: "1370/01/01" })
|
||||
@IsOptional()
|
||||
birthday?: string | number;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
fullName?: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
phoneNumber?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: "Required for a driver who has a licence.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
hasDrivingLicense?: boolean;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
licenseNumber?: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
licenseType?: string;
|
||||
}
|
||||
|
||||
export class InquiryVehicleInputDto {
|
||||
@ApiProperty({ enum: VehicleRegistrationState })
|
||||
@IsEnum(VehicleRegistrationState)
|
||||
registrationState: VehicleRegistrationState;
|
||||
|
||||
@ApiProperty({ type: InquiryPlateDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryPlateDto)
|
||||
currentPlate: InquiryPlateDto;
|
||||
|
||||
@ApiPropertyOptional({ type: InquiryPlateDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryPlateDto)
|
||||
previousPlate?: InquiryPlateDto;
|
||||
|
||||
@ApiPropertyOptional({ maxLength: 17, example: "NAAM01E15HK123456" })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(17)
|
||||
vin?: string;
|
||||
}
|
||||
|
||||
/** New role-complete contract mixed into every inquiry DTO. Legacy fields remain during rollout. */
|
||||
export class InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({ type: InquiryParticipantInputDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
driver?: InquiryParticipantInputDto;
|
||||
|
||||
@ApiPropertyOptional({ type: InquiryParticipantInputDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
vehicleOwner?: InquiryParticipantInputDto;
|
||||
|
||||
@ApiPropertyOptional({ type: InquiryParticipantInputDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
thirdPartyPolicyholder?: InquiryParticipantInputDto;
|
||||
|
||||
@ApiPropertyOptional({ type: InquiryParticipantInputDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
carBodyPolicyholder?: InquiryParticipantInputDto;
|
||||
|
||||
@ApiPropertyOptional({ type: InquiryVehicleInputDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryVehicleInputDto)
|
||||
vehicle?: InquiryVehicleInputDto;
|
||||
}
|
||||
@@ -5,9 +5,11 @@ import {
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateIf,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
import { InquiryParticipantFieldsDto } from "./inquiry-participants.dto";
|
||||
|
||||
class PlateV6Dto {
|
||||
@ApiProperty({ example: "44", description: "Left two digits" })
|
||||
@@ -25,7 +27,10 @@ class PlateV6Dto {
|
||||
@IsNotEmpty()
|
||||
centerDigits: string;
|
||||
|
||||
@ApiProperty({ example: "22", description: "Right two digits (Iran region code)" })
|
||||
@ApiProperty({
|
||||
example: "22",
|
||||
description: "Right two digits (Iran region code)",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
ir: string;
|
||||
@@ -35,35 +40,52 @@ class PlateV6Dto {
|
||||
* 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 {
|
||||
@ApiProperty({
|
||||
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;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy third-party policyholder national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.thirdPartyPolicyholder)
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy driver national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@ApiPropertyOptional({
|
||||
example: true,
|
||||
description: "Legacy role relationship",
|
||||
})
|
||||
@IsBoolean()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
@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.",
|
||||
description:
|
||||
"Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
@@ -90,8 +112,8 @@ export class RunCallCenterInquiryV6Dto {
|
||||
* Identical to `RunCallCenterInquiryV6Dto` but replaces `plate` with `vin`.
|
||||
* Sheba (IBAN) is intentionally absent — the user provides it themselves via the link.
|
||||
*/
|
||||
export class RunCallCenterInquiryVinV6Dto {
|
||||
@ApiProperty({
|
||||
export class RunCallCenterInquiryVinV6Dto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
example: "NAAM01E15HK123456",
|
||||
description: "17-character VIN / chassis number (شماره شاسی)",
|
||||
maxLength: 17,
|
||||
@@ -99,28 +121,45 @@ export class RunCallCenterInquiryVinV6Dto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(17)
|
||||
@ValidateIf((dto) => !dto.vehicle?.vin)
|
||||
vin: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy third-party policyholder national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.thirdPartyPolicyholder)
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy driver national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@ApiPropertyOptional({
|
||||
example: true,
|
||||
description: "Legacy role relationship",
|
||||
})
|
||||
@IsBoolean()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
@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.",
|
||||
description:
|
||||
"Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
@@ -5,9 +5,11 @@ import {
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateIf,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
import { InquiryParticipantFieldsDto } from "./inquiry-participants.dto";
|
||||
|
||||
class PlateV3Dto {
|
||||
@ApiProperty({ example: "44", description: "Left two digits" })
|
||||
@@ -25,7 +27,10 @@ class PlateV3Dto {
|
||||
@IsNotEmpty()
|
||||
centerDigits: string;
|
||||
|
||||
@ApiProperty({ example: "22", description: "Right two digits (Iran region code)" })
|
||||
@ApiProperty({
|
||||
example: "22",
|
||||
description: "Right two digits (Iran region code)",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
ir: string;
|
||||
@@ -35,33 +40,53 @@ class PlateV3Dto {
|
||||
* Body for `POST run-inquiries/:requestId`.
|
||||
* First call = guilty party (+ auto claim). Second call = damaged party (THIRD_PARTY only).
|
||||
*/
|
||||
export class RunInquiriesV3Dto {
|
||||
@ApiProperty({
|
||||
export class RunInquiriesV3Dto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
type: PlateV3Dto,
|
||||
description: "Plate segments — Tejarat block / third-party inquiry.",
|
||||
})
|
||||
@ValidateNested()
|
||||
@Type(() => PlateV3Dto)
|
||||
@ValidateIf((dto) => !dto.vehicle?.currentPlate)
|
||||
plate: PlateV3Dto;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy third-party policyholder national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.thirdPartyPolicyholder)
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy driver national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@ApiPropertyOptional({
|
||||
example: true,
|
||||
description: "Legacy role relationship",
|
||||
})
|
||||
@IsBoolean()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
@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." })
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description:
|
||||
"Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
@@ -106,8 +131,8 @@ export class RunInquiriesV3Dto {
|
||||
* Identical to RunInquiriesV3Dto but uses `vin` (17-char chassis number) instead of `plate`.
|
||||
* First call = guilty party (+ auto claim). Second call = damaged party (THIRD_PARTY only).
|
||||
*/
|
||||
export class RunInquiriesVinV3Dto {
|
||||
@ApiProperty({
|
||||
export class RunInquiriesVinV3Dto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
example: "NAAM01E15HK123456",
|
||||
description: "17-character VIN / chassis number (شماره شاسی)",
|
||||
maxLength: 17,
|
||||
@@ -115,26 +140,46 @@ export class RunInquiriesVinV3Dto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(17)
|
||||
@ValidateIf((dto) => !dto.vehicle?.vin)
|
||||
vin: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy third-party policyholder national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.thirdPartyPolicyholder)
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@ApiPropertyOptional({
|
||||
example: "1234567890",
|
||||
description: "Legacy driver national code",
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@ApiPropertyOptional({
|
||||
example: true,
|
||||
description: "Legacy role relationship",
|
||||
})
|
||||
@IsBoolean()
|
||||
@ValidateIf((dto) => !dto.driver)
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
@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." })
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description:
|
||||
"Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user