"use strict";
// SPDX-License-Identifier: Apache-2.0
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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-unused-vars */
const LogErrorDecorator_1 = require("../../../core/decorator/LogErrorDecorator");
const Injectable_1 = __importDefault(require("../../../core/injectable/Injectable"));
const CommandBus_1 = require("../../../core/command/CommandBus");
const index_1 = require("../request/index");
const QueryBus_1 = require("../../../core/query/QueryBus");
const ValidatedArgs_1 = __importDefault(require("../../../core/validation/ValidatedArgs"));
const UpdateExternalKycListsCommand_1 = require("../../../app/usecase/command/security/externalKycLists/updateExternalKycLists/UpdateExternalKycListsCommand");
const AddExternalKycListCommand_1 = require("../../../app/usecase/command/security/externalKycLists/addExternalKycList/AddExternalKycListCommand");
const RemoveExternalKycListCommand_1 = require("../../../app/usecase/command/security/externalKycLists/removeExternalKycList/RemoveExternalKycListCommand");
const IsExternallyGrantedQuery_1 = require("../../../app/usecase/query/security/externalKycLists/isExternallyGranted/IsExternallyGrantedQuery");
const IsExternalKycListQuery_1 = require("../../../app/usecase/query/security/externalKycLists/isExternalKycList/IsExternalKycListQuery");
const GetExternalKycListsCountQuery_1 = require("../../../app/usecase/query/security/externalKycLists/getExternalKycListsCount/GetExternalKycListsCountQuery");
const GetExternalKycListsMembersQuery_1 = require("../../../app/usecase/query/security/externalKycLists/getExternalKycListsMembers/GetExternalKycListsMembersQuery");
const GrantKycMockCommand_1 = require("../../../app/usecase/command/security/externalKycLists/mock/grantKycMock/GrantKycMockCommand");
const RevokeKycMockCommand_1 = require("../../../app/usecase/command/security/externalKycLists/mock/revokeKycMock/RevokeKycMockCommand");
const GetKycStatusMockQuery_1 = require("../../../app/usecase/query/security/externalKycLists/mock/getKycStatusMock/GetKycStatusMockQuery");
const CreateExternalKycMockCommand_1 = require("../../../app/usecase/command/security/externalKycLists/mock/createExternalKycMock/CreateExternalKycMockCommand");
class ExternalKycListsInPort {
    queryBus;
    commandBus;
    constructor(queryBus = Injectable_1.default.resolve(QueryBus_1.QueryBus), commandBus = Injectable_1.default.resolve(CommandBus_1.CommandBus)) {
        this.queryBus = queryBus;
        this.commandBus = commandBus;
    }
    async updateExternalKycLists(request) {
        const { securityId, externalKycListsAddresses, actives } = request;
        ValidatedArgs_1.default.handleValidation("UpdateExternalKycListsRequest", request);
        return await this.commandBus.execute(new UpdateExternalKycListsCommand_1.UpdateExternalKycListsCommand(securityId, externalKycListsAddresses, actives));
    }
    async addExternalKycList(request) {
        const { securityId, externalKycListAddress } = request;
        ValidatedArgs_1.default.handleValidation("AddExternalKycListRequest", request);
        return await this.commandBus.execute(new AddExternalKycListCommand_1.AddExternalKycListCommand(securityId, externalKycListAddress));
    }
    async removeExternalKycList(request) {
        const { securityId, externalKycListAddress } = request;
        ValidatedArgs_1.default.handleValidation("RemoveExternalKycListRequest", request);
        return await this.commandBus.execute(new RemoveExternalKycListCommand_1.RemoveExternalKycListCommand(securityId, externalKycListAddress));
    }
    async isExternallyGranted(request) {
        const { securityId, kycStatus, targetId } = request;
        ValidatedArgs_1.default.handleValidation("IsExternallyGrantedRequest", request);
        return (await this.queryBus.execute(new IsExternallyGrantedQuery_1.IsExternallyGrantedQuery(securityId, kycStatus, targetId))).payload;
    }
    async isExternalKycList(request) {
        const { securityId, externalKycListAddress } = request;
        ValidatedArgs_1.default.handleValidation("IsExternalKycListRequest", request);
        return (await this.queryBus.execute(new IsExternalKycListQuery_1.IsExternalKycListQuery(securityId, externalKycListAddress))).payload;
    }
    async getExternalKycListsCount(request) {
        const { securityId } = request;
        ValidatedArgs_1.default.handleValidation("GetExternalKycListsCountRequest", request);
        return (await this.queryBus.execute(new GetExternalKycListsCountQuery_1.GetExternalKycListsCountQuery(securityId))).payload;
    }
    async getExternalKycListsMembers(request) {
        const { securityId, start, end } = request;
        ValidatedArgs_1.default.handleValidation("GetExternalKycListsMembersRequest", request);
        return (await this.queryBus.execute(new GetExternalKycListsMembersQuery_1.GetExternalKycListsMembersQuery(securityId, start, end))).payload;
    }
    async grantKycMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("GrantKycMockRequest", request);
        return await this.commandBus.execute(new GrantKycMockCommand_1.GrantKycMockCommand(contractId, targetId));
    }
    async revokeKycMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("RevokeKycMockRequest", request);
        return await this.commandBus.execute(new RevokeKycMockCommand_1.RevokeKycMockCommand(contractId, targetId));
    }
    async getKycStatusMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("GetKycStatusMockRequest", request);
        return (await this.queryBus.execute(new GetKycStatusMockQuery_1.GetKycStatusMockQuery(contractId, targetId))).payload;
    }
    async createExternalKycMock() {
        return (await this.commandBus.execute(new CreateExternalKycMockCommand_1.CreateExternalKycListMockCommand())).payload;
    }
}
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.UpdateExternalKycListsRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "updateExternalKycLists", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.AddExternalKycListRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "addExternalKycList", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.RemoveExternalKycListRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "removeExternalKycList", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.IsExternallyGrantedRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "isExternallyGranted", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.IsExternalKycListRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "isExternalKycList", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GetExternalKycListsCountRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "getExternalKycListsCount", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GetExternalKycListsMembersRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "getExternalKycListsMembers", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GrantKycMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "grantKycMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.RevokeKycMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "revokeKycMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GetKycStatusMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "getKycStatusMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "createExternalKycMock", null);
const ExternalKycListsManagement = new ExternalKycListsInPort();
exports.default = ExternalKycListsManagement;
