@pallasoft/ps-utilities 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ export interface CreateApiClientOptions {
2
2
  apiKey?: string;
3
3
  apiKeyHeader?: string;
4
4
  baseURL?: string;
5
+ headers?: Record<string, string>;
5
6
  }
6
7
  export interface PsHttpRequestConfig {
7
8
  headers?: Record<string, string>;
@@ -49,7 +49,7 @@ var HttpService = /** @class */ (function () {
49
49
  HttpService.createApiClient = function (options) {
50
50
  var _this = this;
51
51
  if (options === void 0) { options = {}; }
52
- var apiKey = options.apiKey, _a = options.apiKeyHeader, apiKeyHeader = _a === void 0 ? 'X-API-Key' : _a, baseURL = options.baseURL;
52
+ var apiKey = options.apiKey, _a = options.apiKeyHeader, apiKeyHeader = _a === void 0 ? 'X-API-Key' : _a, baseURL = options.baseURL, defaultHeaders = options.headers;
53
53
  var request = function (method, url, data, config) { return __awaiter(_this, void 0, void 0, function () {
54
54
  var fullUrl, sendsBinaryBody, headers, body, response, responseData, error;
55
55
  return __generator(this, function (_a) {
@@ -60,6 +60,8 @@ var HttpService = /** @class */ (function () {
60
60
  headers = sendsBinaryBody
61
61
  ? {}
62
62
  : { 'Content-Type': 'application/json' };
63
+ if (defaultHeaders)
64
+ Object.assign(headers, defaultHeaders);
63
65
  if (apiKey)
64
66
  headers[apiKeyHeader] = apiKey;
65
67
  if (config === null || config === void 0 ? void 0 : config.headers)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-utilities",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",