"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CurvesProvider = void 0;
const common_1 = require("@refinitiv-data/common");
const util_1 = require("../../../util");
const abstract_content_provider_1 = require("../../abstract-content-provider");
const data_accessor_1 = require("../../data-accessor/data-accessor");
/** @internal */
class CurvesProvider extends abstract_content_provider_1.AbstractContentProvider {
    constructor(session) {
        super(session);
        this.apiGroup = 'data';
        this.endpointName = 'quantitative-analytics-curves-and-surfaces';
        this.dataAccessor = new data_accessor_1.DataAccessorImpl(session);
    }
    async getForwardCurve(params) {
        (0, util_1.validateRequired)(params, ['curveDefinition', 'forwardCurveDefinitions'], 'ForwardCurve.Params');
        const { outputs, extendedParams } = params, forwardCurveParams = __rest(params, ["outputs", "extendedParams"]);
        const requestParams = {
            url: this.getEndpointPath('forward-curves'),
            method: common_1.HttpMethod.POST,
            dataAccessorContentBody: Object.assign({ universe: [forwardCurveParams], outputs }, extendedParams),
        };
        const response = await this.dataAccessor.getData(requestParams);
        return this.toContentResponse(response);
    }
    async getForwardCurves(params) {
        (0, util_1.validateRequired)(params, ['universe'], 'ForwardCurves.Params');
        const { outputs, extendedParams, universe: u } = params;
        const universe = u.map(this.getCurveParams);
        const requestParams = {
            url: this.getEndpointPath('forward-curves'),
            method: common_1.HttpMethod.POST,
            dataAccessorContentBody: Object.assign({ universe, outputs }, extendedParams),
        };
        const response = await this.dataAccessor.getData(requestParams);
        return this.toContentResponse(response);
    }
    async getZcCurve(params) {
        (0, util_1.validateRequired)(params, ['curveDefinition'], 'ZcCurve.Params');
        const { outputs, extendedParams } = params, zcCurveParams = __rest(params, ["outputs", "extendedParams"]);
        const requestParams = {
            url: this.getEndpointPath('zc-curves'),
            method: common_1.HttpMethod.POST,
            dataAccessorContentBody: Object.assign({ universe: [zcCurveParams], outputs }, extendedParams),
        };
        const response = await this.dataAccessor.getData(requestParams);
        return this.toContentResponse(response);
    }
    async getZcCurves(params) {
        (0, util_1.validateRequired)(params, ['universe'], 'ZcCurves.Params');
        const { outputs, extendedParams, universe: u } = params;
        const universe = u.map(this.getCurveParams);
        const requestParams = {
            url: this.getEndpointPath('zc-curves'),
            method: common_1.HttpMethod.POST,
            dataAccessorContentBody: Object.assign({ universe, outputs }, extendedParams),
        };
        const response = await this.dataAccessor.getData(requestParams);
        return this.toContentResponse(response);
    }
    async getZcCurveDefinition(universe) {
        const { extendedParams } = universe, parameters = __rest(universe, ["extendedParams"]);
        const params = {
            url: this.getEndpointPath('zc-curve-definitions'),
            method: common_1.HttpMethod.POST,
            dataAccessorContentBody: Object.assign({ universe: [parameters] }, extendedParams),
        };
        const response = await this.dataAccessor.getData(params);
        return this.toContentResponse(response);
    }
    async getZcCurveDefinitions(params) {
        (0, util_1.validateRequired)(params, ['universe'], 'ZcCurveDefinitions.Params');
        const { extendedParams, universe: u } = params;
        const universe = u.map(item => {
            const _a = item.getInstrument(), { extendedParams: e } = _a, zcCurveDefinitionParams = __rest(_a, ["extendedParams"]);
            return zcCurveDefinitionParams;
        });
        const requestParams = {
            url: this.getEndpointPath('zc-curve-definitions'),
            method: common_1.HttpMethod.POST,
            dataAccessorContentBody: Object.assign({ universe }, extendedParams),
        };
        const response = await this.dataAccessor.getData(requestParams);
        return this.toContentResponse(response);
    }
    getCurveParams(item) {
        const _a = item.getInstrument(), { outputs: o, extendedParams: e } = _a, curveParams = __rest(_a, ["outputs", "extendedParams"]);
        return curveParams;
    }
}
exports.CurvesProvider = CurvesProvider;
//# sourceMappingURL=data:application/json;base64, 