"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Route = void 0;
var lodash_1 = require("lodash");
var BringgException_1 = require("../Core/BringgException");
var ExceptionReason_1 = require("../Core/ExceptionReason");
var Route = /** @class */ (function () {
    function Route(uri, httpMethod) {
        if (uri.charAt(0) != '/') {
            throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.INTERNAL_ROUTING_ERROR, 'uri must start with a leading slash!');
        }
        this.uri = uri;
        this.httpMethod = httpMethod;
    }
    Route.prototype.applyParams = function (params) {
        return this.uri.replace(/{:([^}]+)}/gi, function (uri, paramKey) {
            if ((0, lodash_1.isUndefined)(params[paramKey])) {
                throw new BringgException_1.BringgException(ExceptionReason_1.ExceptionReason.INTERNAL_ROUTING_ERROR, function () { return "couldn't find matching parameter to macro: {:".concat(paramKey, "}"); });
            }
            return params[paramKey];
        });
    };
    return Route;
}());
exports.Route = Route;
//# sourceMappingURL=Route.js.map