UNPKG

@sitecore/sc-contenthub-webclient-sdk

Version:

Sitecore Content Hub WebClient SDK.

32 lines 1.41 kB
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { CaseInsensitiveStringMap } from "../base-types"; /** * A response message that will be returned by {@link IInternalClient} instances. */ export 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 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 })); } } //# sourceMappingURL=response-message.js.map