UNPKG

graphdb

Version:

Javascript client library supporting GraphDB and RDF4J REST API.

86 lines (80 loc) 3.16 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** * Wrapper for HTTP responses. * * Includes the HTTP client that performed the request and received the response * and the elapsed time in milliseconds. * * @class * @author Mihail Radkov */ var HttpResponse = /*#__PURE__*/function () { /** * Constructs new wrapper with the supplied response and client. * @param {AxiosResponse} response the HTTP response * @param {HttpClient} httpClient client that performed the HTTP request */ function HttpResponse(response, httpClient) { _classCallCheck(this, HttpResponse); this.response = response; this.httpClient = httpClient; } /** * Returns the HTTP response's data. * * @return {string|any} the response data */ return _createClass(HttpResponse, [{ key: "getData", value: function getData() { return this.response.data; } /** * Returns the HTTP response's headers. * * @return {{object}} the headers map */ }, { key: "getHeaders", value: function getHeaders() { return this.response.headers; } /** * Sets the elapsed time of the request and response. * * @param {number} elapsedTime the elapsed time in milliseconds */ }, { key: "setElapsedTime", value: function setElapsedTime(elapsedTime) { this.elapsedTime = elapsedTime; } /** * Returns the elapsed time of the HTTP request execution. * * @return {number} the elapsed time in milliseconds */ }, { key: "getElapsedTime", value: function getElapsedTime() { return this.elapsedTime; } /** * Returns the base URL to which this request was performed. * * @return {string} the base URL */ }, { key: "getBaseURL", value: function getBaseURL() { return this.httpClient.getBaseURL(); } }]); }(); module.exports = HttpResponse;