"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdminKycController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const kyc_verification_service_1 = require("../../appapi/kyc/kyc-verification.service");
const didit_dto_1 = require("../../appapi/kyc/didit.dto");
const JwtAuthGuard_1 = require("../../guards/JwtAuthGuard");
const roles_guard_1 = require("../../appapi/user/auth/roles.guard");
const roles_decorator_1 = require("../../appapi/user/auth/roles.decorator");
const user_entity_1 = require("../../appapi/user/user.entity");
let AdminKycController = class AdminKycController {
    constructor(kycVerificationService) {
        this.kycVerificationService = kycVerificationService;
    }
    async listUsers(query) {
        try {
            const data = await this.kycVerificationService.adminListUsers(query);
            return {
                status: true,
                message: "KYC users list.",
                data,
            };
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
    async getHistory(userId) {
        try {
            const data = await this.kycVerificationService.getUserHistory(Number(userId));
            return {
                status: true,
                message: "KYC history.",
                data,
            };
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
    async getDiditDetails(userId) {
        try {
            const data = await this.kycVerificationService.getAttemptDiditDetails(Number(userId));
            return {
                status: true,
                message: "Didit session details.",
                data,
            };
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
    async updateStatus(userId, body, req) {
        try {
            const adminUserId = Number(req?.user?.userId || 0);
            const data = await this.kycVerificationService.adminUpdateUserStatus(Number(userId), body, adminUserId);
            return {
                status: true,
                message: "KYC status updated.",
                data,
            };
        }
        catch (error) {
            throw new common_1.BadRequestException(error.message);
        }
    }
};
exports.AdminKycController = AdminKycController;
__decorate([
    (0, common_1.Get)("users"),
    (0, swagger_1.ApiOperation)({ summary: "List users and their latest KYC verification status" }),
    __param(0, (0, common_1.Query)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [didit_dto_1.AdminKycQueryDto]),
    __metadata("design:returntype", Promise)
], AdminKycController.prototype, "listUsers", null);
__decorate([
    (0, common_1.Get)("users/:userId/history"),
    (0, swagger_1.ApiOperation)({ summary: "List all KYC attempts for a user" }),
    __param(0, (0, common_1.Param)("userId")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], AdminKycController.prototype, "getHistory", null);
__decorate([
    (0, common_1.Get)("users/:userId/didit-details"),
    (0, swagger_1.ApiOperation)({ summary: "Fetch live Didit session details (documents, liveness photo) for a user" }),
    __param(0, (0, common_1.Param)("userId")),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], AdminKycController.prototype, "getDiditDetails", null);
__decorate([
    (0, common_1.Patch)("users/:userId/status"),
    (0, swagger_1.ApiOperation)({ summary: "Manually approve, reject, or review a user's KYC" }),
    __param(0, (0, common_1.Param)("userId")),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number, didit_dto_1.ManualKycStatusUpdateDto, Object]),
    __metadata("design:returntype", Promise)
], AdminKycController.prototype, "updateStatus", null);
exports.AdminKycController = AdminKycController = __decorate([
    (0, swagger_1.ApiTags)("Admin KYC"),
    (0, common_1.UseGuards)(JwtAuthGuard_1.JwtAuthGuard, roles_guard_1.RolesGuard),
    (0, roles_decorator_1.Roles)(user_entity_1.UserRole.ADMIN),
    (0, common_1.Controller)("admin/kyc"),
    __metadata("design:paramtypes", [kyc_verification_service_1.KycVerificationService])
], AdminKycController);
//# sourceMappingURL=admin.kyc.controller.js.map