UNPKG

knowmax-quest-utils

Version:

Utilities for creating a Knowmax Quest client.

40 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.headers = void 0; const knowmax_quest_types_1 = require("knowmax-quest-types"); const headers = (initial) => { return new Headers(initial); }; exports.headers = headers; class Headers { constructor(initial) { this.headers = { ...(initial ?? {}) }; } withBearer(token) { this.headers["Authorization"] = "Bearer " + token; return this; } withLanguage(language) { if (language) { this.headers["Accept-Language"] = language; } return this; } withContentTypeJson() { return this.withContentType(knowmax_quest_types_1.CONTENTTYPE_JSON); } withContentType(contentType) { this.headers["Content-Type"] = contentType; return this; } withHeader(key, value) { if (value) { this.headers[key] = value; } return this; } export() { return { ...this.headers }; } } //# sourceMappingURL=headers.js.map