@colijnit/catalog 255.1.8 → 255.1.10

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.
@@ -30,8 +30,8 @@
30
30
  function Version() {
31
31
  this.name = "@colijnit/catalog";
32
32
  this.description = "iOne Catalog module based on Angular 12";
33
- this.symVer = "255.1.8";
34
- this.publishDate = "16-9-2024 17:31:10";
33
+ this.symVer = "255.1.10";
34
+ this.publishDate = "20-9-2024 11:08:40";
35
35
  }
36
36
  return Version;
37
37
  }());
@@ -5867,58 +5867,73 @@
5867
5867
  };
5868
5868
  CatalogExternalSourceComponent.prototype.fetchAndCombineThreeDimerseData = function (hash) {
5869
5869
  return __awaiter(this, void 0, void 0, function () {
5870
- var customerName, configurationUrl, priceDataUrl, apiResponses, configurationResponse, priceDataResponse, configurationData_1, priceData_1, resultObject, error_1;
5870
+ var customerName, configurationUrl, priceDataUrl, configurationData_1, priceData_1;
5871
+ var _this = this;
5871
5872
  return __generator(this, function (_a) {
5872
- switch (_a.label) {
5873
- case 0:
5874
- customerName = 'Linteloo';
5875
- configurationUrl = this._externalSource.domain + '/configurationData/' + hash;
5876
- console.log('configurationUrl');
5877
- priceDataUrl = this._externalSource.domain + '/rules/api/' + customerName.toLowerCase() + '/' + hash;
5878
- console.log('priceDataUrl');
5879
- _a.label = 1;
5880
- case 1:
5881
- _a.trys.push([1, 3, , 4]);
5882
- return [4 /*yield*/, Promise.all([
5883
- this.fetchJsonFile(configurationUrl),
5884
- this.fetchJsonFile(priceDataUrl)
5885
- ])];
5886
- case 2:
5887
- apiResponses = _a.sent();
5888
- configurationResponse = apiResponses[0];
5889
- priceDataResponse = apiResponses[1];
5890
- if (configurationResponse && configurationResponse.ok) {
5891
- configurationResponse.json().then(function (result) {
5892
- console.log(result);
5873
+ customerName = this._externalSource.username;
5874
+ configurationUrl = this._externalSource.domain + '/configurationData/' + hash;
5875
+ priceDataUrl = this._externalSource.domain + '/rules/api/' + customerName.toLowerCase() + '/' + hash;
5876
+ //test setup for local testing
5877
+ //const configurationUrl: string = "https://bertplantagie.platformapi-accept.3dimerce.com/configurationData/8eb5b35697c96716d3e253294344d98e4dcdcb68969c288189d45829164e3177";
5878
+ //console.log(configurationUrl);
5879
+ //const priceDataUrl: string = "https://bertplantagie.platformapi-accept.3dimerce.com/rules/api/bertplantagie/8eb5b35697c96716d3e253294344d98e4dcdcb68969c288189d45829164e3177";
5880
+ //console.log(priceDataUrl);
5881
+ try {
5882
+ //first fetch the configuration data
5883
+ this.fetchJsonFile(configurationUrl).then(function (configResponse) {
5884
+ if (configResponse && configResponse.ok) {
5885
+ configResponse.json().then(function (result) {
5886
+ //console.log(result);
5893
5887
  configurationData_1 = result;
5888
+ //if we have config data continue to fetch price data
5889
+ _this.fetchJsonFile(priceDataUrl).then(function (priceResponse) {
5890
+ if (priceResponse && priceResponse.ok) {
5891
+ priceResponse.json().then(function (result) {
5892
+ //console.log(result);
5893
+ priceData_1 = result;
5894
+ //If we have config and price data. Create the necessary data object and pass it along.
5895
+ _this.create3DimerseFeedback(configurationData_1, priceData_1);
5896
+ }).catch(function (e) {
5897
+ //If there is no price data, make that object null and pass data along
5898
+ _this.create3DimerseFeedback(configurationData_1, null);
5899
+ console.log(e);
5900
+ });
5901
+ }
5902
+ else {
5903
+ //If there is no valid price data, make that object null and pass data along
5904
+ _this.create3DimerseFeedback(configurationData_1, null);
5905
+ }
5906
+ }).catch(function (e) {
5907
+ //If we cannot fetch price data
5908
+ _this.create3DimerseFeedback(configurationData_1, null);
5909
+ console.log(e);
5910
+ });
5894
5911
  }).catch(function (e) {
5912
+ //If there is an error fetching config data do not continue. just log the error.
5895
5913
  console.log(e);
5896
5914
  configurationData_1 = {};
5897
5915
  });
5898
5916
  }
5899
- if (priceDataResponse && priceDataResponse.ok) {
5900
- priceDataResponse.json().then(function (result) {
5901
- console.log(result);
5902
- priceData_1 = result;
5903
- }).catch(function (e) {
5904
- console.log(e);
5905
- priceData_1 = {};
5906
- });
5907
- }
5908
- resultObject = {};
5909
- resultObject['configuratie-data'] = configurationData_1;
5910
- resultObject['prijs-data'] = priceData_1;
5911
- this.iFrameFeedbackReceived.emit(JSON.stringify(resultObject));
5912
- return [3 /*break*/, 4];
5913
- case 3:
5914
- error_1 = _a.sent();
5915
- console.error('Error fetching data:', error_1);
5916
- return [3 /*break*/, 4];
5917
- case 4: return [2 /*return*/];
5917
+ }).catch(function (e) {
5918
+ //If there is an error fetching config dat. just log the error.
5919
+ console.log(e);
5920
+ configurationData_1 = {};
5921
+ });
5918
5922
  }
5923
+ catch (error) {
5924
+ console.error('Error fetching data:', error);
5925
+ }
5926
+ return [2 /*return*/];
5919
5927
  });
5920
5928
  });
5921
5929
  };
5930
+ CatalogExternalSourceComponent.prototype.create3DimerseFeedback = function (configurationData, priceData) {
5931
+ var resultObject = {};
5932
+ resultObject['configuratie-data'] = configurationData;
5933
+ resultObject['prijs-data'] = priceData;
5934
+ console.log(resultObject);
5935
+ this.iFrameFeedbackReceived.emit(JSON.stringify(resultObject));
5936
+ };
5922
5937
  CatalogExternalSourceComponent.prototype.fetchJsonFile = function (url) {
5923
5938
  return __awaiter(this, void 0, void 0, function () {
5924
5939
  return __generator(this, function (_a) {