forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
179
src/expert-claim/expert-claim.controller.ts
Normal file
179
src/expert-claim/expert-claim.controller.ts
Normal file
@@ -0,0 +1,179 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Header,
|
||||
Param,
|
||||
Put,
|
||||
Query,
|
||||
Res,
|
||||
UseGuards,
|
||||
Headers,
|
||||
Patch,
|
||||
} from "@nestjs/common";
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiBody,
|
||||
ApiParam,
|
||||
ApiQuery,
|
||||
ApiTags,
|
||||
} from "@nestjs/swagger";
|
||||
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
|
||||
import { RolesGuard } from "src/auth/guards/role.guard";
|
||||
import { ClientKey } from "src/decorators/clientKey.decorator";
|
||||
import { Roles } from "src/decorators/roles.decorator";
|
||||
import { CurrentUser } from "src/decorators/user.decorator";
|
||||
import {
|
||||
ClaimSubmitReplyDto,
|
||||
ClaimSubmitResendDto,
|
||||
} from "src/expert-claim/dto/reply.dto";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { ParseJsonPipe } from "src/utils/pipes/parse-json.pipe";
|
||||
import { ExpertClaimService } from "./expert-claim.service";
|
||||
import { FactorValidationDto } from "./dto/factor-validation.dto";
|
||||
|
||||
@ApiTags("expert-claim-panel")
|
||||
@Controller("expert-claim")
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(LocalActorAuthGuard, RolesGuard)
|
||||
@Roles(RoleEnum.DAMAGE_EXPERT)
|
||||
export class ExpertClaimController {
|
||||
constructor(private readonly expertClaimService: ExpertClaimService) {}
|
||||
|
||||
@Get()
|
||||
async getAllClaimRequests(@CurrentUser() actor, @ClientKey() client) {
|
||||
return await this.expertClaimService.getClaimRequestsListForExpert(actor);
|
||||
}
|
||||
|
||||
@Get("/:id")
|
||||
@ApiParam({ name: "id" })
|
||||
@ApiQuery({
|
||||
name: "updateDropPrice",
|
||||
required: false,
|
||||
description: "A stringified JSON object with price drop override values.",
|
||||
})
|
||||
async getClaimRequestPerId(
|
||||
@Param("id") id: string,
|
||||
@CurrentUser() currentUser,
|
||||
@Query("updateDropPrice", new ParseJsonPipe()) priceDrop?: any,
|
||||
) {
|
||||
return await this.expertClaimService.requestPerId(
|
||||
id,
|
||||
currentUser,
|
||||
priceDrop,
|
||||
);
|
||||
}
|
||||
|
||||
@Get("imageRequired/:id")
|
||||
@ApiParam({ name: "id" })
|
||||
async getImageRequired(@Param("id") id: string, @CurrentUser() currentUser) {
|
||||
return await this.expertClaimService.imageRequired(id, currentUser);
|
||||
}
|
||||
|
||||
@Get("required-documents/:id")
|
||||
@ApiParam({ name: "id" })
|
||||
async getRequiredDocuments(
|
||||
@Param("id") id: string,
|
||||
@CurrentUser() currentUser,
|
||||
) {
|
||||
return await this.expertClaimService.getRequiredDocuments(id, currentUser);
|
||||
}
|
||||
|
||||
@Put("lock/:id")
|
||||
async lockClaimRequest(@Param("id") requestId: string, @CurrentUser() actor) {
|
||||
return await this.expertClaimService.lockClaimRequest(requestId, actor);
|
||||
}
|
||||
|
||||
@Put("reply/submit/:id")
|
||||
@ApiParam({ name: "id" })
|
||||
async submitReplyRequest(
|
||||
@Param("id") requestId,
|
||||
@Body() body: ClaimSubmitReplyDto,
|
||||
@CurrentUser() actor,
|
||||
) {
|
||||
return await this.expertClaimService.submitReplyRequest(
|
||||
requestId,
|
||||
body,
|
||||
actor,
|
||||
);
|
||||
}
|
||||
|
||||
@Put("resend/submit/:id")
|
||||
@ApiParam({ name: "id" })
|
||||
async submitResend(
|
||||
@Param("id") requestId,
|
||||
@Body() body: ClaimSubmitResendDto,
|
||||
@CurrentUser() actor,
|
||||
) {
|
||||
return await this.expertClaimService.submitResend(
|
||||
requestId,
|
||||
body,
|
||||
actor.sub,
|
||||
);
|
||||
}
|
||||
|
||||
@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.streamService(id, query, res, headers);
|
||||
}
|
||||
|
||||
@ApiQuery({
|
||||
name: "query",
|
||||
enum: ["car-capture", "accident"],
|
||||
required: true,
|
||||
})
|
||||
@Get("link/:id/video")
|
||||
@ApiParam({ name: "id" })
|
||||
async getClaimVideoLink(
|
||||
@Param("id") id: string,
|
||||
@Query("query") query: "car-capture" | "accident",
|
||||
) {
|
||||
return this.expertClaimService.getVideoLink(id, query);
|
||||
}
|
||||
|
||||
@Get("stream/:id/voice")
|
||||
@ApiParam({ name: "id" })
|
||||
async getClaimVoiceLink(@Param("id") id: string) {
|
||||
return await this.expertClaimService.getVoiceLink(id);
|
||||
}
|
||||
|
||||
@Patch("validate-factors/:claimId")
|
||||
@ApiParam({ name: "claimId" })
|
||||
@ApiBody({ type: FactorValidationDto })
|
||||
@Roles(RoleEnum.DAMAGE_EXPERT)
|
||||
async validateFactors(
|
||||
@Param("claimId") claimId: string,
|
||||
@Body() validationData: FactorValidationDto,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
return this.expertClaimService.validateClaimFactors(
|
||||
claimId,
|
||||
validationData.decisions,
|
||||
user.sub,
|
||||
);
|
||||
}
|
||||
|
||||
@ApiParam({ name: "id" })
|
||||
@Patch(":id/visit")
|
||||
async inPersonVisit(@Param("id") requestId: string, @CurrentUser() actor) {
|
||||
return await this.expertClaimService.inPersonVisit(requestId, actor);
|
||||
}
|
||||
|
||||
@Get("branches/:insuranceId")
|
||||
@ApiParam({ name: "insuranceId" })
|
||||
async getInsuranceBranches(@Param("insuranceId") insuranceId: string) {
|
||||
return await this.expertClaimService.retrieveInsuranceBranches(insuranceId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user