forked from Yara724/api
212 lines
4.7 KiB
TypeScript
212 lines
4.7 KiB
TypeScript
import {
|
|
ApiHideProperty,
|
|
ApiProperty,
|
|
ApiPropertyOptional,
|
|
} from "@nestjs/swagger";
|
|
import { Type } from "class-transformer";
|
|
import {
|
|
IsBoolean,
|
|
IsEnum,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
Length,
|
|
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" })
|
|
@IsNotEmpty()
|
|
leftDigits: string | number;
|
|
|
|
@ApiProperty({ example: "ب" })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
centerAlphabet: string;
|
|
|
|
@ApiProperty({ example: "111" })
|
|
@IsNotEmpty()
|
|
centerDigits: string | number;
|
|
|
|
@ApiProperty({ example: "22" })
|
|
@IsNotEmpty()
|
|
ir: string | number;
|
|
}
|
|
|
|
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({
|
|
description: "Required for a driver who has a licence.",
|
|
})
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
hasDrivingLicense?: boolean;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
licenseNumber?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
licenseType?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
"Driver licence issue date. Required only for a driver who has a licence; Jalali YYYY/MM/DD is recommended.",
|
|
example: "1400/01/15",
|
|
})
|
|
@IsOptional()
|
|
driverLicenseDate?: string | number;
|
|
}
|
|
|
|
export class InquiryVehicleInputDto {
|
|
@ApiPropertyOptional({
|
|
enum: VehicleRegistrationState,
|
|
default: VehicleRegistrationState.CURRENT,
|
|
})
|
|
@IsOptional()
|
|
@IsEnum(VehicleRegistrationState)
|
|
registrationState?: VehicleRegistrationState;
|
|
|
|
@ApiProperty({ type: InquiryPlateDto })
|
|
@ValidateNested()
|
|
@Type(() => InquiryPlateDto)
|
|
currentPlate: InquiryPlateDto;
|
|
|
|
@ApiPropertyOptional({ type: InquiryPlateDto })
|
|
@IsOptional()
|
|
@ValidateNested()
|
|
@Type(() => InquiryPlateDto)
|
|
previousPlate?: InquiryPlateDto;
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
"National code of the policyholder associated with previousPlate. Required only for RECENTLY_TRANSFERRED vehicles.",
|
|
example: "0012345678",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
previousPolicyholderNationalCode?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
minLength: 17,
|
|
maxLength: 17,
|
|
example: "NAAM01E15HK123456",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@Length(17, 17)
|
|
vin?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Whether the vehicle is newly purchased/registered.",
|
|
})
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isNewCar?: boolean;
|
|
}
|
|
|
|
/** Structured role-complete contract mixed into every inquiry DTO. */
|
|
export class InquiryParticipantFieldsDto {
|
|
@ApiProperty({ type: InquiryParticipantInputDto })
|
|
@ValidateNested()
|
|
@Type(() => InquiryParticipantInputDto)
|
|
driver: InquiryParticipantInputDto;
|
|
|
|
@ApiProperty({ type: InquiryParticipantInputDto })
|
|
@ValidateNested()
|
|
@Type(() => InquiryParticipantInputDto)
|
|
vehicleOwner: InquiryParticipantInputDto;
|
|
|
|
@ApiProperty({ type: InquiryParticipantInputDto })
|
|
@ValidateNested()
|
|
@Type(() => InquiryParticipantInputDto)
|
|
thirdPartyPolicyholder: InquiryParticipantInputDto;
|
|
|
|
@ApiPropertyOptional({ type: InquiryParticipantInputDto })
|
|
@IsOptional()
|
|
@ValidateNested()
|
|
@Type(() => InquiryParticipantInputDto)
|
|
carBodyPolicyholder?: InquiryParticipantInputDto;
|
|
|
|
@ApiProperty({ type: InquiryVehicleInputDto })
|
|
@ValidateNested()
|
|
@Type(() => InquiryVehicleInputDto)
|
|
vehicle: InquiryVehicleInputDto;
|
|
|
|
/** Internal normalized projections; rejected as request input by the resolver. */
|
|
@ApiHideProperty()
|
|
nationalCodeOfDriver?: string;
|
|
|
|
@ApiHideProperty()
|
|
driverBirthday?: any;
|
|
|
|
@ApiHideProperty()
|
|
driverLicense?: string;
|
|
|
|
@ApiHideProperty()
|
|
driverLicenseDate?: string;
|
|
|
|
@ApiHideProperty()
|
|
licenseType?: string;
|
|
|
|
@ApiHideProperty()
|
|
nationalCodeOfInsurer?: string;
|
|
|
|
@ApiHideProperty()
|
|
insurerBirthday?: any;
|
|
|
|
@ApiHideProperty()
|
|
insurerLicense?: string;
|
|
|
|
@ApiHideProperty()
|
|
driverIsInsurer?: boolean;
|
|
|
|
@ApiHideProperty()
|
|
userNoCertificate?: boolean;
|
|
|
|
@ApiHideProperty()
|
|
plate?: any;
|
|
|
|
@ApiHideProperty()
|
|
plateId?: string;
|
|
|
|
@ApiHideProperty()
|
|
vin?: string;
|
|
|
|
@ApiHideProperty()
|
|
isNewCar?: boolean;
|
|
}
|