forked from Yara724/api
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
HttpException,
|
|
InternalServerErrorException,
|
|
Post,
|
|
UseGuards,
|
|
} from "@nestjs/common";
|
|
import {
|
|
ApiBearerAuth,
|
|
ApiBody,
|
|
ApiOperation,
|
|
ApiResponse,
|
|
ApiTags,
|
|
} from "@nestjs/swagger";
|
|
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
|
|
import { RolesGuard } from "src/auth/guards/role.guard";
|
|
import { Roles } from "src/decorators/roles.decorator";
|
|
import { RoleEnum } from "src/Types&Enums/role.enum";
|
|
import {
|
|
ReinquiryInquiriesDto,
|
|
ReinquiryInquiriesResponseDto,
|
|
} from "./dto/reinquiry-inquiries.dto";
|
|
import { InquiryRefreshService } from "./inquiry-refresh.service";
|
|
|
|
@ApiTags("blame-inquiry-refresh")
|
|
@Controller("v2/blame-inquiries")
|
|
@ApiBearerAuth()
|
|
@UseGuards(LocalActorAuthGuard, RolesGuard)
|
|
@Roles(RoleEnum.ADMIN, RoleEnum.FIELD_EXPERT)
|
|
export class InquiryRefreshController {
|
|
constructor(private readonly inquiryRefreshService: InquiryRefreshService) {}
|
|
|
|
@Post("reinquiry")
|
|
@ApiOperation({
|
|
summary: "Re-run third-party and person inquiries for blame/claim cases",
|
|
description:
|
|
"Refreshes inquiries for FIRST/SECOND parties on a blame case, updates parties + inquiries on blameCases, " +
|
|
"and syncs inquiries.thirdParty + inquiries.person to linked claimCases. " +
|
|
"Use publicId or blameRequestId for one case, or limit for bulk.",
|
|
})
|
|
@ApiBody({ type: ReinquiryInquiriesDto })
|
|
@ApiResponse({ status: 200, type: ReinquiryInquiriesResponseDto })
|
|
async reinquiry(
|
|
@Body() body: ReinquiryInquiriesDto,
|
|
): Promise<ReinquiryInquiriesResponseDto> {
|
|
try {
|
|
return await this.inquiryRefreshService.reinquiryInquiries(body);
|
|
} catch (error) {
|
|
if (error instanceof HttpException) throw error;
|
|
throw new InternalServerErrorException(
|
|
error instanceof Error ? error.message : "Failed to refresh inquiries",
|
|
);
|
|
}
|
|
}
|
|
}
|