forked from Yara724/api
inquiry refresh service + fanavaran client config
This commit is contained in:
56
src/request-management/inquiry-refresh.controller.ts
Normal file
56
src/request-management/inquiry-refresh.controller.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
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",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user