@vergelijkdirect/insurance-transmission-client 1.3.67 → 1.3.69
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/README.md +2 -0
- package/package.json +4 -1
- package/src/js/adapters/index.d.ts +1 -0
- package/src/js/adapters/index.js +3 -1
- package/src/js/adapters/memory-storage.adapter.d.ts +14 -0
- package/src/js/adapters/memory-storage.adapter.js +33 -0
- package/src/js/core/http.client.js +4 -7
- package/src/js/interfaces/environment.interface.d.ts +8 -0
- package/src/js/models/comparison/comparison.model.js +1 -1
- package/src/js/resources/bike.resource.js +2 -1
- package/src/js/resources/loan.resource.d.ts +1 -0
- package/src/js/resources/loan.resource.js +6 -0
- package/src/js/services/loan.service.d.ts +1 -0
- package/src/js/services/loan.service.js +7 -0
- package/src/js/services/package.service.js +2 -1
- package/src/js/utils/supplierPlacementTracker.util.js +12 -0
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Partner-facing JavaScript/TypeScript client for the Vergelijkdirect Insurance Transmission API.
|
|
4
4
|
|
|
5
|
+
This repository also contains the **Partner API server** (`server/`) — a Node.js HTTP API on https://partner-api.vergelijkdirect.com that runs the same comparison flow server-side: partners send one request and receive a comparison id plus calculated rates. See [server/README.md](server/README.md). The browser client below is unaffected and keeps working as before.
|
|
6
|
+
|
|
5
7
|
Use this client to request insurance rates from all partner-enabled providers in one flow, receive one combined `RateCollection`, work with normalized rate models, store selected offers, and call supporting API services for comparison sessions, vehicle data, documents, validation, packages, loans, partner data, and lookups.
|
|
6
8
|
|
|
7
9
|
## What It Can Do
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vergelijkdirect/insurance-transmission-client",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.69",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/js/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest --config jestconfig.json",
|
|
8
8
|
"compile": "export NODE_OPTIONS=--openssl-legacy-provider; tsc",
|
|
9
|
+
"compile:server": "tsc -p server/tsconfig.json",
|
|
10
|
+
"start:server": "node server/js/index.js",
|
|
9
11
|
"_browserify": "browserify src/tests/browser/${npm_config_arg}.webtest.js -o src/tests/browser/bundle.js",
|
|
10
12
|
"browserify": "npm run _browserify"
|
|
11
13
|
},
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
"license": "ISC",
|
|
21
23
|
"homepage": "https://bitbucket.org/vergelijkdirect/insurance-transmission-client#readme",
|
|
22
24
|
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.19.43",
|
|
23
26
|
"jest": "^29.6.1",
|
|
24
27
|
"jest-localstorage-mock": "^2.4.0",
|
|
25
28
|
"ts-jest": "^29.1.1",
|
package/src/js/adapters/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LocalStorageAdapter = void 0;
|
|
3
|
+
exports.MemoryStorageAdapter = exports.LocalStorageAdapter = void 0;
|
|
4
4
|
var local_storage_adapter_1 = require("./local-storage.adapter");
|
|
5
5
|
Object.defineProperty(exports, "LocalStorageAdapter", { enumerable: true, get: function () { return local_storage_adapter_1.default; } });
|
|
6
|
+
var memory_storage_adapter_1 = require("./memory-storage.adapter");
|
|
7
|
+
Object.defineProperty(exports, "MemoryStorageAdapter", { enumerable: true, get: function () { return memory_storage_adapter_1.default; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StorageInterface } from '../interfaces';
|
|
2
|
+
declare class MemoryStorageAdapter implements StorageInterface {
|
|
3
|
+
protected storage: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
save(key: string, data: any): this;
|
|
7
|
+
put(key: string, data: any): this;
|
|
8
|
+
get(key: string): any;
|
|
9
|
+
remove(key: string): this;
|
|
10
|
+
all(): {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export default MemoryStorageAdapter;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var MemoryStorageAdapter = /** @class */ (function () {
|
|
4
|
+
function MemoryStorageAdapter() {
|
|
5
|
+
this.storage = {};
|
|
6
|
+
}
|
|
7
|
+
MemoryStorageAdapter.prototype.save = function (key, data) {
|
|
8
|
+
if (this.storage[key] === undefined) {
|
|
9
|
+
this.storage[key] = [];
|
|
10
|
+
}
|
|
11
|
+
this.storage[key].push(data);
|
|
12
|
+
return this;
|
|
13
|
+
};
|
|
14
|
+
MemoryStorageAdapter.prototype.put = function (key, data) {
|
|
15
|
+
this.storage[key] = data;
|
|
16
|
+
return this;
|
|
17
|
+
};
|
|
18
|
+
MemoryStorageAdapter.prototype.get = function (key) {
|
|
19
|
+
if (this.storage[key] === undefined) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
return this.storage[key];
|
|
23
|
+
};
|
|
24
|
+
MemoryStorageAdapter.prototype.remove = function (key) {
|
|
25
|
+
delete this.storage[key];
|
|
26
|
+
return this;
|
|
27
|
+
};
|
|
28
|
+
MemoryStorageAdapter.prototype.all = function () {
|
|
29
|
+
return this.storage;
|
|
30
|
+
};
|
|
31
|
+
return MemoryStorageAdapter;
|
|
32
|
+
}());
|
|
33
|
+
exports.default = MemoryStorageAdapter;
|
|
@@ -86,16 +86,13 @@ var HttpClient = /** @class */ (function () {
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
HttpClient.prototype.getDefaultHeaders = function () {
|
|
89
|
-
var _a, _b;
|
|
90
|
-
var headers = {
|
|
91
|
-
|
|
92
|
-
'ITC': 'true',
|
|
93
|
-
};
|
|
94
|
-
var credentials = (_a = this.environment) === null || _a === void 0 ? void 0 : _a.api.credentials;
|
|
89
|
+
var _a, _b, _c, _d;
|
|
90
|
+
var headers = __assign({ 'Content-Type': 'application/json', 'ITC': 'true' }, ((_b = (_a = this.environment) === null || _a === void 0 ? void 0 : _a.api.headers) !== null && _b !== void 0 ? _b : {}));
|
|
91
|
+
var credentials = (_c = this.environment) === null || _c === void 0 ? void 0 : _c.api.credentials;
|
|
95
92
|
if (!credentials) {
|
|
96
93
|
return headers;
|
|
97
94
|
}
|
|
98
|
-
var authType = (
|
|
95
|
+
var authType = (_d = credentials.authType) !== null && _d !== void 0 ? _d : 'headers';
|
|
99
96
|
if (authType === 'headers' || authType === 'both') {
|
|
100
97
|
headers['X-Partner-Access-Key'] = credentials.accessKey;
|
|
101
98
|
headers['X-Partner-Secret'] = credentials.secret;
|
|
@@ -9,6 +9,14 @@ interface EnvironmentInterface {
|
|
|
9
9
|
baseUrl: string;
|
|
10
10
|
version: string;
|
|
11
11
|
credentials?: PartnerCredentialsInterface;
|
|
12
|
+
/**
|
|
13
|
+
* Extra headers sent with every request. Server-side integrations use
|
|
14
|
+
* this to pass the partner context explicitly instead of relying on
|
|
15
|
+
* the API resolving it from the calling host.
|
|
16
|
+
*/
|
|
17
|
+
headers?: {
|
|
18
|
+
[name: string]: string;
|
|
19
|
+
};
|
|
12
20
|
};
|
|
13
21
|
}
|
|
14
22
|
export default EnvironmentInterface;
|
|
@@ -44,7 +44,7 @@ var Comparison = /** @class */ (function () {
|
|
|
44
44
|
this.funnel = funnel;
|
|
45
45
|
this.data = data;
|
|
46
46
|
this.user = user;
|
|
47
|
-
this.location = window.location;
|
|
47
|
+
this.location = typeof window !== 'undefined' ? window.location : { href: '' };
|
|
48
48
|
this.updated_at = updated_at;
|
|
49
49
|
this.created_at = created_at;
|
|
50
50
|
}
|
|
@@ -5,5 +5,6 @@ declare class LoanResource extends CategoryResource {
|
|
|
5
5
|
protected getAvailableServices(): string[];
|
|
6
6
|
getFieldValues(fieldName: string): Promise<any>;
|
|
7
7
|
loanRequest(data: any): Promise<any>;
|
|
8
|
+
getRequestStatus(id: string): Promise<any>;
|
|
8
9
|
}
|
|
9
10
|
export default LoanResource;
|
|
@@ -43,6 +43,12 @@ var LoanResource = /** @class */ (function (_super) {
|
|
|
43
43
|
data: data
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
+
LoanResource.prototype.getRequestStatus = function (id) {
|
|
47
|
+
return this.http({
|
|
48
|
+
method: 'get',
|
|
49
|
+
url: "/request/status/".concat(id),
|
|
50
|
+
});
|
|
51
|
+
};
|
|
46
52
|
return LoanResource;
|
|
47
53
|
}(categories_resource_1.default));
|
|
48
54
|
exports.default = LoanResource;
|
|
@@ -7,5 +7,6 @@ declare class LoanService extends RateService implements CalculateRatesInterface
|
|
|
7
7
|
getRates(data: any): Promise<RateCollection>;
|
|
8
8
|
getFieldValues(fieldName: string): Promise<any>;
|
|
9
9
|
loanRequest(data: any): Promise<any>;
|
|
10
|
+
getRequestStatus(data: any): Promise<any>;
|
|
10
11
|
}
|
|
11
12
|
export default LoanService;
|
|
@@ -89,6 +89,13 @@ var LoanService = /** @class */ (function (_super) {
|
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
};
|
|
92
|
+
LoanService.prototype.getRequestStatus = function (data) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
return [2 /*return*/, this.client.getRequestStatus(data)];
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
92
99
|
return LoanService;
|
|
93
100
|
}(services_1.RateService));
|
|
94
101
|
exports.default = LoanService;
|
|
@@ -122,7 +122,8 @@ var PackageService = /** @class */ (function () {
|
|
|
122
122
|
return __generator(this, function (_a) {
|
|
123
123
|
switch (_a.label) {
|
|
124
124
|
case 0:
|
|
125
|
-
if (localStorage
|
|
125
|
+
if (typeof localStorage !== 'undefined'
|
|
126
|
+
&& localStorage.getItem('supplierID') && localStorage.getItem('placementID')) {
|
|
126
127
|
criteria['SupplierID'] = localStorage.getItem('supplierID');
|
|
127
128
|
criteria['PlacementID'] = localStorage.getItem('placementID');
|
|
128
129
|
}
|
|
@@ -30,6 +30,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
exports.supplierPlacementTracker = void 0;
|
|
31
31
|
exports.supplierPlacementTracker = {
|
|
32
32
|
setParams: function () {
|
|
33
|
+
if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
33
36
|
var urlParams = new URLSearchParams(window.location.search);
|
|
34
37
|
var supplierID = urlParams.get('supplierID');
|
|
35
38
|
var placementID = urlParams.get('placementID');
|
|
@@ -39,16 +42,25 @@ exports.supplierPlacementTracker = {
|
|
|
39
42
|
}
|
|
40
43
|
},
|
|
41
44
|
removeParams: function () {
|
|
45
|
+
if (typeof localStorage === 'undefined') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
42
48
|
localStorage.removeItem('supplierID');
|
|
43
49
|
localStorage.removeItem('placementID');
|
|
44
50
|
},
|
|
45
51
|
getSubId: function () {
|
|
52
|
+
if (typeof window === 'undefined') {
|
|
53
|
+
return '';
|
|
54
|
+
}
|
|
46
55
|
var urlParams = new URLSearchParams(window.location.search);
|
|
47
56
|
var subID = urlParams.get('subid') || this.getCookie('ivanhoe_id');
|
|
48
57
|
return (subID && subID.includes('ivan')) ? subID : '';
|
|
49
58
|
},
|
|
50
59
|
getCookie: function (name) {
|
|
51
60
|
var e_1, _a;
|
|
61
|
+
if (typeof document === 'undefined') {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
52
64
|
var cookies = document.cookie.split(';');
|
|
53
65
|
try {
|
|
54
66
|
for (var cookies_1 = __values(cookies), cookies_1_1 = cookies_1.next(); !cookies_1_1.done; cookies_1_1 = cookies_1.next()) {
|