// 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);
};
/* eslint-disable @typescript-eslint/no-unused-vars */
import { LogError } from "../../../core/decorator/LogErrorDecorator";
import Injectable from "../../../core/injectable/Injectable";
import { CommandBus } from "../../../core/command/CommandBus";
import { AddExternalKycListRequest, RemoveExternalKycListRequest, UpdateExternalKycListsRequest, GetExternalKycListsCountRequest, GetExternalKycListsMembersRequest, IsExternalKycListRequest, IsExternallyGrantedRequest, GrantKycMockRequest, RevokeKycMockRequest, GetKycStatusMockRequest, } from "../request/index";
import { QueryBus } from "../../../core/query/QueryBus";
import ValidatedRequest from "../../../core/validation/ValidatedArgs";
import { UpdateExternalKycListsCommand } from "../../../app/usecase/command/security/externalKycLists/updateExternalKycLists/UpdateExternalKycListsCommand";
import { AddExternalKycListCommand } from "../../../app/usecase/command/security/externalKycLists/addExternalKycList/AddExternalKycListCommand";
import { RemoveExternalKycListCommand } from "../../../app/usecase/command/security/externalKycLists/removeExternalKycList/RemoveExternalKycListCommand";
import { IsExternallyGrantedQuery } from "../../../app/usecase/query/security/externalKycLists/isExternallyGranted/IsExternallyGrantedQuery";
import { IsExternalKycListQuery } from "../../../app/usecase/query/security/externalKycLists/isExternalKycList/IsExternalKycListQuery";
import { GetExternalKycListsCountQuery } from "../../../app/usecase/query/security/externalKycLists/getExternalKycListsCount/GetExternalKycListsCountQuery";
import { GetExternalKycListsMembersQuery } from "../../../app/usecase/query/security/externalKycLists/getExternalKycListsMembers/GetExternalKycListsMembersQuery";
import { GrantKycMockCommand } from "../../../app/usecase/command/security/externalKycLists/mock/grantKycMock/GrantKycMockCommand";
import { RevokeKycMockCommand } from "../../../app/usecase/command/security/externalKycLists/mock/revokeKycMock/RevokeKycMockCommand";
import { GetKycStatusMockQuery } from "../../../app/usecase/query/security/externalKycLists/mock/getKycStatusMock/GetKycStatusMockQuery";
import { CreateExternalKycListMockCommand } from "../../../app/usecase/command/security/externalKycLists/mock/createExternalKycMock/CreateExternalKycMockCommand";
class ExternalKycListsInPort {
    queryBus;
    commandBus;
    constructor(queryBus = Injectable.resolve(QueryBus), commandBus = Injectable.resolve(CommandBus)) {
        this.queryBus = queryBus;
        this.commandBus = commandBus;
    }
    async updateExternalKycLists(request) {
        const { securityId, externalKycListsAddresses, actives } = request;
        ValidatedRequest.handleValidation("UpdateExternalKycListsRequest", request);
        return await this.commandBus.execute(new UpdateExternalKycListsCommand(securityId, externalKycListsAddresses, actives));
    }
    async addExternalKycList(request) {
        const { securityId, externalKycListAddress } = request;
        ValidatedRequest.handleValidation("AddExternalKycListRequest", request);
        return await this.commandBus.execute(new AddExternalKycListCommand(securityId, externalKycListAddress));
    }
    async removeExternalKycList(request) {
        const { securityId, externalKycListAddress } = request;
        ValidatedRequest.handleValidation("RemoveExternalKycListRequest", request);
        return await this.commandBus.execute(new RemoveExternalKycListCommand(securityId, externalKycListAddress));
    }
    async isExternallyGranted(request) {
        const { securityId, kycStatus, targetId } = request;
        ValidatedRequest.handleValidation("IsExternallyGrantedRequest", request);
        return (await this.queryBus.execute(new IsExternallyGrantedQuery(securityId, kycStatus, targetId))).payload;
    }
    async isExternalKycList(request) {
        const { securityId, externalKycListAddress } = request;
        ValidatedRequest.handleValidation("IsExternalKycListRequest", request);
        return (await this.queryBus.execute(new IsExternalKycListQuery(securityId, externalKycListAddress))).payload;
    }
    async getExternalKycListsCount(request) {
        const { securityId } = request;
        ValidatedRequest.handleValidation("GetExternalKycListsCountRequest", request);
        return (await this.queryBus.execute(new GetExternalKycListsCountQuery(securityId))).payload;
    }
    async getExternalKycListsMembers(request) {
        const { securityId, start, end } = request;
        ValidatedRequest.handleValidation("GetExternalKycListsMembersRequest", request);
        return (await this.queryBus.execute(new GetExternalKycListsMembersQuery(securityId, start, end))).payload;
    }
    async grantKycMock(request) {
        const { contractId, targetId } = request;
        ValidatedRequest.handleValidation("GrantKycMockRequest", request);
        return await this.commandBus.execute(new GrantKycMockCommand(contractId, targetId));
    }
    async revokeKycMock(request) {
        const { contractId, targetId } = request;
        ValidatedRequest.handleValidation("RevokeKycMockRequest", request);
        return await this.commandBus.execute(new RevokeKycMockCommand(contractId, targetId));
    }
    async getKycStatusMock(request) {
        const { contractId, targetId } = request;
        ValidatedRequest.handleValidation("GetKycStatusMockRequest", request);
        return (await this.queryBus.execute(new GetKycStatusMockQuery(contractId, targetId))).payload;
    }
    async createExternalKycMock() {
        return (await this.commandBus.execute(new CreateExternalKycListMockCommand())).payload;
    }
}
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [UpdateExternalKycListsRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "updateExternalKycLists", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [AddExternalKycListRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "addExternalKycList", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RemoveExternalKycListRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "removeExternalKycList", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [IsExternallyGrantedRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "isExternallyGranted", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [IsExternalKycListRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "isExternalKycList", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetExternalKycListsCountRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "getExternalKycListsCount", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetExternalKycListsMembersRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "getExternalKycListsMembers", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GrantKycMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "grantKycMock", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RevokeKycMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "revokeKycMock", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetKycStatusMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "getKycStatusMock", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], ExternalKycListsInPort.prototype, "createExternalKycMock", null);
const ExternalKycListsManagement = new ExternalKycListsInPort();
export default ExternalKycListsManagement;
