var paramName = function (param) { return param.replace(/[{}]/g, ''); };
var replaceParameters = function (_a) {
    var path = _a.path, params = _a.params;
    var parameters = path.match(/{([A-Za-z0-9_-]+)}/g) || [];
    if (parameters.length === 0) {
        return path;
    }
    var replacedPath = path;
    parameters.forEach(function (paramPattern) {
        var name = paramName(paramPattern);
        var value = params === null || params === void 0 ? void 0 : params[name];
        if (!value) {
            throw new Error("Parameter ".concat(name, " missing. Expected parameters are: ").concat(parameters
                .map(paramName)
                .join(', ')));
        }
        replacedPath = replacedPath.replace(paramPattern, "".concat(value));
    });
    return replacedPath;
};

export { replaceParameters };
//# sourceMappingURL=replacePathParameters.js.map
