"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 UpdateExternalPausesCommand_1 = require("../../../app/usecase/command/security/externalPauses/updateExternalPauses/UpdateExternalPausesCommand");
const SetPausedMockCommand_1 = require("../../../app/usecase/command/security/externalPauses/mock/setPaused/SetPausedMockCommand");
const QueryBus_1 = require("../../../core/query/QueryBus");
const IsPausedMockQuery_1 = require("../../../app/usecase/query/security/externalPauses/mock/isPaused/IsPausedMockQuery");
const AddExternalPauseCommand_1 = require("../../../app/usecase/command/security/externalPauses/addExternalPause/AddExternalPauseCommand");
const RemoveExternalPauseCommand_1 = require("../../../app/usecase/command/security/externalPauses/removeExternalPause/RemoveExternalPauseCommand");
const IsExternalPauseQuery_1 = require("../../../app/usecase/query/security/externalPauses/isExternalPause/IsExternalPauseQuery");
const GetExternalPausesCountQuery_1 = require("../../../app/usecase/query/security/externalPauses/getExternalPausesCount/GetExternalPausesCountQuery");
const GetExternalPausesMembersQuery_1 = require("../../../app/usecase/query/security/externalPauses/getExternalPausesMembers/GetExternalPausesMembersQuery");
const CreateExternalPauseMockCommand_1 = require("../../../app/usecase/command/security/externalPauses/mock/createExternalPauseMock/CreateExternalPauseMockCommand");
const ValidatedArgs_1 = __importDefault(require("../../../core/validation/ValidatedArgs"));
class ExternalPausesInPort {
    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 updateExternalPauses(request) {
        const { securityId, externalPausesAddresses, actives } = request;
        ValidatedArgs_1.default.handleValidation("UpdateExternalPausesRequest", request);
        return await this.commandBus.execute(new UpdateExternalPausesCommand_1.UpdateExternalPausesCommand(securityId, externalPausesAddresses, actives));
    }
    async addExternalPause(request) {
        const { securityId, externalPauseAddress } = request;
        ValidatedArgs_1.default.handleValidation("AddExternalPauseRequest", request);
        return await this.commandBus.execute(new AddExternalPauseCommand_1.AddExternalPauseCommand(securityId, externalPauseAddress));
    }
    async removeExternalPause(request) {
        const { securityId, externalPauseAddress } = request;
        ValidatedArgs_1.default.handleValidation("RemoveExternalPauseRequest", request);
        return await this.commandBus.execute(new RemoveExternalPauseCommand_1.RemoveExternalPauseCommand(securityId, externalPauseAddress));
    }
    async isExternalPause(request) {
        const { securityId, externalPauseAddress } = request;
        ValidatedArgs_1.default.handleValidation("IsExternalPauseRequest", request);
        return (await this.queryBus.execute(new IsExternalPauseQuery_1.IsExternalPauseQuery(securityId, externalPauseAddress))).payload;
    }
    async getExternalPausesCount(request) {
        const { securityId } = request;
        ValidatedArgs_1.default.handleValidation("GetExternalPausesCountRequest", request);
        return (await this.queryBus.execute(new GetExternalPausesCountQuery_1.GetExternalPausesCountQuery(securityId))).payload;
    }
    async getExternalPausesMembers(request) {
        const { securityId, start, end } = request;
        ValidatedArgs_1.default.handleValidation("GetExternalPausesMembersRequest", request);
        return (await this.queryBus.execute(new GetExternalPausesMembersQuery_1.GetExternalPausesMembersQuery(securityId, start, end))).payload;
    }
    async setPausedMock(request) {
        const { contractId, paused } = request;
        ValidatedArgs_1.default.handleValidation("SetPausedMockRequest", request);
        return await this.commandBus.execute(new SetPausedMockCommand_1.SetPausedMockCommand(contractId, paused));
    }
    async isPausedMock(request) {
        const { contractId } = request;
        ValidatedArgs_1.default.handleValidation("IsPausedMockRequest", request);
        return (await this.queryBus.execute(new IsPausedMockQuery_1.IsPausedMockQuery(contractId))).payload;
    }
    async createMock() {
        return (await this.commandBus.execute(new CreateExternalPauseMockCommand_1.CreateExternalPauseMockCommand())).payload;
    }
}
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.UpdateExternalPausesRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "updateExternalPauses", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.AddExternalPauseRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "addExternalPause", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.RemoveExternalPauseRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "removeExternalPause", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.IsExternalPauseRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "isExternalPause", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GetExternalPausesCountRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "getExternalPausesCount", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GetExternalPausesMembersRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "getExternalPausesMembers", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.SetPausedMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "setPausedMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.IsPausedMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "isPausedMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], ExternalPausesInPort.prototype, "createMock", null);
const ExternalPausesManagement = new ExternalPausesInPort();
exports.default = ExternalPausesManagement;
