import { Body, Controller, Get, Param, Patch, Put, } from "@nestjs/common"; import { ApiBody, ApiOperation, ApiParam, ApiResponse, ApiTags, } from "@nestjs/swagger"; import { ClientService } from "./client.service"; import { ClientExternalInquiriesCatalogDto, ClientExternalInquiriesListDto, ClientExternalInquiriesViewDto, ExternalInquiryFlagsDto, UpdateClientExternalInquiriesDto, } from "./dto/client-external-inquiries.dto"; /** * Per-insurer external inquiry toggles (public for now — lock down when super-admin exists). */ @ApiTags("client-external-inquiries") @Controller("client") export class ClientExternalInquiriesController { constructor(private readonly clientService: ClientService) {} @Get("external-inquiries/catalog") @ApiOperation({ summary: "List supported external inquiry kinds and API paths", description: "No auth (temporary). Describes global master switch + per-client flags.", }) @ApiResponse({ status: 200, type: ClientExternalInquiriesCatalogDto }) getCatalog(): ClientExternalInquiriesCatalogDto { return this.clientService.getExternalInquiriesCatalog(); } @Get("external-inquiries") @ApiOperation({ summary: "List external inquiry settings for all insurers", description: "No auth (temporary). Returns stored flags and effective live flags (after global master switch).", }) @ApiResponse({ status: 200, type: ClientExternalInquiriesListDto }) listAll(): Promise { return this.clientService.listExternalInquirySettings(); } @Get(":clientId/external-inquiries") @ApiOperation({ summary: "Get external inquiry settings for one insurer", description: "No auth (temporary).", }) @ApiParam({ name: "clientId", description: "Insurer client Mongo ObjectId" }) @ApiResponse({ status: 200, type: ClientExternalInquiriesViewDto }) getOne( @Param("clientId") clientId: string, ): Promise { return this.clientService.getExternalInquirySettings(clientId); } @Put(":clientId/external-inquiries") @ApiOperation({ summary: "Replace external inquiry flags for one insurer", description: "No auth (temporary). Omitted inquiry keys default to `false` (mock). Global master switch still applies at runtime.", }) @ApiParam({ name: "clientId", description: "Insurer client Mongo ObjectId" }) @ApiBody({ type: ExternalInquiryFlagsDto }) @ApiResponse({ status: 200, type: ClientExternalInquiriesViewDto }) replace( @Param("clientId") clientId: string, @Body() body: ExternalInquiryFlagsDto, ): Promise { return this.clientService.replaceExternalInquirySettings(clientId, body); } @Patch(":clientId/external-inquiries") @ApiOperation({ summary: "Partially update external inquiry flags for one insurer", description: "No auth (temporary). Only supplied flags are changed.", }) @ApiParam({ name: "clientId", description: "Insurer client Mongo ObjectId" }) @ApiBody({ type: UpdateClientExternalInquiriesDto }) @ApiResponse({ status: 200, type: ClientExternalInquiriesViewDto }) patch( @Param("clientId") clientId: string, @Body() body: UpdateClientExternalInquiriesDto, ): Promise { return this.clientService.patchExternalInquirySettings(clientId, body); } }