UNPKG

wiremock-mapper

Version:
153 lines 5.41 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RequestBuilderImpl = void 0; var match_builder_1 = require("../../lib/builders/match_builder"); var url_match_builder_1 = require("../../lib/builders/url_match_builder"); var RequestBuilderImpl = /** @class */ (function () { function RequestBuilderImpl() { var _this = this; this.request = {}; this.urlMatchBuilder = new url_match_builder_1.UrlMatchBuilder(this); this.toJSON = function () { return (__assign(__assign({}, _this.request), _this.urlMatchBuilder.toJSON())); }; } RequestBuilderImpl.prototype.clone = function () { var clone = new RequestBuilderImpl(); clone.request = __assign({}, this.request); clone.urlMatchBuilder = this.urlMatchBuilder; return clone; }; Object.defineProperty(RequestBuilderImpl.prototype, "isADelete", { get: function () { this.request.method = 'DELETE'; return this; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "isAGet", { get: function () { this.request.method = 'GET'; return this; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "isAHead", { get: function () { this.request.method = 'HEAD'; return this; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "isAnOptions", { get: function () { this.request.method = 'OPTIONS'; return this; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "isAnyVerb", { get: function () { this.request.method = 'ANY'; return this; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "isAPost", { get: function () { this.request.method = 'POST'; return this; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "isAPut", { get: function () { this.request.method = 'PUT'; return this; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "isATrace", { get: function () { this.request.method = 'TRACE'; return this; }, enumerable: false, configurable: true }); RequestBuilderImpl.prototype.withBasicAuth = function (username, password) { this.request.basicAuthCredentials = { username: username, password: password }; return this; }; Object.defineProperty(RequestBuilderImpl.prototype, "withBody", { get: function () { if (!this.request.bodyPatterns) { this.request.bodyPatterns = []; } var matchBuilder = new match_builder_1.MatchBuilder(this); this.request.bodyPatterns.push(matchBuilder); return matchBuilder; }, enumerable: false, configurable: true }); RequestBuilderImpl.prototype.withCookie = function (key) { if (!this.request.cookies) { this.request.cookies = {}; } var matchBuilder = new match_builder_1.MatchBuilder(this); this.request.cookies[key] = matchBuilder; return matchBuilder; }; RequestBuilderImpl.prototype.withHeader = function (key) { if (!this.request.headers) { this.request.headers = {}; } var matchBuilder = new match_builder_1.MatchBuilder(this); this.request.headers[key] = matchBuilder; return matchBuilder; }; RequestBuilderImpl.prototype.withQueryParam = function (key) { if (!this.request.queryParameters) { this.request.queryParameters = {}; } var matchBuilder = new match_builder_1.MatchBuilder(this); this.request.queryParameters[key] = matchBuilder; return matchBuilder; }; Object.defineProperty(RequestBuilderImpl.prototype, "withUrl", { get: function () { this.urlMatchBuilder = new url_match_builder_1.UrlMatchBuilder(this); return this.urlMatchBuilder; }, enumerable: false, configurable: true }); Object.defineProperty(RequestBuilderImpl.prototype, "withUrlPath", { get: function () { this.urlMatchBuilder = new url_match_builder_1.UrlMatchBuilder(this, true); return this.urlMatchBuilder; }, enumerable: false, configurable: true }); return RequestBuilderImpl; }()); exports.RequestBuilderImpl = RequestBuilderImpl; //# sourceMappingURL=request_builder.js.map