import { Controller, Get, Param, Query } from "@nestjs/common"; import { ApiOkResponse, ApiOperation, ApiParam, ApiQuery, ApiTags, } from "@nestjs/swagger"; import { LookupsService } from "./lookups.service"; @ApiTags("lookups") @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("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") @ApiOkResponse({ description: "Returns driving licence types lookup data", schema: { type: "array", items: { type: "object", }, }, }) 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("inquiry-by-vin") @ApiOperation({ summary: "Fanavaran vehicle inquiry by VIN", description: "Returns vehicle details from Fanavaran for the given VIN number via car/vehicles/inquiry-by-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("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(); } }