"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HistoricalPricingProvider = void 0;
const url_join_1 = __importDefault(require("url-join"));
const util_1 = require("../../util");
const abstract_content_provider_1 = require("../abstract-content-provider");
const data_accessor_1 = require("../data-accessor/data-accessor");
const historical_pricing_interface_1 = require("./historical-pricing.interface");
/** @internal */
class HistoricalPricingProvider extends abstract_content_provider_1.AbstractContentProvider {
    constructor(session, tableBuilder) {
        super(session);
        this.tableBuilder = tableBuilder;
        this.apiGroup = 'data';
        this.endpointName = 'historical-pricing';
        this.dataAccessor = new data_accessor_1.DataAccessorImpl(session);
    }
    async getEvents(params) {
        (0, util_1.validateRequired)(params, ['universe'], 'HistoricalPricing.Events');
        const { universe, extendedParams } = params, otherParams = __rest(params, ["universe", "extendedParams"]);
        const url = (0, url_join_1.default)(this.getEndpointPath('events'), universe);
        const requestParams = {
            url,
            dataAccessorContentQuery: Object.assign(Object.assign({}, otherParams), extendedParams),
        };
        const response = await this.dataAccessor.getData(requestParams);
        const buildTable = () => this.tableBuilder.build(response.data);
        return this.toContentResponse(response, buildTable);
    }
    async getSummaries(params) {
        (0, util_1.validateRequired)(params, ['universe'], 'HistoricalPricing.Summaries');
        const { universe, extendedParams } = params, otherParams = __rest(params, ["universe", "extendedParams"]);
        const url = (0, url_join_1.default)(this.getSummaryEndpoint(params.interval), universe);
        const requestParams = {
            url,
            dataAccessorContentQuery: Object.assign(Object.assign({}, otherParams), extendedParams),
        };
        const response = await this.dataAccessor.getData(requestParams);
        const buildTable = () => this.tableBuilder.build(response.data);
        return this.toContentResponse(response, buildTable);
    }
    getSummaryEndpoint(interval) {
        let endpoint = (0, url_join_1.default)(this.getEndpointPath('interday-summaries'));
        if (interval && Object.values(historical_pricing_interface_1.IntradayInterval).includes(interval)) {
            endpoint = (0, url_join_1.default)(this.getEndpointPath('intraday-summaries'));
        }
        return endpoint;
    }
}
exports.HistoricalPricingProvider = HistoricalPricingProvider;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlzdG9yaWNhbC1wcmljaW5nLXByb3ZpZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2NvbnRlbnQvaGlzdG9yaWNhbC1wcmljaW5nL2hpc3RvcmljYWwtcHJpY2luZy1wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLHdEQUErQjtBQUcvQixxQ0FBOEM7QUFDOUMsNEVBQXVFO0FBR3ZFLGtFQUFrRTtBQUdsRSxpRkFBaUc7QUFHakcsZ0JBQWdCO0FBQ2hCLE1BQWEseUJBQTBCLFNBQVEsbURBQXVCO0lBS2xFLFlBQVksT0FBZ0IsRUFBVSxZQUF1QztRQUN6RSxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUM7UUFEbUIsaUJBQVksR0FBWixZQUFZLENBQTJCO1FBSnRFLGFBQVEsR0FBdUIsTUFBTSxDQUFDO1FBQ3RDLGlCQUFZLEdBQUcsb0JBQW9CLENBQUM7UUFLdkMsSUFBSSxDQUFDLFlBQVksR0FBRyxJQUFJLGdDQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3RELENBQUM7SUFFTSxLQUFLLENBQUMsU0FBUyxDQUFDLE1BQXFCO1FBQ3hDLElBQUEsdUJBQWdCLEVBQWdCLE1B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