forked from Yara724/api
28 lines
860 B
TypeScript
28 lines
860 B
TypeScript
import { Injectable, NotFoundException } from "@nestjs/common";
|
|
import { ExpertInsurerService } from "src/expert-insurer/expert-insurer.service";
|
|
import { buildInsurerFileReport } from "./case-expert-report.builder";
|
|
import { InsurerFileReportViewModel } from "./case-expert-report.types";
|
|
|
|
@Injectable()
|
|
export class CaseExpertReportService {
|
|
constructor(
|
|
private readonly expertInsurerService: ExpertInsurerService,
|
|
) {}
|
|
|
|
async generateForInsurer(
|
|
publicId: string,
|
|
actor: { clientKey?: string },
|
|
): Promise<InsurerFileReportViewModel> {
|
|
const clientKey = actor?.clientKey;
|
|
if (!clientKey) {
|
|
throw new NotFoundException("Insurer context not found");
|
|
}
|
|
|
|
const file = await this.expertInsurerService.retrieveFileDetailsByPublicId(
|
|
clientKey,
|
|
publicId,
|
|
);
|
|
return buildInsurerFileReport(file);
|
|
}
|
|
}
|