forked from Yara724/api
update the expert claim dto
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
|||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
|
import { ClaimRequiredDocumentType } from 'src/Types&Enums/claim-request-management/required-document-type.enum';
|
||||||
|
import { DamagedPartItem } from 'src/claim-request-management/dto/capture-requirements-v2.dto';
|
||||||
|
|
||||||
export class CarPartDamageV2Dto {
|
export class CarPartDamageV2Dto {
|
||||||
@ApiProperty({ example: 'left' })
|
@ApiProperty({ example: 'left' })
|
||||||
@@ -68,3 +70,14 @@ export class SubmitExpertReplyV2Dto {
|
|||||||
@Type(() => PartPricingV2Dto)
|
@Type(() => PartPricingV2Dto)
|
||||||
parts: PartPricingV2Dto[];
|
parts: PartPricingV2Dto[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ClaimSubmitResendV2Dto {
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
resendDescription: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true, examples: ClaimRequiredDocumentType })
|
||||||
|
resendDocuments: ClaimRequiredDocumentType[];
|
||||||
|
|
||||||
|
@ApiProperty({ required: true, type: [DamagedPartItem] })
|
||||||
|
resendCarParts: DamagedPartItem[];
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ import { ClaimRequiredDocumentDbService } from "src/claim-request-management/ent
|
|||||||
import { FactorStatus } from "src/Types&Enums/claim-request-management/factor-status.enum";
|
import { FactorStatus } from "src/Types&Enums/claim-request-management/factor-status.enum";
|
||||||
import { DaghiOption } from "src/Types&Enums/claim-request-management/daghi-option.enum";
|
import { DaghiOption } from "src/Types&Enums/claim-request-management/daghi-option.enum";
|
||||||
import { BranchDbService } from "src/client/entities/db-service/branch.db.service";
|
import { BranchDbService } from "src/client/entities/db-service/branch.db.service";
|
||||||
|
import { ClaimSubmitResendV2Dto } from "./dto/expert-claim-v2.dto";
|
||||||
|
import { BlameRequestDbService } from "src/request-management/entities/db-service/blame-request.db.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ExpertClaimService {
|
export class ExpertClaimService {
|
||||||
@@ -154,13 +156,14 @@ export class ExpertClaimService {
|
|||||||
private readonly claimVideoCaptureDbService: VideoCaptureDbService,
|
private readonly claimVideoCaptureDbService: VideoCaptureDbService,
|
||||||
private readonly httpService: HttpService,
|
private readonly httpService: HttpService,
|
||||||
private readonly claimCaseDbService: ClaimCaseDbService,
|
private readonly claimCaseDbService: ClaimCaseDbService,
|
||||||
|
private readonly blameRequestDbService: BlameRequestDbService,
|
||||||
private readonly sandHubService: SandHubService,
|
private readonly sandHubService: SandHubService,
|
||||||
private readonly damageExpertDbService: DamageExpertDbService,
|
private readonly damageExpertDbService: DamageExpertDbService,
|
||||||
private readonly clientDbService: ClientDbService,
|
private readonly clientDbService: ClientDbService,
|
||||||
private readonly claimFactorsImageDbService: ClaimFactorsImageDbService,
|
private readonly claimFactorsImageDbService: ClaimFactorsImageDbService,
|
||||||
private readonly claimRequiredDocumentDbService: ClaimRequiredDocumentDbService,
|
private readonly claimRequiredDocumentDbService: ClaimRequiredDocumentDbService,
|
||||||
private readonly branchDbService: BranchDbService,
|
private readonly branchDbService: BranchDbService,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
private isVisibleToClientType(client: any, actor: any): boolean {
|
private isVisibleToClientType(client: any, actor: any): boolean {
|
||||||
if (actor.userType === UserType.GENUINE) {
|
if (actor.userType === UserType.GENUINE) {
|
||||||
@@ -1255,6 +1258,66 @@ export class ExpertClaimService {
|
|||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async streamServiceV2(requestId, query, res, header) {
|
||||||
|
const request = await this.claimCaseDbService.findById(requestId);
|
||||||
|
console.log(request)
|
||||||
|
// const blameCase = await this.blameCaseDbService
|
||||||
|
return request;
|
||||||
|
// let videoPath: string = "";
|
||||||
|
// switch (query) {
|
||||||
|
// case "accident":
|
||||||
|
// videoPath = await this.getAccidentVideoPath(
|
||||||
|
// String(
|
||||||
|
// request?.blameFile?.firstPartyDetails?.firstPartyFile
|
||||||
|
// ?.firstPartyVideoId,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// break;
|
||||||
|
// case "car-capture":
|
||||||
|
// videoPath = await this.getCarCapture(requestId);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// throw new NotFoundException("Invalid query type");
|
||||||
|
// }
|
||||||
|
// if (!videoPath) throw new NotFoundException("video_not_found");
|
||||||
|
|
||||||
|
// const absolutePath = join(process.cwd(), videoPath.replace(/^\/+/, ""));
|
||||||
|
|
||||||
|
// if (!existsSync(absolutePath)) {
|
||||||
|
// throw new NotFoundException(
|
||||||
|
// `Video file not found at path: ${absolutePath}`,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const { size } = statSync(absolutePath);
|
||||||
|
// const range = header.range;
|
||||||
|
|
||||||
|
// if (range) {
|
||||||
|
// const [startStr, endStr] = range.replace(/bytes=/, "").split("-");
|
||||||
|
// const start = parseInt(startStr, 10);
|
||||||
|
// const end = endStr ? parseInt(endStr, 10) : size - 1;
|
||||||
|
// const chunkSize = end - start + 1;
|
||||||
|
|
||||||
|
// const file = createReadStream(absolutePath, { start, end });
|
||||||
|
|
||||||
|
// res.writeHead(206, {
|
||||||
|
// "Content-Range": `bytes ${start}-${end}/${size}`,
|
||||||
|
// "Accept-Ranges": "bytes",
|
||||||
|
// "Content-Length": chunkSize,
|
||||||
|
// "Content-Type": "video/mp4",
|
||||||
|
// });
|
||||||
|
|
||||||
|
// file.pipe(res);
|
||||||
|
// } else {
|
||||||
|
// res.writeHead(200, {
|
||||||
|
// "Content-Length": size,
|
||||||
|
// "Content-Type": "video/mp4",
|
||||||
|
// });
|
||||||
|
|
||||||
|
// createReadStream(absolutePath).pipe(res);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
async streamService(requestId, query, res, header) {
|
async streamService(requestId, query, res, header) {
|
||||||
const request =
|
const request =
|
||||||
await this.claimRequestManagementDbService.findOne(requestId);
|
await this.claimRequestManagementDbService.findOne(requestId);
|
||||||
@@ -1635,6 +1698,18 @@ export class ExpertClaimService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async submitResendDocsV2(
|
||||||
|
claimRequestId: string,
|
||||||
|
reply: ClaimSubmitResendV2Dto,
|
||||||
|
actor: any,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V2: Submit damage expert reply for a claim.
|
* V2: Submit damage expert reply for a claim.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Put, UseGuards } from "@nestjs/common";
|
import { Body, Controller, Get, Header, Param, Headers, Patch, Put, UseGuards, Query, Res } from "@nestjs/common";
|
||||||
import {
|
import {
|
||||||
ApiBearerAuth,
|
ApiBearerAuth,
|
||||||
ApiBody,
|
ApiBody,
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
ApiParam,
|
ApiParam,
|
||||||
ApiPropertyOptional,
|
ApiPropertyOptional,
|
||||||
|
ApiQuery,
|
||||||
ApiTags,
|
ApiTags,
|
||||||
} from "@nestjs/swagger";
|
} from "@nestjs/swagger";
|
||||||
import { IsOptional, IsString } from "class-validator";
|
import { IsOptional, IsString } from "class-validator";
|
||||||
@@ -14,7 +15,7 @@ import { Roles } from "src/decorators/roles.decorator";
|
|||||||
import { CurrentUser } from "src/decorators/user.decorator";
|
import { CurrentUser } from "src/decorators/user.decorator";
|
||||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||||
import { ExpertClaimService } from "./expert-claim.service";
|
import { ExpertClaimService } from "./expert-claim.service";
|
||||||
import { SubmitExpertReplyV2Dto } from "./dto/expert-claim-v2.dto";
|
import { ClaimSubmitResendV2Dto, SubmitExpertReplyV2Dto } from "./dto/expert-claim-v2.dto";
|
||||||
import { UpdateClaimDamagedPartsV2Dto } from "./dto/update-claim-damaged-parts-v2.dto";
|
import { UpdateClaimDamagedPartsV2Dto } from "./dto/update-claim-damaged-parts-v2.dto";
|
||||||
|
|
||||||
class InPersonVisitV2Dto {
|
class InPersonVisitV2Dto {
|
||||||
@@ -30,7 +31,7 @@ class InPersonVisitV2Dto {
|
|||||||
@UseGuards(LocalActorAuthGuard, RolesGuard)
|
@UseGuards(LocalActorAuthGuard, RolesGuard)
|
||||||
@Roles(RoleEnum.DAMAGE_EXPERT)
|
@Roles(RoleEnum.DAMAGE_EXPERT)
|
||||||
export class ExpertClaimV2Controller {
|
export class ExpertClaimV2Controller {
|
||||||
constructor(private readonly expertClaimService: ExpertClaimService) {}
|
constructor(private readonly expertClaimService: ExpertClaimService) { }
|
||||||
|
|
||||||
@Get("requests")
|
@Get("requests")
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
@@ -89,6 +90,22 @@ export class ExpertClaimV2Controller {
|
|||||||
return await this.expertClaimService.submitExpertReplyV2(claimRequestId, body, actor);
|
return await this.expertClaimService.submitExpertReplyV2(claimRequestId, body, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Put("reply/resend/:claimRequestId")
|
||||||
|
@ApiOperation({
|
||||||
|
summary: "Submit expert damage resend request. ",
|
||||||
|
description:
|
||||||
|
"Claim must be locked by this expert (status EXPERT_REVIEWING). Submitting unlocks the claim. If any part has factorNeeded=true the claim moves to EXPERT_COST_EVALUATION; otherwise moves to INSURER_REVIEW. Total payment cap is 30,000,000.",
|
||||||
|
})
|
||||||
|
@ApiParam({ name: "claimRequestId" })
|
||||||
|
@ApiBody({ type: ClaimSubmitResendV2Dto })
|
||||||
|
async submitExpertResendV2(
|
||||||
|
@Param("claimRequestId") claimRequestId: string,
|
||||||
|
@Body() body: ClaimSubmitResendV2Dto,
|
||||||
|
@CurrentUser() actor,
|
||||||
|
) {
|
||||||
|
return await this.expertClaimService.submitResendDocsV2(claimRequestId, body, actor);
|
||||||
|
}
|
||||||
|
|
||||||
@Patch(":claimRequestId/visit")
|
@Patch(":claimRequestId/visit")
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: "Request in-person visit for claim",
|
summary: "Request in-person visit for claim",
|
||||||
@@ -128,4 +145,21 @@ export class ExpertClaimV2Controller {
|
|||||||
actor,
|
actor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiQuery({
|
||||||
|
name: "query",
|
||||||
|
enum: ["car-capture", "accident"],
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@Get("stream/:id/video")
|
||||||
|
@Header("Accept-Ranges", "bytes")
|
||||||
|
@Header("Content-Type", "video/mp4")
|
||||||
|
async claimStream(
|
||||||
|
@Headers() headers,
|
||||||
|
@Param("id") id: string,
|
||||||
|
@Query("query") query: "car-capture" | "accident",
|
||||||
|
@Res() res,
|
||||||
|
) {
|
||||||
|
return this.expertClaimService.streamServiceV2(id, query, res, headers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user