"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ODataCountRequestConfig = void 0;
var util_1 = require("@sap-cloud-sdk/util");
var remove_slashes_1 = require("../remove-slashes");
var odata_request_config_1 = require("./odata-request-config");
var logger = util_1.createLogger({
    package: 'core',
    messageContext: 'count-request-config'
});
/**
 * OData count request configuration for an entity type.
 * @typeparam EntityT - Type of the entity to setup a request for
 */
var ODataCountRequestConfig = /** @class */ (function (_super) {
    __extends(ODataCountRequestConfig, _super);
    /**
     * Creates an instance of ODataGetAllRequestConfig.
     * @param entityConstructor - Constructor type of the entity to create a configuration for
     */
    function ODataCountRequestConfig(getAllRequest) {
        var _this = _super.call(this, 'get', getAllRequest._entityConstructor._defaultServicePath) || this;
        _this.getAllRequest = getAllRequest;
        return _this;
    }
    ODataCountRequestConfig.prototype.resourcePath = function () {
        return remove_slashes_1.removeTrailingSlashes(this.getAllRequest._entityConstructor._entityName) + "/$count";
    };
    ODataCountRequestConfig.prototype.queryParameters = function () {
        var parametersAllowedInCount = ['$apply', '$search', '$filter'];
        var defaultParameters = ['$format'];
        var parameters = this.getAllRequest.requestConfig.queryParameters();
        Object.keys(parameters).forEach(function (key) {
            if (!parametersAllowedInCount.includes(key) &&
                !defaultParameters.includes(key)) {
                logger.warn("The query parameter " + key + " must not be used in a count request and has been ignored.");
            }
        });
        return util_1.pick(parametersAllowedInCount, parameters);
    };
    return ODataCountRequestConfig;
}(odata_request_config_1.ODataRequestConfig));
exports.ODataCountRequestConfig = ODataCountRequestConfig;
//# sourceMappingURL=odata-count-request-config.js.map