@vergelijkdirect/insurance-transmission-client 1.3.63 → 1.3.64

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vergelijkdirect/insurance-transmission-client",
3
- "version": "1.3.63",
3
+ "version": "1.3.64",
4
4
  "description": "",
5
5
  "main": "./src/js/index.js",
6
6
  "scripts": {
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var resources_1 = require("../resources");
40
40
  var factories_1 = require("../factories");
41
41
  var core_1 = require("../core");
42
+ var supplierPlacementTracker_util_1 = require("../utils/supplierPlacementTracker.util");
42
43
  var ComparisonService = /** @class */ (function () {
43
44
  function ComparisonService() {
44
45
  this.client = new resources_1.ComparisonResource();
@@ -56,6 +57,9 @@ var ComparisonService = /** @class */ (function () {
56
57
  if (user !== null) {
57
58
  data.user = user;
58
59
  }
60
+ if (supplierPlacementTracker_util_1.supplierPlacementTracker.getSubId()) {
61
+ data.sub_id = supplierPlacementTracker_util_1.supplierPlacementTracker.getSubId();
62
+ }
59
63
  return [4 /*yield*/, this.client.create(data)];
60
64
  case 1:
61
65
  response = _a.sent();
@@ -71,6 +75,9 @@ var ComparisonService = /** @class */ (function () {
71
75
  switch (_a.label) {
72
76
  case 0:
73
77
  data = comparison.toObject();
78
+ if (supplierPlacementTracker_util_1.supplierPlacementTracker.getSubId()) {
79
+ data.sub_id = supplierPlacementTracker_util_1.supplierPlacementTracker.getSubId();
80
+ }
74
81
  return [4 /*yield*/, this.client.update(data, comparison.getId())];
75
82
  case 1:
76
83
  response = _a.sent();
@@ -126,6 +126,9 @@ var PackageService = /** @class */ (function () {
126
126
  criteria['SupplierID'] = localStorage.getItem('supplierID');
127
127
  criteria['PlacementID'] = localStorage.getItem('placementID');
128
128
  }
129
+ if (supplierPlacementTracker_util_1.supplierPlacementTracker.getSubId()) {
130
+ criteria['SubID'] = supplierPlacementTracker_util_1.supplierPlacementTracker.getSubId();
131
+ }
129
132
  return [4 /*yield*/, this.client.requestPackage(criteria)];
130
133
  case 1:
131
134
  response = _a.sent();
@@ -1,4 +1,6 @@
1
1
  export declare const supplierPlacementTracker: {
2
2
  setParams(): void;
3
3
  removeParams(): void;
4
+ getSubId(): string;
5
+ getCookie(name: string): string;
4
6
  };
@@ -1,4 +1,31 @@
1
1
  "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
2
29
  Object.defineProperty(exports, "__esModule", { value: true });
3
30
  exports.supplierPlacementTracker = void 0;
4
31
  exports.supplierPlacementTracker = {
@@ -14,5 +41,31 @@ exports.supplierPlacementTracker = {
14
41
  removeParams: function () {
15
42
  localStorage.removeItem('supplierID');
16
43
  localStorage.removeItem('placementID');
44
+ },
45
+ getSubId: function () {
46
+ var urlParams = new URLSearchParams(window.location.search);
47
+ var subID = urlParams.get('subid') || this.getCookie('ivanhoe_id');
48
+ return (subID && subID.includes('ivan')) ? subID : '';
49
+ },
50
+ getCookie: function (name) {
51
+ var e_1, _a;
52
+ var cookies = document.cookie.split(';');
53
+ try {
54
+ for (var cookies_1 = __values(cookies), cookies_1_1 = cookies_1.next(); !cookies_1_1.done; cookies_1_1 = cookies_1.next()) {
55
+ var cookie = cookies_1_1.value;
56
+ var _b = __read(cookie.trim().split('=')), key = _b[0], value = _b.slice(1);
57
+ if (key === name) {
58
+ return decodeURIComponent(value.join('='));
59
+ }
60
+ }
61
+ }
62
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
63
+ finally {
64
+ try {
65
+ if (cookies_1_1 && !cookies_1_1.done && (_a = cookies_1.return)) _a.call(cookies_1);
66
+ }
67
+ finally { if (e_1) throw e_1.error; }
68
+ }
69
+ return '';
17
70
  }
18
71
  };
@@ -1,27 +0,0 @@
1
- import { EnvironmentInterface, RateInterface, StorageInterface } from "../interfaces";
2
- declare class ShoppingCardClient {
3
- private products;
4
- private packageService;
5
- private totalPrice;
6
- private totalDiscount;
7
- private subTotal;
8
- private totalCosts;
9
- private storageManager;
10
- onCalculating: boolean;
11
- constructor(storageManager: StorageInterface, env: EnvironmentInterface);
12
- configure(config: EnvironmentInterface): this;
13
- addProduct(rate: RateInterface): this;
14
- setProducts(products: any): this;
15
- getTotalCosts(): number;
16
- getTotalPrice(): number;
17
- getTotalDiscount(): number;
18
- getSubTotal(): number;
19
- getProducts(): any;
20
- setCalculations(calculations: any): this;
21
- initFromStore(): void;
22
- resetCard(): void;
23
- productsCount(): any;
24
- private commit;
25
- private calculatePackage;
26
- }
27
- export default ShoppingCardClient;
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var core_1 = require("../core");
4
- var package_service_1 = require("../services/package.service");
5
- var ShoppingCardClient = /** @class */ (function () {
6
- function ShoppingCardClient(storageManager, env) {
7
- this.products = [];
8
- this.totalPrice = 0;
9
- this.totalDiscount = 0;
10
- this.subTotal = 0;
11
- this.totalCosts = 0;
12
- this.onCalculating = false;
13
- this.storageManager = storageManager;
14
- this.configure(env);
15
- this.packageService = new package_service_1.default();
16
- }
17
- ShoppingCardClient.prototype.configure = function (config) {
18
- var injector = core_1.Injector.instance;
19
- injector.constant('environment', config);
20
- return this;
21
- };
22
- ShoppingCardClient.prototype.addProduct = function (rate) {
23
- var rateData = rate.getData();
24
- this.products.push(rateData);
25
- this.calculatePackage();
26
- return this;
27
- };
28
- ShoppingCardClient.prototype.setProducts = function (products) {
29
- this.products = products;
30
- this.calculatePackage();
31
- return this;
32
- };
33
- ShoppingCardClient.prototype.getTotalCosts = function () {
34
- return this.totalCosts;
35
- };
36
- ShoppingCardClient.prototype.getTotalPrice = function () {
37
- return this.totalPrice;
38
- };
39
- ShoppingCardClient.prototype.getTotalDiscount = function () {
40
- return this.totalDiscount;
41
- };
42
- ShoppingCardClient.prototype.getSubTotal = function () {
43
- return this.subTotal;
44
- };
45
- ShoppingCardClient.prototype.getProducts = function () {
46
- return this.products;
47
- };
48
- ShoppingCardClient.prototype.setCalculations = function (calculations) {
49
- this.subTotal = calculations.NettoPremium;
50
- this.totalPrice = calculations.Premium;
51
- this.totalDiscount = calculations.PackageDiscount;
52
- this.totalCosts = calculations.TotalCosts;
53
- this.commit();
54
- return this;
55
- };
56
- ShoppingCardClient.prototype.initFromStore = function () {
57
- this.products = this.storageManager.get('products');
58
- this.totalPrice = this.storageManager.get('totalPrice');
59
- this.totalDiscount = this.storageManager.get('totalDiscount');
60
- this.subTotal = this.storageManager.get('subTotal');
61
- this.totalCosts = this.storageManager.get('totalCosts');
62
- };
63
- ShoppingCardClient.prototype.resetCard = function () {
64
- this.products = [];
65
- this.totalPrice = 0;
66
- this.totalDiscount = 0;
67
- this.subTotal = 0;
68
- this.commit();
69
- };
70
- ShoppingCardClient.prototype.productsCount = function () {
71
- return this.products.length;
72
- };
73
- ShoppingCardClient.prototype.commit = function () {
74
- this.storageManager.put('products', this.products);
75
- this.storageManager.put('totalPrice', this.totalPrice);
76
- this.storageManager.put('totalDiscount', this.totalDiscount);
77
- this.storageManager.put('subTotal', this.subTotal);
78
- this.storageManager.put('totalCosts', this.totalCosts);
79
- return this;
80
- };
81
- ShoppingCardClient.prototype.calculatePackage = function () {
82
- var _this = this;
83
- this.onCalculating = true;
84
- this.packageService.calculatePackage(this.getProducts())
85
- .then(function (calculations) {
86
- _this.setCalculations(calculations);
87
- _this.onCalculating = false;
88
- })
89
- .catch(function (error) {
90
- console.error(error);
91
- _this.onCalculating = false;
92
- });
93
- };
94
- return ShoppingCardClient;
95
- }());
96
- exports.default = ShoppingCardClient;
@@ -1,8 +0,0 @@
1
- interface AbstractRateInterface {
2
- Price: number;
3
- CompanyName: string;
4
- CompanyLogoUrl: string;
5
- Identifier: string;
6
- Coverage: any;
7
- }
8
- export default AbstractRateInterface;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export default function (insuranceCategory: string): any;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function default_1(insuranceCategory) {
4
- var map = {
5
- 'moped': 'brommer',
6
- 'pet': 'dieren',
7
- 'motor': 'motor',
8
- 'home': 'woon',
9
- 'household': 'woon',
10
- 'liability': 'woon',
11
- 'legal-assistance': 'rechtsbijstand',
12
- 'caravan': 'caravan',
13
- 'bike': 'fiets',
14
- 'car': 'car',
15
- };
16
- return map[insuranceCategory];
17
- }
18
- exports.default = default_1;