"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SearchProvider = void 0;
const util_1 = require("../../util");
const data_accessor_1 = require("../data-accessor/data-accessor");
const abstract_content_provider_1 = require("../abstract-content-provider");
const SearchHelpers = __importStar(require("./search/helpers"));
const SymbolConversionHelpers = __importStar(require("./symbol-conversion/helpers"));
/** @internal */
class SearchProvider extends abstract_content_provider_1.AbstractContentProvider {
    constructor(session, tableBuilder) {
        super(session);
        this.tableBuilder = tableBuilder;
        this.apiGroup = 'discovery';
        this.endpointName = 'search';
        this.dataAccessor = new data_accessor_1.DataAccessorImpl(session);
    }
    async search(params) {
        (0, util_1.validateRequired)(params, [], 'Search.Params');
        const dataAccessorContentBody = SearchHelpers.convertParamsToBody(params);
        const request = {
            url: this.getEndpointPath('search'),
            method: SearchHelpers.method,
            dataAccessorContentBody,
        };
        const response = await this.dataAccessor.getData(request);
        const buildTable = () => this.tableBuilder.build(response.data);
        return this.toContentResponse(response, buildTable);
    }
    async getSymbology(params) {
        SymbolConversionHelpers.validateParams(params);
        const normalizedParams = SymbolConversionHelpers.getNormalizedParams(params);
        const dataAccessorContentBody = SymbolConversionHelpers.convertParamsToBody(normalizedParams);
        const request = {
            url: this.getEndpointPath('lookup'),
            method: SymbolConversionHelpers.method,
            dataAccessorContentBody,
        };
        const response = await this.dataAccessor.getData(request);
        const buildTable = () => this.tableBuilder.build({ data: response.data, params: normalizedParams });
        return this.toContentResponse(response, buildTable);
    }
}
exports.SearchProvider = SearchProvider;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VhcmNoLXByb3ZpZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2NvbnRlbnQvc2VhcmNoL3NlYXJjaC1wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUNBLHFDQUE4QztBQUU5QyxrRUFBa0U7QUFHbEUsNEVBQXVFO0FBRXZFLGdFQUFrRDtBQUVsRCxxRkFBdUU7QUFFdkUsZ0JBQWdCO0FBQ2hCLE1BQWEsY0FBMEMsU0FBUSxtREFBdUI7SUFNbEYsWUFBWSxPQUFnQixFQUFVLFlBQXlDO1FBQzNFLEtBQUssQ0FBQyxPQUFPLENBQUMsQ0FBQztRQURtQixpQkFBWSxHQUFaLFlBQVksQ0FBNkI7UUFMeEUsYUFBUSxHQUF1QixXQUFXLENBQUM7UUFDM0MsaUJBQVksR0FBRyxRQUFRLENBQUM7UUFNM0IsSUFBSSxDQUFDLFlBQVksR0FBRyxJQUFJLGdDQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3RELENBQUM7SUFFTSxLQUFLLENBQUMsTUFBTSxDQUFDLE1BQXFCO1FBQ3JDLElBQUEsdUJBQWdCLEVBQWdCLE1BQU0sRUFBRSxFQUFFLEVBQUUsZUFBZSxDQUFDLENBQUM7UUFDN0QsTUFBTSx1QkFBdUIsR0FBRyxhQUFhLENBQUMsbUJBQW1CLENBQU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