"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 ValidatedArgs_1 = __importDefault(require("../../../../core/validation/ValidatedArgs"));
const QueryBus_1 = require("../../../../core/query/QueryBus");
const Injectable_1 = __importDefault(require("../../../../core/injectable/Injectable"));
const CommandBus_1 = require("../../../../core/command/CommandBus");
const ActionContentHashExistsQuery_1 = require("../../../../app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQuery");
const GetCorporateActionQuery_1 = require("../../../../app/usecase/query/security/getCorporateAction/GetCorporateActionQuery");
const GetCorporateActionsQuery_1 = require("../../../../app/usecase/query/security/getCorporateActions/GetCorporateActionsQuery");
const GetCorporateActionsByTypeQuery_1 = require("../../../../app/usecase/query/security/getCorporateActionsByType/GetCorporateActionsByTypeQuery");
const request_1 = require("../../request");
class CorporateActionsInPort {
    commandBus;
    queryBus;
    constructor(commandBus = Injectable_1.default.resolve(CommandBus_1.CommandBus), queryBus = Injectable_1.default.resolve(QueryBus_1.QueryBus)) {
        this.commandBus = commandBus;
        this.queryBus = queryBus;
    }
    async actionContentHashExists(request) {
        const { securityId, contentHash } = request;
        ValidatedArgs_1.default.handleValidation("ActionContentHashExistsRequest", request);
        return (await this.queryBus.execute(new ActionContentHashExistsQuery_1.ActionContentHashExistsQuery(securityId, contentHash))).payload;
    }
    async getCorporateAction(request) {
        ValidatedArgs_1.default.handleValidation("GetCorporateActionRequest", request);
        const res = await this.queryBus.execute(new GetCorporateActionQuery_1.GetCorporateActionQuery(request.securityId, request.corporateActionId));
        return res.payload;
    }
    async getCorporateActions(request) {
        ValidatedArgs_1.default.handleValidation("GetCorporateActionsRequest", request);
        const res = await this.queryBus.execute(new GetCorporateActionsQuery_1.GetCorporateActionsQuery(request.securityId, request.start, request.end));
        return res.payload;
    }
    async getCorporateActionsByType(request) {
        ValidatedArgs_1.default.handleValidation("GetCorporateActionsByTypeRequest", request);
        const res = await this.queryBus.execute(new GetCorporateActionsByTypeQuery_1.GetCorporateActionsByTypeQuery(request.securityId, request.actionType, request.start, request.end));
        return res.payload;
    }
}
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.ActionContentHashExistsRequest]),
    __metadata("design:returntype", Promise)
], CorporateActionsInPort.prototype, "actionContentHashExists", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.GetCorporateActionRequest]),
    __metadata("design:returntype", Promise)
], CorporateActionsInPort.prototype, "getCorporateAction", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.GetCorporateActionsRequest]),
    __metadata("design:returntype", Promise)
], CorporateActionsInPort.prototype, "getCorporateActions", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [request_1.GetCorporateActionsByTypeRequest]),
    __metadata("design:returntype", Promise)
], CorporateActionsInPort.prototype, "getCorporateActionsByType", null);
const CorporateActions = new CorporateActionsInPort();
exports.default = CorporateActions;
