1
0
forked from Yara724/api

fanavaran stage by stage implemented i am so bored to send smart commit sorry MR sina

This commit is contained in:
2026-07-01 15:13:22 +03:30
parent 99c819caeb
commit 67471fb9ce
16 changed files with 2366 additions and 146 deletions

View File

@@ -54,11 +54,11 @@ export class FanavaranController {
};
}
@Get(":client/claim-cases/:claimCaseId")
@Get(":client/claim-cases/:claimCaseId/base-claim/preview")
@ApiOperation({
summary: "Preview Fanavaran submit payload (V2)",
summary: "Preview Fanavaran base claim create payload",
description:
"Builds the third-party-car-financial-claims body from claimCases + blameCases without calling Fanavaran.",
"Builds the GEN.03 third-party-car-financial-claims payload from local claimCases + blameCases without creating a Fanavaran claim.",
})
@ApiParam({
name: "client",
@@ -87,11 +87,11 @@ export class FanavaranController {
);
}
@Post(":client/claim-cases/:claimCaseId")
@Post(":client/claim-cases/:claimCaseId/base-claim/submit")
@ApiOperation({
summary: "Submit claim to Fanavaran (V2)",
summary: "Submit Fanavaran base claim create request",
description:
"Authenticates with the selected client credentials and submits the mapped claimCases + blameCases payload.",
"Authenticates with the selected tenant credentials and submits the GEN.03 base claim create request. Stores returned Id as claimId and ClaimNo when present.",
})
@ApiParam({
name: "client",
@@ -113,6 +113,162 @@ export class FanavaranController {
);
}
@Get(":client/claim-cases/:claimCaseId/damage-case/preview")
@ApiOperation({
summary: "Preview Fanavaran damage-case payload",
description:
"Builds the GEN.12 damaged vehicle/person case payload without calling Fanavaran. Requires selected damaged parts; submit requires a Fanavaran claimId.",
})
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
})
@ApiParam({
name: "claimCaseId",
description: "Claim case MongoDB ObjectId",
})
async previewDamageCase(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
) {
const clientKey = this.parseClientParam(client);
return await this.claimRequestManagementService.previewFanavaranDamageCaseV2(
claimCaseId,
clientKey,
);
}
@Post(":client/claim-cases/:claimCaseId/damage-case/submit")
@ApiOperation({
summary: "Submit Fanavaran damage-case request",
description:
"Submits the GEN.12 dmg-cases request for the already-created Fanavaran claim and stores returned Id as local dmgCaseId.",
})
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
})
@ApiParam({
name: "claimCaseId",
description: "Claim case MongoDB ObjectId",
})
async submitDamageCase(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
) {
const clientKey = this.parseClientParam(client);
return await this.claimRequestManagementService.submitFanavaranDamageCaseV2(
claimCaseId,
clientKey,
);
}
@Get(":client/claim-cases/:claimCaseId/attachments/preview")
@ApiOperation({
summary: "Preview Fanavaran attachment upload plan",
description:
"Lists local required-document and captured damage images that would be sent to GEN.07. Shows which images are already recorded as uploaded to Fanavaran.",
})
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
})
@ApiParam({
name: "claimCaseId",
description: "Claim case MongoDB ObjectId",
})
async previewAttachments(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
) {
const clientKey = this.parseClientParam(client);
return await this.claimRequestManagementService.previewFanavaranAttachmentsV2(
claimCaseId,
clientKey,
);
}
@Post(":client/claim-cases/:claimCaseId/attachments/submit")
@ApiOperation({
summary: "Submit missing Fanavaran attachments",
description:
"Uploads every local image that does not already have a recorded successful GEN.07 Fanavaran file upload. Uses one multipart request per image.",
})
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
})
@ApiParam({
name: "claimCaseId",
description: "Claim case MongoDB ObjectId",
})
async submitAttachments(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
) {
const clientKey = this.parseClientParam(client);
return await this.claimRequestManagementService.submitFanavaranAttachmentsV2(
claimCaseId,
clientKey,
);
}
@Get(":client/claim-cases/:claimCaseId/expertise/preview")
@ApiOperation({
summary: "Preview Fanavaran expertise payload",
description:
"Builds the GEN.08 expertise payload from the active damage expert reply, price-drop data, and Fanavaran lookup mappings without calling Fanavaran.",
})
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
})
@ApiParam({
name: "claimCaseId",
description: "Claim case MongoDB ObjectId",
})
async previewExpertise(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
) {
const clientKey = this.parseClientParam(client);
return await this.claimRequestManagementService.previewFanavaranExpertiseV2(
claimCaseId,
clientKey,
);
}
@Post(":client/claim-cases/:claimCaseId/expertise/submit")
@ApiOperation({
summary: "Submit Fanavaran expertise request",
description:
"Submits the GEN.08 expertise payload for a claim with existing Fanavaran claimId and dmgCaseId. Stores returned Id as local expertiseId.",
})
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
})
@ApiParam({
name: "claimCaseId",
description: "Claim case MongoDB ObjectId",
})
async submitExpertise(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
) {
const clientKey = this.parseClientParam(client);
return await this.claimRequestManagementService.submitFanavaranExpertiseV2(
claimCaseId,
clientKey,
);
}
private parseClientParam(client: string) {
if (!isFanavaranClientKey(client)) {
throw new BadRequestException(