Files
yara724-api/src/lookups/lookups.controller.ts
2026-09-16 16:05:54 +03:30

886 lines
27 KiB
TypeScript

import { Controller, Get, Param, ParseIntPipe, Query, UseGuards } from "@nestjs/common";
import {
ApiBearerAuth,
ApiOkResponse,
ApiOperation,
ApiParam,
ApiQuery,
ApiTags,
} from "@nestjs/swagger";
import { AuthGuard } from "src/common/auth/guards";
import { LookupsService } from "./lookups.service";
@ApiTags("lookups")
@ApiBearerAuth()
@UseGuards(AuthGuard)
@Controller("lookups")
export class LookupsController {
constructor(private readonly lookupsService: LookupsService) {}
@Get("accident-causes")
@ApiOkResponse({
description: "Returns accident causes lookup data",
schema: {
type: "array",
items: {
type: "object",
properties: {
Caption: { type: "string" },
Id: { type: "number" },
IsActive: { type: "number" },
},
},
},
})
async getAccidentCauses() {
return await this.lookupsService.getAccidentCauses();
}
@Get("vehicle-hull-accident-types")
@ApiOperation({
summary: "Fanavaran GEN.03 hull accident type lookup",
description:
"Returns values for base-claim field AccidentTypeId from car/base-info/vehicle-hull-accident-types (not the Tejarat static accident-type list).",
})
@ApiOkResponse({
description: "Returns Fanavaran vehicle hull accident types",
schema: { type: "array", items: { type: "object" } },
})
async getVehicleHullAccidentTypes() {
return await this.lookupsService.getVehicleHullAccidentTypes();
}
@Get("vehicle-hull-accident-culprit-type")
@ApiOperation({
summary: "Fanavaran GEN.03 hull culprit type lookup",
description:
"Returns values for base-claim field CulpritTypeId from car/code-list/vehicle-hull-accident-culprit-type (not accident-culprit-type used for ثالث).",
})
@ApiOkResponse({
description: "Returns Fanavaran vehicle hull accident culprit types",
schema: { type: "array", items: { type: "object" } },
})
async getVehicleHullAccidentCulpritType() {
return await this.lookupsService.getVehicleHullAccidentCulpritType();
}
@Get("vehicle-hull-dmg-kind")
@ApiOperation({
summary: "Fanavaran GEN.06 hull damage kind lookup",
description:
"Returns values for DmgSections[].DmgKindId from car/code-list/vehicle-hull-dmg-kind.",
})
@ApiOkResponse({
description: "Returns Fanavaran vehicle hull damage kinds",
schema: { type: "array", items: { type: "object" } },
})
async getVehicleHullDmgKind() {
return await this.lookupsService.getVehicleHullDmgKind();
}
@Get("vehicle-hull-dmg-cost-kinds")
@ApiOperation({
summary: "Fanavaran GEN.06 hull damage cost kind lookup",
description:
"Returns values for DmgSections[].DmgSectionCosts[].DmgCostKindId from car/base-info/vehicle-hull-dmg-cost-kinds.",
})
@ApiOkResponse({
description: "Returns Fanavaran vehicle hull damage cost kinds",
schema: { type: "array", items: { type: "object" } },
})
async getVehicleHullDmgCostKinds() {
return await this.lookupsService.getVehicleHullDmgCostKinds();
}
@Get("vehicle-hull-dmg-accessories/:policyId")
@ApiOperation({
summary: "Fanavaran GEN.06 hull policy damage accessories",
description:
"Returns rows for DmgSections[].VehicleHullAccessoryId from car/vehicle-hull-policies/{policyId}/dmg-accessories. PolicyId is required (Fanavaran: کد رایانه ریسورس).",
})
@ApiParam({
name: "policyId",
description: "Fanavaran hull policy Id (same as GEN.03 PolicyId)",
example: 13764610,
})
@ApiOkResponse({
description: "Returns Fanavaran vehicle hull damage accessories for the policy",
schema: { type: "array", items: { type: "object" } },
})
async getVehicleHullDmgAccessoriesByPolicyId(
@Param("policyId", ParseIntPipe) policyId: number,
) {
return await this.lookupsService.getVehicleHullDmgAccessoriesByPolicyId(
policyId,
);
}
@Get("accident-report-type")
@ApiOkResponse({
description: "Returns accident report type lookup data",
schema: {
type: "array",
items: {
type: "object",
},
},
})
async getAccidentReportType() {
return await this.lookupsService.getAccidentReportType();
}
@Get("vehicle-use-types")
@ApiOkResponse({
description: "Returns vehicle use types lookup data",
schema: {
type: "array",
items: {
type: "object",
},
},
})
async getVehicleUseTypes() {
return await this.lookupsService.getVehicleUseTypes();
}
@Get("dmg-pay-method")
@ApiOkResponse({
description: "Returns damage pay method lookup data",
schema: {
type: "array",
items: {
type: "object",
},
},
})
async getDmgPayMethod() {
return await this.lookupsService.getDmgPayMethod();
}
@Get("driving-licence-types")
@ApiOperation({
summary: "Fanavaran driving licence types lookup",
description:
"Returns licence type codes from car/base-info/driving-licence-types (BaseURL/Api/BimeApi/v2.0/...). Used for GEN culprit licence type selection.",
})
@ApiOkResponse({
description: "Returns driving licence types lookup data",
schema: {
type: "array",
items: {
type: "object",
properties: {
Caption: { type: "string" },
Id: { type: "number" },
IsActive: { type: "number" },
},
},
},
})
async getDrivingLicenceTypes() {
return await this.lookupsService.getDrivingLicenceTypes();
}
@Get("accident-culprit-type")
@ApiOkResponse({
description: "Returns accident culprit type lookup data",
schema: {
type: "array",
items: {
type: "object",
},
},
})
async getAccidentCulpritType() {
return await this.lookupsService.getAccidentCulpritType();
}
@Get("inspection-place")
@ApiOperation({
summary: "Fanavaran GEN.08 inspection place lookup",
description:
"Returns values for expertise payload field InspectionPlaceId from car/code-list/inspection-place.",
})
@ApiOkResponse({
description: "Returns Fanavaran inspection place lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getInspectionPlace() {
return await this.lookupsService.getInspectionPlace();
}
@Get("drop-amount-status")
@ApiOperation({
summary: "Fanavaran GEN.08 drop amount status lookup",
description:
"Returns values for expertise payload field DropAmountStatus from car/code-list/drop-amount-status.",
})
@ApiOkResponse({
description: "Returns Fanavaran drop amount status lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getDropAmountStatus() {
return await this.lookupsService.getDropAmountStatus();
}
@Get("car-components")
@ApiOperation({
summary: "Fanavaran GEN.08 damaged section lookup",
description:
"Returns values for DmgSections[].DmgSectionId from car/base-info/car-components.",
})
@ApiOkResponse({
description: "Returns Fanavaran car component lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getCarComponents() {
return await this.lookupsService.getCarComponents();
}
@Get("accident-level")
@ApiOperation({
summary: "Fanavaran GEN.08 accident level lookup",
description:
"Returns values for DmgSections[].AccidentLevel from car/code-list/accident-level.",
})
@ApiOkResponse({
description: "Returns Fanavaran accident level lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getAccidentLevel() {
return await this.lookupsService.getAccidentLevel();
}
@Get("expert-status")
@ApiOperation({
summary: "Fanavaran GEN.08 expert status lookup",
description:
"Returns values for expertise response field Status from car/code-list/expert-status.",
})
@ApiOkResponse({
description: "Returns Fanavaran expert status lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getExpertStatus() {
return await this.lookupsService.getExpertStatus();
}
@Get("vehicle-kinds")
@ApiOperation({
summary: "Fanavaran GEN.12 vehicle kind lookup",
description:
"Returns values for damage case payload field VehicleKindId from car/base-info/vehicle-kinds.",
})
@ApiOkResponse({
description: "Returns Fanavaran vehicle kinds lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getVehicleKinds() {
return await this.lookupsService.getVehicleKinds();
}
@Get("person-role")
@ApiOperation({
summary: "Fanavaran person role lookup",
description:
"Returns person role codes from common/code-list/person-role.",
})
@ApiOkResponse({
description: "Returns Fanavaran person role lookup data",
schema: {
type: "array",
items: {
type: "object",
properties: {
Caption: { type: "string" },
Id: { type: "number" },
IsActive: { type: "number" },
},
},
},
})
async getPersonRole() {
return await this.lookupsService.getPersonRole();
}
@Get("file-types")
@ApiOperation({
summary: "Fanavaran file types lookup",
description:
"Returns file type codes from common/base-info/file-types. Use FileTypeId in attachment uploads.",
})
@ApiOkResponse({
description: "Returns Fanavaran file types lookup data",
schema: {
type: "array",
items: {
type: "object",
properties: {
Caption: { type: "string" },
Id: { type: "number" },
IsActive: { type: "number" },
},
},
},
})
async getFileTypes() {
return await this.lookupsService.getFileTypes();
}
@Get("cities")
@ApiOperation({
summary: "Fanavaran cities lookup",
description: "Returns city codes from common/base-info/cities.",
})
@ApiOkResponse({
description: "Returns Fanavaran cities lookup data",
schema: { type: "array", items: { type: "object" } },
})
async cities() {
return await this.lookupsService.getCities();
}
@Get("provinces")
@ApiOperation({
summary: "Fanavaran provinces lookup",
description: "Returns province codes from common/base-info/provinces.",
})
@ApiOkResponse({
description: "Returns Fanavaran provinces lookup data",
schema: { type: "array", items: { type: "object" } },
})
async provinces() {
return await this.lookupsService.getProvinces();
}
@Get("dmg-case-type")
@ApiOperation({
summary: "Fanavaran damage case type lookup",
description: "Returns damage case type codes from car/code-list/dmg-case-type.",
})
@ApiOkResponse({
description: "Returns Fanavaran damage case type lookup data",
schema: { type: "array", items: { type: "object" } },
})
async dmgCaseType() {
return await this.lookupsService.getDmgCaseType();
}
@Get("dmg-history-status")
@ApiOperation({
summary: "Fanavaran damage history status lookup",
description:
"Returns damage history status codes from car/code-list/dmg-case-history-status.",
})
@ApiOkResponse({
description: "Returns Fanavaran damage history status lookup data",
schema: { type: "array", items: { type: "object" } },
})
async dmgHistoryStatus() {
return await this.lookupsService.getDmgHistoryStatus();
}
@Get("used-place")
@ApiOperation({
summary: "Fanavaran used place lookup",
description: "Returns used place codes from car/code-list/used-place.",
})
@ApiOkResponse({
description: "Returns Fanavaran used place lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getUsedPlace() {
return await this.lookupsService.getUsedPlace();
}
@Get("dmg-business-line")
@ApiOperation({
summary: "Fanavaran damage business line lookup",
description: "Returns damage business line codes from car/code-list/dmg-business-line.",
})
@ApiOkResponse({
description: "Returns Fanavaran damage business line lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getDmgBusinessLine() {
return await this.lookupsService.getDmgBusinessLine();
}
@Get("gender")
@ApiOperation({
summary: "Fanavaran GEN.44 gender lookup",
description:
"Returns values for other-people payload field GenderId from common/code-list/gender.",
})
@ApiOkResponse({
description: "Returns Fanavaran gender lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getGender() {
return await this.lookupsService.getGender();
}
@Get("marital-status")
@ApiOperation({
summary: "Fanavaran GEN.44 marital status lookup",
description:
"Returns values for other-people payload field MaritalStatus from common/code-list/marital-status.",
})
@ApiOkResponse({
description: "Returns Fanavaran marital status lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getMaritalStatus() {
return await this.lookupsService.getMaritalStatus();
}
@Get("ans")
@ApiOperation({
summary: "Fanavaran GEN.44 yes/no lookup",
description:
"Returns values for other-people fields IsIranian / IsValid / IsVerified from common/code-list/ans.",
})
@ApiOkResponse({
description: "Returns Fanavaran yes/no (ans) lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getAns() {
return await this.lookupsService.getAns();
}
@Get("countries")
@ApiOperation({
summary: "Fanavaran GEN.44 countries lookup",
description:
"Returns values for other-people payload field NationalityId from common/base-info/countries.",
})
@ApiOkResponse({
description: "Returns Fanavaran countries lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getCountries() {
return await this.lookupsService.getCountries();
}
@Get("person-kind")
@ApiOperation({
summary: "Fanavaran GEN.44 person kind lookup",
description:
"Returns values for other-people payload field PersonKindId from common/code-list/person-kind.",
})
@ApiOkResponse({
description: "Returns Fanavaran person kind lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getPersonKind() {
return await this.lookupsService.getPersonKind();
}
@Get("cii-validation-status")
@ApiOperation({
summary: "Fanavaran GEN.44 CII validation status lookup",
description:
"Returns values for other-people response fields CIIValidationStatus / CIIMobileStatus from common/code-list/cii-validation-status.",
})
@ApiOkResponse({
description: "Returns Fanavaran CII validation status lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getCiiValidationStatus() {
return await this.lookupsService.getCiiValidationStatus();
}
@Get("inquiry-by-vin")
@ApiOperation({
summary: "Fanavaran vehicle inquiry by VIN",
description:
"GET car/vehicles/inquiry-by-vin. Response includes UsedId (AccidentVehicleUsedId), VehicleKindId, plus vehicleKind/used lookup rows. Prefer this over vehicle GET when you already have the VIN.",
})
@ApiQuery({
name: "vin",
description: "Vehicle Identification Number (VIN)",
example: "IRNKAEK4150012345",
})
@ApiOkResponse({
description: "Returns Fanavaran vehicle inquiry data for the VIN",
schema: { type: "object" },
})
async inquiryByVin(@Query("vin") vin: string) {
return await this.lookupsService.inquiryByVin(vin);
}
@Get("inquiry-by-unique-identifier")
@ApiOperation({
summary: "Fanavaran party inquiry by national code and birthday",
description:
"GET common/parties/inquiry-by-unique-identifier. Use this to resolve GEN.12 DriverId. Pass birthday as 13480313 or 1348/03/13, or birthYear+birthMonth+birthDay.",
})
@ApiQuery({ name: "nationalCode", example: "0012345678" })
@ApiQuery({
name: "birthday",
required: false,
example: "13480313",
description: "Jalali birthday compact (13480313) or delimited (1348/03/13)",
})
@ApiQuery({ name: "birthYear", required: false, example: 1348 })
@ApiQuery({ name: "birthMonth", required: false, example: 3 })
@ApiQuery({ name: "birthDay", required: false, example: 13 })
@ApiOkResponse({
description: "Fanavaran parties plus picked driverId / insurerId",
schema: { type: "object" },
})
async inquiryByUniqueIdentifier(
@Query("nationalCode") nationalCode?: string,
@Query("birthday") birthday?: string,
@Query("birthYear") birthYear?: string,
@Query("birthMonth") birthMonth?: string,
@Query("birthDay") birthDay?: string,
) {
return await this.lookupsService.inquiryByUniqueIdentifier({
nationalCode,
birthday,
birthYear,
birthMonth,
birthDay,
});
}
@Get("other-people/:personId")
@ApiOperation({
summary: "Fanavaran GEN.44 other person by id",
description:
"GET common/other-people/{Id}. Use after parties inquiry misses and GEN.44 create, or to inspect a known person Id.",
})
@ApiParam({
name: "personId",
description: "Fanavaran other-people Id",
example: 4553876,
})
@ApiOkResponse({
description: "Returns the Fanavaran other-person record",
schema: { type: "object" },
})
async otherPersonById(@Param("personId", ParseIntPipe) personId: number) {
return await this.lookupsService.otherPersonById(personId);
}
@Get("fanavaran")
@ApiOperation({
summary: "List configured Fanavaran remote lookups",
description:
"Returns the lookup names available through /lookups/fanavaran/{lookupName}.",
})
async listFanavaranRemoteLookups() {
return this.lookupsService.listFanavaranRemoteLookups().map((lookup) => ({
name: lookup.name,
cacheFile: lookup.cacheFile,
url: lookup.url,
}));
}
@Get("fanavaran/:lookupName")
@ApiOperation({
summary: "Fetch a Fanavaran remote lookup by name",
description:
"Generic cached Fanavaran lookup fetcher for configured lookup names, including GEN.08 expertise lookups.",
})
@ApiParam({
name: "lookupName",
description:
"Configured Fanavaran lookup name, for example inspection-place, drop-amount-status, car-components, accident-level, expert-status",
})
@ApiOkResponse({
description: "Returns cached or live Fanavaran lookup data",
schema: { type: "array", items: { type: "object" } },
})
async getFanavaranRemoteLookup(@Param("lookupName") lookupName: string) {
return await this.lookupsService.getClientRemoteLookup(lookupName);
}
@Get("accident-way")
@ApiOkResponse({
description:
"Returns accident way options for the add-accident-fields step",
schema: {
type: "array",
items: {
type: "object",
properties: {
id: { type: "number", example: 9 },
label: { type: "string", example: "جلو به پهلو" },
},
},
},
})
async getAccidentWay() {
return await this.lookupsService.getAccidentWay();
}
@Get("accident-reason")
@ApiOkResponse({
description:
"Returns accident reason options for the add-accident-fields step",
schema: {
type: "array",
items: {
type: "object",
properties: {
id: { type: "number", example: 23 },
label: { type: "string", example: "عدم رعايت فاصله جانبی" },
fanavaran: { type: "number", example: 3 },
},
},
},
})
async getAccidentReason() {
return await this.lookupsService.getAccidentReason();
}
@Get("accident-type")
@ApiOkResponse({
description:
"Returns accident type options for the add-accident-fields step",
schema: {
type: "array",
items: {
type: "object",
properties: {
id: { type: "number", example: 3 },
label: {
type: "string",
example: "برخورد یک وسیله نقلیه با وسیله نقلیه پارک شده",
},
},
},
},
})
async getAccidentType() {
return await this.lookupsService.getAccidentType();
}
@Get("accident-fields")
@ApiOkResponse({
description:
"Returns all three accident field lookup lists in one call — drop-in replacement for the deprecated expert-blame/request/accident-fields endpoint",
schema: {
type: "object",
properties: {
client: { type: "string", example: "tejaratno" },
accidentWay: {
type: "array",
items: {
type: "object",
properties: {
id: { type: "number", example: 9 },
label: { type: "string", example: "جلو به پهلو" },
},
},
},
accidentReason: {
type: "array",
items: {
type: "object",
properties: {
id: { type: "number", example: 23 },
label: { type: "string", example: "عدم رعايت فاصله جانبی" },
fanavaran: { type: "number", example: 3 },
},
},
},
accidentType: {
type: "array",
items: {
type: "object",
properties: {
id: { type: "number", example: 3 },
label: {
type: "string",
example: "برخورد یک وسیله نقلیه با وسیله نقلیه پارک شده",
},
},
},
},
},
},
})
async getAccidentFields() {
return await this.lookupsService.getAccidentFields();
}
@Get("my-policies")
@ApiOperation({
summary: "My policies inquiry",
description:
"Returns the list of policies for the given national code via common/Policies/inquiry-my-policies.",
})
@ApiQuery({
name: "nationalCode",
description: "National code of the insured person",
example: "0012345678",
})
@ApiQuery({
name: "insuranceLineId",
description: "Insurance line ID (default: 5 for car)",
required: false,
example: 5,
})
@ApiOkResponse({
description: "Returns list of policies",
schema: { type: "array", items: { type: "object" } },
})
async myPolicies(
@Query("nationalCode") nationalCode: string,
@Query("insuranceLineId") insuranceLineId?: number,
) {
return await this.lookupsService.myPolicies(
nationalCode,
insuranceLineId ?? 5,
);
}
@Get("processed-third-party-policy")
@ApiOperation({
summary: "Last processed third-party policy for a car",
description:
"Lists Fanavaran policies by national code (InsuranceLineId=5), hydrates each with the third-party policy GET and vehicle GET, matches VIN (preferred) and/or the four plaque parts, then returns that car's last policy. VIN/plaque never open the policy list.",
})
@ApiQuery({ name: "nationalCode", example: "0012345678" })
@ApiQuery({ name: "vin", required: false, example: "IRNKAEK4150012345" })
@ApiQuery({ name: "plaqueLeft", required: false, example: "12" })
@ApiQuery({ name: "plaqueLetter", required: false, example: "ب" })
@ApiQuery({ name: "plaqueRight", required: false, example: "345" })
@ApiQuery({ name: "plaqueSerial", required: false, example: "67" })
@ApiOkResponse({
description: "Mapped last third-party policy plus vehicle",
schema: { type: "object" },
})
async processedThirdPartyPolicy(
@Query("nationalCode") nationalCode?: string,
@Query("vin") vin?: string,
@Query("plaqueLeft") plaqueLeft?: string,
@Query("plaqueLetter") plaqueLetter?: string,
@Query("plaqueRight") plaqueRight?: string,
@Query("plaqueSerial") plaqueSerial?: string,
) {
return this.lookupsService.findLastProcessedCarPolicy("third-party", {
nationalCode,
vin,
plaqueLeft,
plaqueLetter,
plaqueRight,
plaqueSerial,
});
}
@Get("processed-body-policy")
@ApiOperation({
summary: "Last processed car-body (hull) policy for a car",
description:
"Same car-matching flow as processed-third-party-policy, using InsuranceLineId=4 and the hull policy GET. Uses hull ContractId when configured.",
})
@ApiQuery({ name: "nationalCode", example: "0012345678" })
@ApiQuery({ name: "vin", required: false, example: "IRNKAEK4150012345" })
@ApiQuery({ name: "plaqueLeft", required: false, example: "12" })
@ApiQuery({ name: "plaqueLetter", required: false, example: "ب" })
@ApiQuery({ name: "plaqueRight", required: false, example: "345" })
@ApiQuery({ name: "plaqueSerial", required: false, example: "67" })
@ApiOkResponse({
description: "Mapped last body policy plus vehicle",
schema: { type: "object" },
})
async processedBodyPolicy(
@Query("nationalCode") nationalCode?: string,
@Query("vin") vin?: string,
@Query("plaqueLeft") plaqueLeft?: string,
@Query("plaqueLetter") plaqueLetter?: string,
@Query("plaqueRight") plaqueRight?: string,
@Query("plaqueSerial") plaqueSerial?: string,
) {
return this.lookupsService.findLastProcessedCarPolicy("car-body", {
nationalCode,
vin,
plaqueLeft,
plaqueLetter,
plaqueRight,
plaqueSerial,
});
}
@Get("third-party-policy/:policyId")
@ApiOperation({
summary: "Third-party car policy inquiry by policy ID",
description:
"Returns third-party car insurance policy details for the given policy ID via car/third-party-car-policies/{policyId}.",
})
@ApiParam({
name: "policyId",
description: "Fanavaran policy ID",
example: 12345,
})
@ApiOkResponse({
description: "Returns third-party policy details",
schema: { type: "object" },
})
async thirdPartyPolicyById(
@Param("policyId", ParseIntPipe) policyId: number,
) {
return await this.lookupsService.thirdPartyPolicyById(policyId);
}
@Get("body-policy/:policyId")
@ApiOperation({
summary: "Vehicle hull (body) policy inquiry by policy ID",
description:
"Returns vehicle hull (body) insurance policy details for the given policy ID via car/vehicle-hull-policies/{policyId}.",
})
@ApiParam({
name: "policyId",
description: "Fanavaran policy ID",
example: 12345,
})
@ApiOkResponse({
description: "Returns body policy details",
schema: { type: "object" },
})
async bodyPolicyById(@Param("policyId", ParseIntPipe) policyId: number) {
return await this.lookupsService.bodyPolicyById(policyId);
}
@Get("vehicle/:vehicleId")
@ApiOperation({
summary: "Fanavaran vehicle by id",
description:
"GET car/vehicles/{vehicleId} after a third-party/hull policy returns VehicleId. Pass the policy VehicleVersionNo when you need that exact version; omit it for the latest version. Response includes vehicleKind (VehicleGroupId) and used (UsedId) lookup rows.",
})
@ApiParam({
name: "vehicleId",
description: "Fanavaran vehicle id from the policy VehicleId field",
example: 3379978,
})
@ApiQuery({
name: "versionNo",
required: false,
description:
"Policy VehicleVersionNo. Omit to fetch the latest vehicle version.",
example: 2,
})
@ApiOkResponse({
description:
"Vehicle record plus vehicleKind, used, plaque, and color placeholders",
schema: { type: "object" },
})
async vehicleById(
@Param("vehicleId", ParseIntPipe) vehicleId: number,
@Query("versionNo") versionNo?: string,
) {
const parsedVersion =
versionNo == null || String(versionNo).trim() === ""
? undefined
: Number(versionNo);
return await this.lookupsService.vehicleById(
vehicleId,
Number.isFinite(parsedVersion) ? parsedVersion : undefined,
);
}
}