UNPKG

@sitecore/sc-contenthub-webclient-sdk

Version:

Sitecore Content Hub WebClient SDK.

36 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ResponseMessage = void 0; /* eslint-disable @typescript-eslint/no-unsafe-member-access */ const base_types_1 = require("../base-types"); /** * A response message that will be returned by {@link IInternalClient} instances. */ class ResponseMessage { /** * Indicates if the response is successful. */ get isSuccessStatusCode() { return !!this.statusCode && this.statusCode >= 200 && this.statusCode < 300; } constructor(init) { Object.assign(this, init); } /** * Build a response message. * @param statusCode - HTTP status code * @param responseHeaders - Headers containing additional information sent by the server * @param optional - Object with more response properties (statusText, content, ...) */ static build(statusCode, responseHeaders, optional) { var _a; responseHeaders = new base_types_1.CaseInsensitiveStringMap(responseHeaders || {}); let reasonPhrase = undefined; if ((statusCode < 200 || statusCode >= 300) && typeof ((_a = optional === null || optional === void 0 ? void 0 : optional.content) === null || _a === void 0 ? void 0 : _a["Message"]) === "string") { reasonPhrase = optional.content["Message"]; } return new ResponseMessage(Object.assign(Object.assign({}, optional), { statusCode, responseHeaders, reasonPhrase })); } } exports.ResponseMessage = ResponseMessage; //# sourceMappingURL=response-message.js.map