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