@crystaldesign/basket-handler 25.13.2-rc.8 → 25.13.2

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.
@@ -37,6 +37,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
37
37
  var BASKET_SAVE_ERROR = /*#__PURE__*/function (BASKET_SAVE_ERROR) {
38
38
  BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED"] = "ERROR_NO_BASKET_SAVED";
39
39
  BASKET_SAVE_ERROR["ERROR_BASKET_AFTER_SAVE"] = "ERROR_BASKET_AFTER_SAVE";
40
+ BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED_ENTITY_EXISTS"] = "ERROR_NO_BASKET_SAVED_ENTITY_EXISTS";
40
41
  return BASKET_SAVE_ERROR;
41
42
  }({});
42
43
  var BasketHandler = /*#__PURE__*/function () {
@@ -62,11 +63,11 @@ var BasketHandler = /*#__PURE__*/function () {
62
63
  key: "saveBasket",
63
64
  value: function () {
64
65
  var _saveBasket = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(_ref) {
65
- var jwt, basket, awaitPDF, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _api2Result, authHeader, _this$LOG2, resultBasket, api2Result, _this$LOG3;
66
+ var jwt, basket, awaitPDF, utmCampaign, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _DivaUtils$Configurat, _api2Result, authHeader, resultBasket, api2Result, _e$response, _e$response2, _this$LOG4, _this$LOG2, _this$LOG3;
66
67
  return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
67
68
  while (1) switch (_context.prev = _context.next) {
68
69
  case 0:
69
- jwt = _ref.jwt, basket = _ref.basket, awaitPDF = _ref.awaitPDF, saveToApi2 = _ref.saveToApi2, sessionGuid = _ref.sessionGuid, apiKey = _ref.apiKey;
70
+ jwt = _ref.jwt, basket = _ref.basket, awaitPDF = _ref.awaitPDF, utmCampaign = _ref.utmCampaign, saveToApi2 = _ref.saveToApi2, sessionGuid = _ref.sessionGuid, apiKey = _ref.apiKey;
70
71
  if (basket.DivaNr) {
71
72
  _context.next = 4;
72
73
  break;
@@ -74,41 +75,34 @@ var BasketHandler = /*#__PURE__*/function () {
74
75
  (_this$LOG = this.LOG) === null || _this$LOG === void 0 || _this$LOG.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
75
76
  return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
76
77
  case 4:
77
- fullUrl = this.basketService + '/baskets';
78
- if (awaitPDF != undefined) {
79
- fullUrl = fullUrl + "?awaitPDF=".concat(awaitPDF);
80
- }
81
- _context.prev = 6;
78
+ fullUrl = new URL(this.basketService + '/baskets');
79
+ if (awaitPDF != undefined) fullUrl.searchParams.append('awaitPDF', awaitPDF.toString());
80
+ if (utmCampaign != undefined) fullUrl.searchParams.append('utmCampaign', utmCampaign);
81
+ _context.prev = 7;
82
82
  if (jwt) authHeader = {
83
83
  Authorization: 'Bearer ' + jwt
84
84
  };else if (apiKey) authHeader = {
85
85
  'X-API-KEY': apiKey
86
86
  };
87
- _context.next = 10;
88
- return axios__default["default"].post(fullUrl, JSON.stringify(basket.getAsJson()), {
87
+ _context.next = 11;
88
+ return axios__default["default"].post(fullUrl.toString(), JSON.stringify(basket.getAsJson()), {
89
89
  headers: _objectSpread(_objectSpread({}, authHeader), {}, {
90
90
  'Content-Type': 'application/json',
91
- 'X-Session-Id': DivaUtils__default["default"].SessionId
91
+ 'X-Session-Id': DivaUtils__default["default"].SessionId,
92
+ 'X-Configurator-Id': (_DivaUtils$Configurat = DivaUtils__default["default"].ConfigurationId) !== null && _DivaUtils$Configurat !== void 0 ? _DivaUtils$Configurat : ''
92
93
  })
93
94
  });
94
- case 10:
95
+ case 11:
95
96
  response = _context.sent;
96
- if (!(response.status !== 201)) {
97
- _context.next = 14;
98
- break;
99
- }
100
- (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed.');
101
- return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
102
- case 14:
103
- _context.next = 16;
97
+ _context.next = 14;
104
98
  return response.data;
105
- case 16:
99
+ case 14:
106
100
  resultBasket = _context.sent;
107
101
  if (!saveToApi2) {
108
- _context.next = 21;
102
+ _context.next = 19;
109
103
  break;
110
104
  }
111
- _context.next = 20;
105
+ _context.next = 18;
112
106
  return this.api2SaveBasket({
113
107
  basket: basket,
114
108
  sessionGuid: sessionGuid,
@@ -117,20 +111,34 @@ var BasketHandler = /*#__PURE__*/function () {
117
111
  saveToApi2: saveToApi2,
118
112
  _id: resultBasket._id
119
113
  });
120
- case 20:
114
+ case 18:
121
115
  api2Result = _context.sent;
122
- case 21:
116
+ case 19:
123
117
  return _context.abrupt("return", (_api2Result = api2Result) !== null && _api2Result !== void 0 ? _api2Result : resultBasket);
124
- case 24:
125
- _context.prev = 24;
126
- _context.t0 = _context["catch"](6);
127
- (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
118
+ case 22:
119
+ _context.prev = 22;
120
+ _context.t0 = _context["catch"](7);
121
+ if (!(((_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.status) === 409)) {
122
+ _context.next = 29;
123
+ break;
124
+ }
125
+ (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed - Entity already exists.');
126
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED_ENTITY_EXISTS);
127
+ case 29:
128
+ if (!(((_e$response2 = _context.t0.response) === null || _e$response2 === void 0 ? void 0 : _e$response2.status) !== 201)) {
129
+ _context.next = 32;
130
+ break;
131
+ }
132
+ (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket failed.');
133
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
134
+ case 32:
135
+ (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
128
136
  return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
129
- case 28:
137
+ case 34:
130
138
  case "end":
131
139
  return _context.stop();
132
140
  }
133
- }, _callee, this, [[6, 24]]);
141
+ }, _callee, this, [[7, 22]]);
134
142
  }));
135
143
  function saveBasket(_x) {
136
144
  return _saveBasket.apply(this, arguments);
@@ -141,7 +149,7 @@ var BasketHandler = /*#__PURE__*/function () {
141
149
  key: "api2SaveBasket",
142
150
  value: function () {
143
151
  var _api2SaveBasket = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(_ref2) {
144
- var basket, sessionGuid, awaitPDF, _id, _this$LOG4, _this$LOG5, fullUrl, response, _response$Result, _this$LOG6, _this$LOG7;
152
+ var basket, sessionGuid, awaitPDF, _id, _this$LOG5, _this$LOG6, fullUrl, response, _DivaUtils$Configurat2, _response$Result, _this$LOG7, _this$LOG8;
145
153
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
146
154
  while (1) switch (_context2.prev = _context2.next) {
147
155
  case 0:
@@ -150,14 +158,14 @@ var BasketHandler = /*#__PURE__*/function () {
150
158
  _context2.next = 4;
151
159
  break;
152
160
  }
153
- (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
161
+ (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
154
162
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
155
163
  case 4:
156
164
  if (sessionGuid) {
157
165
  _context2.next = 7;
158
166
  break;
159
167
  }
160
- (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Cant create api2 Basket without sessionguid');
168
+ (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Cant create api2 Basket without sessionguid');
161
169
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
162
170
  case 7:
163
171
  fullUrl = this.api2Url + '?function=SetJsonBasketData3' + '&callHeadlessBrowserAsync=' + (!awaitPDF ? '1' : '0');
@@ -169,7 +177,8 @@ var BasketHandler = /*#__PURE__*/function () {
169
177
  headers: {
170
178
  sessionGuid: sessionGuid,
171
179
  'Content-Type': 'application/json',
172
- 'X-Session-Id': DivaUtils__default["default"].SessionId
180
+ 'X-Session-Id': DivaUtils__default["default"].SessionId,
181
+ 'X-Configurator-Id': (_DivaUtils$Configurat2 = DivaUtils__default["default"].ConfigurationId) !== null && _DivaUtils$Configurat2 !== void 0 ? _DivaUtils$Configurat2 : ''
173
182
  }
174
183
  }).then(function (res) {
175
184
  if (res.status !== 200) {
@@ -183,7 +192,7 @@ var BasketHandler = /*#__PURE__*/function () {
183
192
  _context2.next = 15;
184
193
  break;
185
194
  }
186
- (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
195
+ (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
187
196
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
188
197
  case 15:
189
198
  _context2.next = 21;
@@ -191,7 +200,7 @@ var BasketHandler = /*#__PURE__*/function () {
191
200
  case 17:
192
201
  _context2.prev = 17;
193
202
  _context2.t0 = _context2["catch"](8);
194
- (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
203
+ (_this$LOG8 = this.LOG) === null || _this$LOG8 === void 0 || _this$LOG8.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
195
204
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
196
205
  case 21:
197
206
  return _context2.abrupt("return", undefined);
@@ -206,6 +215,50 @@ var BasketHandler = /*#__PURE__*/function () {
206
215
  }
207
216
  return api2SaveBasket;
208
217
  }()
218
+ }, {
219
+ key: "setOrdered",
220
+ value: function () {
221
+ var _setOrdered = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref3) {
222
+ var serviceUrl, organizationId, jwt, divaNr, documentVersion, body, _this$LOG9;
223
+ return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
224
+ while (1) switch (_context3.prev = _context3.next) {
225
+ case 0:
226
+ serviceUrl = _ref3.serviceUrl, organizationId = _ref3.organizationId, jwt = _ref3.jwt, divaNr = _ref3.divaNr, documentVersion = _ref3.documentVersion;
227
+ _context3.prev = 1;
228
+ body = {
229
+ divaNr: divaNr,
230
+ version: documentVersion
231
+ };
232
+ _context3.next = 5;
233
+ return fetch("".concat(serviceUrl, "/orders?organizationId=").concat(organizationId), {
234
+ method: 'POST',
235
+ headers: {
236
+ authorization: "Bearer ".concat(jwt),
237
+ 'content-type': 'application/json'
238
+ },
239
+ body: JSON.stringify(body)
240
+ }).then(function (r) {
241
+ return r.json();
242
+ });
243
+ case 5:
244
+ _context3.next = 11;
245
+ break;
246
+ case 7:
247
+ _context3.prev = 7;
248
+ _context3.t0 = _context3["catch"](1);
249
+ (_this$LOG9 = this.LOG) === null || _this$LOG9 === void 0 || _this$LOG9.error('Could not set OrderStatus: ' + _context3.t0.message);
250
+ throw new Error('DivaNr not found');
251
+ case 11:
252
+ case "end":
253
+ return _context3.stop();
254
+ }
255
+ }, _callee3, this, [[1, 7]]);
256
+ }));
257
+ function setOrdered(_x3) {
258
+ return _setOrdered.apply(this, arguments);
259
+ }
260
+ return setOrdered;
261
+ }()
209
262
  }]);
210
263
  }();
211
264
 
@@ -23,6 +23,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
23
23
  var BASKET_SAVE_ERROR = /*#__PURE__*/function (BASKET_SAVE_ERROR) {
24
24
  BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED"] = "ERROR_NO_BASKET_SAVED";
25
25
  BASKET_SAVE_ERROR["ERROR_BASKET_AFTER_SAVE"] = "ERROR_BASKET_AFTER_SAVE";
26
+ BASKET_SAVE_ERROR["ERROR_NO_BASKET_SAVED_ENTITY_EXISTS"] = "ERROR_NO_BASKET_SAVED_ENTITY_EXISTS";
26
27
  return BASKET_SAVE_ERROR;
27
28
  }({});
28
29
  var BasketHandler = /*#__PURE__*/function () {
@@ -48,11 +49,11 @@ var BasketHandler = /*#__PURE__*/function () {
48
49
  key: "saveBasket",
49
50
  value: function () {
50
51
  var _saveBasket = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
51
- var jwt, basket, awaitPDF, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _api2Result, authHeader, _this$LOG2, resultBasket, api2Result, _this$LOG3;
52
+ var jwt, basket, awaitPDF, utmCampaign, saveToApi2, sessionGuid, apiKey, _this$LOG, fullUrl, response, _DivaUtils$Configurat, _api2Result, authHeader, resultBasket, api2Result, _e$response, _e$response2, _this$LOG4, _this$LOG2, _this$LOG3;
52
53
  return _regeneratorRuntime.wrap(function _callee$(_context) {
53
54
  while (1) switch (_context.prev = _context.next) {
54
55
  case 0:
55
- jwt = _ref.jwt, basket = _ref.basket, awaitPDF = _ref.awaitPDF, saveToApi2 = _ref.saveToApi2, sessionGuid = _ref.sessionGuid, apiKey = _ref.apiKey;
56
+ jwt = _ref.jwt, basket = _ref.basket, awaitPDF = _ref.awaitPDF, utmCampaign = _ref.utmCampaign, saveToApi2 = _ref.saveToApi2, sessionGuid = _ref.sessionGuid, apiKey = _ref.apiKey;
56
57
  if (basket.DivaNr) {
57
58
  _context.next = 4;
58
59
  break;
@@ -60,41 +61,34 @@ var BasketHandler = /*#__PURE__*/function () {
60
61
  (_this$LOG = this.LOG) === null || _this$LOG === void 0 || _this$LOG.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
61
62
  return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
62
63
  case 4:
63
- fullUrl = this.basketService + '/baskets';
64
- if (awaitPDF != undefined) {
65
- fullUrl = fullUrl + "?awaitPDF=".concat(awaitPDF);
66
- }
67
- _context.prev = 6;
64
+ fullUrl = new URL(this.basketService + '/baskets');
65
+ if (awaitPDF != undefined) fullUrl.searchParams.append('awaitPDF', awaitPDF.toString());
66
+ if (utmCampaign != undefined) fullUrl.searchParams.append('utmCampaign', utmCampaign);
67
+ _context.prev = 7;
68
68
  if (jwt) authHeader = {
69
69
  Authorization: 'Bearer ' + jwt
70
70
  };else if (apiKey) authHeader = {
71
71
  'X-API-KEY': apiKey
72
72
  };
73
- _context.next = 10;
74
- return axios.post(fullUrl, JSON.stringify(basket.getAsJson()), {
73
+ _context.next = 11;
74
+ return axios.post(fullUrl.toString(), JSON.stringify(basket.getAsJson()), {
75
75
  headers: _objectSpread(_objectSpread({}, authHeader), {}, {
76
76
  'Content-Type': 'application/json',
77
- 'X-Session-Id': DivaUtils.SessionId
77
+ 'X-Session-Id': DivaUtils.SessionId,
78
+ 'X-Configurator-Id': (_DivaUtils$Configurat = DivaUtils.ConfigurationId) !== null && _DivaUtils$Configurat !== void 0 ? _DivaUtils$Configurat : ''
78
79
  })
79
80
  });
80
- case 10:
81
+ case 11:
81
82
  response = _context.sent;
82
- if (!(response.status !== 201)) {
83
- _context.next = 14;
84
- break;
85
- }
86
- (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed.');
87
- return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
88
- case 14:
89
- _context.next = 16;
83
+ _context.next = 14;
90
84
  return response.data;
91
- case 16:
85
+ case 14:
92
86
  resultBasket = _context.sent;
93
87
  if (!saveToApi2) {
94
- _context.next = 21;
88
+ _context.next = 19;
95
89
  break;
96
90
  }
97
- _context.next = 20;
91
+ _context.next = 18;
98
92
  return this.api2SaveBasket({
99
93
  basket: basket,
100
94
  sessionGuid: sessionGuid,
@@ -103,20 +97,34 @@ var BasketHandler = /*#__PURE__*/function () {
103
97
  saveToApi2: saveToApi2,
104
98
  _id: resultBasket._id
105
99
  });
106
- case 20:
100
+ case 18:
107
101
  api2Result = _context.sent;
108
- case 21:
102
+ case 19:
109
103
  return _context.abrupt("return", (_api2Result = api2Result) !== null && _api2Result !== void 0 ? _api2Result : resultBasket);
110
- case 24:
111
- _context.prev = 24;
112
- _context.t0 = _context["catch"](6);
113
- (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
104
+ case 22:
105
+ _context.prev = 22;
106
+ _context.t0 = _context["catch"](7);
107
+ if (!(((_e$response = _context.t0.response) === null || _e$response === void 0 ? void 0 : _e$response.status) === 409)) {
108
+ _context.next = 29;
109
+ break;
110
+ }
111
+ (_this$LOG2 = this.LOG) === null || _this$LOG2 === void 0 || _this$LOG2.error('Saving Basket failed - Entity already exists.');
112
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED_ENTITY_EXISTS);
113
+ case 29:
114
+ if (!(((_e$response2 = _context.t0.response) === null || _e$response2 === void 0 ? void 0 : _e$response2.status) !== 201)) {
115
+ _context.next = 32;
116
+ break;
117
+ }
118
+ (_this$LOG3 = this.LOG) === null || _this$LOG3 === void 0 || _this$LOG3.error('Saving Basket failed.');
119
+ return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
120
+ case 32:
121
+ (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. serverError ' + _context.t0.message, 'SELLER_0003');
114
122
  return _context.abrupt("return", BASKET_SAVE_ERROR.ERROR_NO_BASKET_SAVED);
115
- case 28:
123
+ case 34:
116
124
  case "end":
117
125
  return _context.stop();
118
126
  }
119
- }, _callee, this, [[6, 24]]);
127
+ }, _callee, this, [[7, 22]]);
120
128
  }));
121
129
  function saveBasket(_x) {
122
130
  return _saveBasket.apply(this, arguments);
@@ -127,7 +135,7 @@ var BasketHandler = /*#__PURE__*/function () {
127
135
  key: "api2SaveBasket",
128
136
  value: function () {
129
137
  var _api2SaveBasket = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
130
- var basket, sessionGuid, awaitPDF, _id, _this$LOG4, _this$LOG5, fullUrl, response, _response$Result, _this$LOG6, _this$LOG7;
138
+ var basket, sessionGuid, awaitPDF, _id, _this$LOG5, _this$LOG6, fullUrl, response, _DivaUtils$Configurat2, _response$Result, _this$LOG7, _this$LOG8;
131
139
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
132
140
  while (1) switch (_context2.prev = _context2.next) {
133
141
  case 0:
@@ -136,14 +144,14 @@ var BasketHandler = /*#__PURE__*/function () {
136
144
  _context2.next = 4;
137
145
  break;
138
146
  }
139
- (_this$LOG4 = this.LOG) === null || _this$LOG4 === void 0 || _this$LOG4.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
147
+ (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Saving Basket Failed. Error: DivaNr is empty', 'SELLER_0003');
140
148
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
141
149
  case 4:
142
150
  if (sessionGuid) {
143
151
  _context2.next = 7;
144
152
  break;
145
153
  }
146
- (_this$LOG5 = this.LOG) === null || _this$LOG5 === void 0 || _this$LOG5.error('Cant create api2 Basket without sessionguid');
154
+ (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Cant create api2 Basket without sessionguid');
147
155
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
148
156
  case 7:
149
157
  fullUrl = this.api2Url + '?function=SetJsonBasketData3' + '&callHeadlessBrowserAsync=' + (!awaitPDF ? '1' : '0');
@@ -155,7 +163,8 @@ var BasketHandler = /*#__PURE__*/function () {
155
163
  headers: {
156
164
  sessionGuid: sessionGuid,
157
165
  'Content-Type': 'application/json',
158
- 'X-Session-Id': DivaUtils.SessionId
166
+ 'X-Session-Id': DivaUtils.SessionId,
167
+ 'X-Configurator-Id': (_DivaUtils$Configurat2 = DivaUtils.ConfigurationId) !== null && _DivaUtils$Configurat2 !== void 0 ? _DivaUtils$Configurat2 : ''
159
168
  }
160
169
  }).then(function (res) {
161
170
  if (res.status !== 200) {
@@ -169,7 +178,7 @@ var BasketHandler = /*#__PURE__*/function () {
169
178
  _context2.next = 15;
170
179
  break;
171
180
  }
172
- (_this$LOG6 = this.LOG) === null || _this$LOG6 === void 0 || _this$LOG6.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
181
+ (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError: ' + response.Error, 'SELLER_0003');
173
182
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
174
183
  case 15:
175
184
  _context2.next = 21;
@@ -177,7 +186,7 @@ var BasketHandler = /*#__PURE__*/function () {
177
186
  case 17:
178
187
  _context2.prev = 17;
179
188
  _context2.t0 = _context2["catch"](8);
180
- (_this$LOG7 = this.LOG) === null || _this$LOG7 === void 0 || _this$LOG7.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
189
+ (_this$LOG8 = this.LOG) === null || _this$LOG8 === void 0 || _this$LOG8.error('Saving Basket Failed. serverError ' + _context2.t0.message, 'SELLER_0003');
181
190
  return _context2.abrupt("return", BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE);
182
191
  case 21:
183
192
  return _context2.abrupt("return", undefined);
@@ -192,6 +201,50 @@ var BasketHandler = /*#__PURE__*/function () {
192
201
  }
193
202
  return api2SaveBasket;
194
203
  }()
204
+ }, {
205
+ key: "setOrdered",
206
+ value: function () {
207
+ var _setOrdered = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
208
+ var serviceUrl, organizationId, jwt, divaNr, documentVersion, body, _this$LOG9;
209
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
210
+ while (1) switch (_context3.prev = _context3.next) {
211
+ case 0:
212
+ serviceUrl = _ref3.serviceUrl, organizationId = _ref3.organizationId, jwt = _ref3.jwt, divaNr = _ref3.divaNr, documentVersion = _ref3.documentVersion;
213
+ _context3.prev = 1;
214
+ body = {
215
+ divaNr: divaNr,
216
+ version: documentVersion
217
+ };
218
+ _context3.next = 5;
219
+ return fetch("".concat(serviceUrl, "/orders?organizationId=").concat(organizationId), {
220
+ method: 'POST',
221
+ headers: {
222
+ authorization: "Bearer ".concat(jwt),
223
+ 'content-type': 'application/json'
224
+ },
225
+ body: JSON.stringify(body)
226
+ }).then(function (r) {
227
+ return r.json();
228
+ });
229
+ case 5:
230
+ _context3.next = 11;
231
+ break;
232
+ case 7:
233
+ _context3.prev = 7;
234
+ _context3.t0 = _context3["catch"](1);
235
+ (_this$LOG9 = this.LOG) === null || _this$LOG9 === void 0 || _this$LOG9.error('Could not set OrderStatus: ' + _context3.t0.message);
236
+ throw new Error('DivaNr not found');
237
+ case 11:
238
+ case "end":
239
+ return _context3.stop();
240
+ }
241
+ }, _callee3, this, [[1, 7]]);
242
+ }));
243
+ function setOrdered(_x3) {
244
+ return _setOrdered.apply(this, arguments);
245
+ }
246
+ return setOrdered;
247
+ }()
195
248
  }]);
196
249
  }();
197
250
 
@@ -1,9 +1,10 @@
1
1
 
2
2
 
3
- import { SaveBasketProps, SaveBasketProps2 } from './types';
3
+ import { SaveBasketProps, SaveBasketProps2, SetOrderedProps } from './types';
4
4
  export declare enum BASKET_SAVE_ERROR {
5
5
  ERROR_NO_BASKET_SAVED = "ERROR_NO_BASKET_SAVED",
6
- ERROR_BASKET_AFTER_SAVE = "ERROR_BASKET_AFTER_SAVE"
6
+ ERROR_BASKET_AFTER_SAVE = "ERROR_BASKET_AFTER_SAVE",
7
+ ERROR_NO_BASKET_SAVED_ENTITY_EXISTS = "ERROR_NO_BASKET_SAVED_ENTITY_EXISTS"
7
8
  }
8
9
  export default class BasketHandler {
9
10
  private LOG;
@@ -12,8 +13,9 @@ export default class BasketHandler {
12
13
  constructor(LOG: any, basketService: string, api2Url: string);
13
14
  get basketService(): string;
14
15
  get api2Url(): string;
15
- saveBasket({ jwt, basket, awaitPDF, saveToApi2, sessionGuid, apiKey }: SaveBasketProps): Promise<any>;
16
+ saveBasket({ jwt, basket, awaitPDF, utmCampaign, saveToApi2, sessionGuid, apiKey }: SaveBasketProps): Promise<any>;
16
17
  api2SaveBasket({ basket, sessionGuid, awaitPDF, _id }: SaveBasketProps2): Promise<BASKET_SAVE_ERROR.ERROR_BASKET_AFTER_SAVE | undefined>;
18
+ setOrdered({ serviceUrl, organizationId, jwt, divaNr, documentVersion }: SetOrderedProps): Promise<void>;
17
19
  }
18
20
  //# sourceMappingURL=index.d.ts.map
19
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAI5D,oBAAY,iBAAiB;IAC3B,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;CACpD;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;IAGpB,OAAO,CAAC,GAAG;IAFvB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;gBACL,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAKpE,IAAI,aAAa,WAEhB;IAED,IAAI,OAAO,WAEV;IAEK,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,eAAe;IAuCtF,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,gBAAgB;CAqC9E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI7E,oBAAY,iBAAiB;IAC3B,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,mCAAmC,wCAAwC;CAC5E;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;IAI9B,OAAO,CAAC,GAAG;IAHb,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;gBAEf,GAAG,EAAE,GAAG,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;IAMjB,IAAI,aAAa,WAEhB;IAED,IAAI,OAAO,WAEV;IAEK,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,eAAe;IA2CnG,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,gBAAgB;IAuCvE,UAAU,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAmB/G"}
@@ -4,6 +4,7 @@ export interface SaveBasketProps {
4
4
  jwt?: string;
5
5
  saveToApi2: boolean;
6
6
  awaitPDF?: boolean;
7
+ utmCampaign?: string;
7
8
  sessionGuid?: string;
8
9
  apiKey?: string;
9
10
  }
@@ -12,7 +13,15 @@ export interface SaveBasketProps2 {
12
13
  jwt?: string;
13
14
  saveToApi2: boolean;
14
15
  awaitPDF?: boolean;
16
+ utmCampaign?: string;
15
17
  sessionGuid?: string;
16
18
  _id: string;
17
19
  }
20
+ export interface SetOrderedProps {
21
+ serviceUrl: string;
22
+ organizationId: string;
23
+ jwt: string;
24
+ divaNr: string;
25
+ documentVersion?: number;
26
+ }
18
27
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AACD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/basket-handler",
3
- "version": "25.13.2-rc.8",
3
+ "version": "25.13.2",
4
4
  "peerDependencies": {
5
5
  "@crystaldesign/basket-model": "*"
6
6
  },
@@ -12,5 +12,5 @@
12
12
  "axios": "^1.7.7",
13
13
  "md5.js": "^1.3.5"
14
14
  },
15
- "gitHead": "e3e14e5224c6ed1b287529149be094c852b12528"
15
+ "gitHead": "6db5eeb3a00a4d1f07d84b2d14a4ef1abf6f4274"
16
16
  }