// 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 { AddExternalPauseRequest, RemoveExternalPauseRequest, UpdateExternalPausesRequest, GetExternalPausesCountRequest, GetExternalPausesMembersRequest, IsExternalPauseRequest, IsPausedMockRequest, SetPausedMockRequest, } from "../request/index";
import { UpdateExternalPausesCommand } from "../../../app/usecase/command/security/externalPauses/updateExternalPauses/UpdateExternalPausesCommand";
import { SetPausedMockCommand } from "../../../app/usecase/command/security/externalPauses/mock/setPaused/SetPausedMockCommand";
import { QueryBus } from "../../../core/query/QueryBus";
import { IsPausedMockQuery } from "../../../app/usecase/query/security/externalPauses/mock/isPaused/IsPausedMockQuery";
import { AddExternalPauseCommand } from "../../../app/usecase/command/security/externalPauses/addExternalPause/AddExternalPauseCommand";
import { RemoveExternalPauseCommand } from "../../../app/usecase/command/security/externalPauses/removeExternalPause/RemoveExternalPauseCommand";
import { IsExternalPauseQuery } from "../../../app/usecase/query/security/externalPauses/isExternalPause/IsExternalPauseQuery";
import { GetExternalPausesCountQuery } from "../../../app/usecase/query/security/externalPauses/getExternalPausesCount/GetExternalPausesCountQuery";
import { GetExternalPausesMembersQuery } from "../../../app/usecase/query/security/externalPauses/getExternalPausesMembers/GetExternalPausesMembersQuery";
import { CreateExternalPauseMockCommand } from "../../../app/usecase/command/security/externalPauses/mock/createExternalPauseMock/CreateExternalPauseMockCommand";
import ValidatedRequest from "../../../core/validation/ValidatedArgs";
class ExternalPausesInPort {
    queryBus;
    commandBus;
    constructor(queryBus = Injectable.resolve(QueryBus), commandBus = Injectable.resolve(CommandBus)) {
        this.queryBus = queryBus;
        this.commandBus = commandBus;
    }
    async updateExternalPauses(request) {
        const { securityId, externalPausesAddresses, actives } = request;
        ValidatedRequest.handleValidation("UpdateExternalPausesRequest", request);
        return await this.commandBus.execute(new UpdateExternalPausesCommand(securityId, externalPausesAddresses, actives));
    }
    async addExternalPause(request) {
        const { securityId, externalPauseAddress } = request;
        ValidatedRequest.handleValidation("AddExternalPauseRequest", request);
        return await this.commandBus.execute(new AddExternalPauseCommand(securityId, externalPauseAddress));
    }
    async removeExternalPause(request) {
        const { securityId, externalPauseAddress } = request;
        ValidatedRequest.handleValidation("RemoveExternalPauseRequest", request);
        return await this.commandBus.execute(new RemoveExternalPauseCommand(securityId, externalPauseAddress));
    }
    async isExternalPause(request) {
        const { securityId, externalPauseAddress } = request;
        ValidatedRequest.handleValidation("IsExternalPauseRequest", request);
        return (await this.queryBus.execute(new IsExternalPauseQuery(securityId, externalPauseAddress))).payload;
    }
    async getExternalPausesCount(request) {
        const { securityId } = request;
        ValidatedRequest.handleValidation("GetExternalPausesCountRequest", request);
        return (await this.queryBus.execute(new GetExternalPausesCountQuery(securityId))).payload;
    }
    async getExternalPausesMembers(request) {
        const { securityId, start, end } = request;
        ValidatedRequest.handleValidation("GetExternalPausesMembersRequest", request);
        return (await this.queryBus.execute(new GetExternalPausesMembersQuery(securityId, start, end))).payload;
    }
    async setPausedMock(request) {
        const { contractId, paused } = request;
        ValidatedRequest.handleValidation("SetPausedMockRequest", request);
        return await this.commandBus.execute(new SetPausedMockCommand(contractId, paused));
    }
    async isPausedMock(request) {
        const { contractId } = request;
        ValidatedRequest.handleValidation("IsPausedMockRequest", request);
        return (await this.queryBus.execute(new IsPausedMockQuery(contractId))).payload;
    }
    async createMock() {
        return (await this.commandBus.execute(new CreateExternalPauseMockCommand())).payload;
    }
}
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [UpdateExternalPausesRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "updateExternalPauses", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [AddExternalPauseRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "addExternalPause", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RemoveExternalPauseRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "removeExternalPause", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [IsExternalPauseRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "isExternalPause", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetExternalPausesCountRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "getExternalPausesCount", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetExternalPausesMembersRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "getExternalPausesMembers", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [SetPausedMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "setPausedMock", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [IsPausedMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "isPausedMock", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "createMock", null);
const ExternalPausesManagement = new ExternalPausesInPort();
export default ExternalPausesManagement;
