@vergelijkdirect/insurance-transmission-client 1.3.60 → 1.3.61
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 +268 -48
- package/package.json +1 -1
- package/src/js/interfaces/professions.interface.d.ts +0 -6
- package/src/js/interfaces/professions.interface.js +0 -2
- package/src/js/resources/liability-business.resource.d.ts +0 -8
- package/src/js/resources/liability-business.resource.js +0 -41
- package/src/js/services/liability-business.service.d.ts +0 -10
- package/src/js/services/liability-business.service.js +0 -88
package/README.md
CHANGED
|
@@ -1,79 +1,299 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Insurance Transmission Client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Partner-facing JavaScript/TypeScript client for the Vergelijkdirect Insurance Transmission API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
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
6
|
|
|
7
|
-
|
|
8
|
-
import LocalStorageAdapter from './adapters/local-storage.adapter';
|
|
9
|
-
|
|
10
|
-
const storage = new LocalStorageAdapter('insurances');
|
|
7
|
+
## What It Can Do
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
- Send one category request through the comparison API and collect rates from all enabled providers, such as Moneyview, RISK, Rolls, or Vergelijkdirect, based on the allowed partner/funnel configuration.
|
|
10
|
+
- Request rates for supported insurance categories and merge provider responses into a `RateCollection`.
|
|
11
|
+
- Read normalized rate data such as company name, price, coverage, documents, raw API data, and provider-specific additional coverages.
|
|
12
|
+
- Store selected rates in browser `localStorage` through `LocalStorageAdapter`, or through any custom adapter implementing `StorageInterface`.
|
|
13
|
+
- Create, retrieve, update, and recalculate comparison sessions.
|
|
14
|
+
- Calculate insurance packages and package discounts.
|
|
15
|
+
- Validate common data such as email/address, phone, IBAN, and zipcode.
|
|
16
|
+
- Retrieve supporting data such as vehicle details, license-plate checks, caravan catalog data, pet breeds/filters, KvK data, SBI data, loan files, Moneyview documents, Google reviews, and partner metadata.
|
|
17
|
+
|
|
18
|
+
## API Version
|
|
19
|
+
|
|
20
|
+
Use API `v2.1` for partner integrations:
|
|
13
21
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"Name": "Test",
|
|
21
|
-
"Initials": "B",
|
|
22
|
-
"NameInfix": "string",
|
|
23
|
-
"Gender": "M",
|
|
24
|
-
"Birthdate": "2000-01-01",
|
|
25
|
-
"Email": "test@hotmail.com",
|
|
26
|
-
"ZipCode": "0000xx",
|
|
27
|
-
"HouseNumber": 0,
|
|
28
|
-
"HouseNumberAddition": "string",
|
|
29
|
-
"IBAN": "NL43ABNA5239941823",
|
|
30
|
-
"MobileNumber": "0XXXXXXXXX",
|
|
31
|
-
"CustomerId": "string",
|
|
32
|
-
"CustomerIdExtern": "string",
|
|
22
|
+
```ts
|
|
23
|
+
const config = {
|
|
24
|
+
api: {
|
|
25
|
+
baseUrl: 'https://api.vergelijkdirect.com/api',
|
|
26
|
+
version: 'v2.1',
|
|
27
|
+
},
|
|
33
28
|
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Category comparison services build their base URL from this value:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
{baseUrl}/{version}/comparisons/{category}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
With the recommended configuration, moped rates are called through:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
https://api.vergelijkdirect.com/api/v2.1/comparisons/moped
|
|
41
|
+
```
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
let companyName = rate.getCompanyName();
|
|
37
|
-
let request = client.getRequest(summary);
|
|
43
|
+
Some helper resources still use fixed API paths in the client, for example `/v2/data`, `/v2/package`, `/v2/user`, `/v2/comparison`, `/v1` validation and legacy endpoints, `/partner`, and `/scripts/comparison-module`. If those backend endpoints are migrated to `v2.1`, update the related resource base URL before sharing a new client build.
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
## Installation
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
```bash
|
|
48
|
+
npm install @vergelijkdirect/insurance-transmission-client
|
|
42
49
|
```
|
|
43
50
|
|
|
51
|
+
For private distribution, install from the package registry or Git URL provided by Vergelijkdirect.
|
|
44
52
|
|
|
45
|
-
|
|
53
|
+
The published package entry points to compiled CommonJS files in `src/js`, so run `npm run compile` before packaging or publishing a new build.
|
|
46
54
|
|
|
47
|
-
|
|
48
|
-
Node has own fetch for example which used as polyfill.
|
|
49
|
-
So we need to be able sometime to test not only from cli(node) environment but also from browser during development
|
|
55
|
+
## Quick Start
|
|
50
56
|
|
|
51
|
-
|
|
57
|
+
Initialize the client before creating API services:
|
|
52
58
|
|
|
59
|
+
```ts
|
|
60
|
+
import {
|
|
61
|
+
InsuranceTransmissionClient,
|
|
62
|
+
LocalStorageAdapter,
|
|
63
|
+
MopedService,
|
|
64
|
+
} from '@vergelijkdirect/insurance-transmission-client';
|
|
65
|
+
|
|
66
|
+
const storage = new LocalStorageAdapter('itc:selected-rates');
|
|
67
|
+
const client = new InsuranceTransmissionClient(storage);
|
|
68
|
+
|
|
69
|
+
await client.configure({
|
|
70
|
+
api: {
|
|
71
|
+
baseUrl: 'https://api.vergelijkdirect.com/api',
|
|
72
|
+
version: 'v2.1',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const mopedService = new MopedService();
|
|
77
|
+
|
|
78
|
+
const rates = await mopedService.getRates({
|
|
79
|
+
CommencingDate: '2026-06-09',
|
|
80
|
+
LicensePlate: 'D251LG',
|
|
81
|
+
TypeOfMoped: '63',
|
|
82
|
+
MopedSignCode: '4872',
|
|
83
|
+
Coverage: '1',
|
|
84
|
+
CatalogValue: 1099,
|
|
85
|
+
ValueAccessories: 0,
|
|
86
|
+
DriverZipCode: '5803DE',
|
|
87
|
+
DriverHouseNumber: '41',
|
|
88
|
+
DriverBirthdate: '1980-06-16',
|
|
89
|
+
ClaimFreeYears: '0',
|
|
90
|
+
BrokerID: '05250',
|
|
91
|
+
ReturnProvision: '0,00',
|
|
92
|
+
IncludeXml: false,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const selectedRate = rates.first();
|
|
96
|
+
|
|
97
|
+
console.log(selectedRate.getCompanyName());
|
|
98
|
+
console.log(selectedRate.getPrice());
|
|
99
|
+
console.log(selectedRate.getCoverage());
|
|
100
|
+
|
|
101
|
+
client.saveNew(selectedRate);
|
|
53
102
|
```
|
|
54
|
-
|
|
103
|
+
|
|
104
|
+
Use complete request payloads from the API contract for production calls. Example development payloads are available in `src/requests`.
|
|
105
|
+
|
|
106
|
+
## Using the Service Factory
|
|
107
|
+
|
|
108
|
+
When the category is dynamic, use `ApiServiceFactory`:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import {
|
|
112
|
+
ApiServiceFactory,
|
|
113
|
+
InsuranceTransmissionClient,
|
|
114
|
+
LocalStorageAdapter,
|
|
115
|
+
} from '@vergelijkdirect/insurance-transmission-client';
|
|
116
|
+
|
|
117
|
+
const client = new InsuranceTransmissionClient(new LocalStorageAdapter('itc'));
|
|
118
|
+
|
|
119
|
+
await client.configure({
|
|
120
|
+
api: {
|
|
121
|
+
baseUrl: 'https://api.vergelijkdirect.com/api',
|
|
122
|
+
version: 'v2.1',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const category = 'car';
|
|
127
|
+
const service = ApiServiceFactory.get(category);
|
|
128
|
+
const rates = await service.getRates(requestPayload);
|
|
129
|
+
|
|
130
|
+
for (const rate of rates) {
|
|
131
|
+
console.log(rate.getCompanyName(), rate.getPrice());
|
|
132
|
+
}
|
|
55
133
|
```
|
|
56
134
|
|
|
57
|
-
|
|
135
|
+
Supported factory categories are:
|
|
58
136
|
|
|
137
|
+
```text
|
|
138
|
+
moped, motor, pet, home, caravan, bike, household, liability,
|
|
139
|
+
legal-assistance, car-business, car, travel, package, housing, loan
|
|
59
140
|
```
|
|
60
|
-
|
|
141
|
+
|
|
142
|
+
Most of these services expose `getRates`. `PackageService` is returned by the same factory, but uses package-specific methods such as `calculatePackage`, `calculatePackages`, `requestPackage`, and `annualDiscount`.
|
|
143
|
+
|
|
144
|
+
## Rate Results
|
|
145
|
+
|
|
146
|
+
Most rate calls return a `RateCollection`.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
const count = rates.count();
|
|
150
|
+
const first = rates.first();
|
|
151
|
+
const last = rates.last();
|
|
152
|
+
const all = rates.all();
|
|
153
|
+
const rawRates = rates.toObject();
|
|
154
|
+
|
|
155
|
+
for (const rate of rates) {
|
|
156
|
+
const company = rate.getCompanyName();
|
|
157
|
+
const price = rate.getPrice();
|
|
158
|
+
const coverage = rate.getCoverage();
|
|
159
|
+
const raw = rate.getData();
|
|
160
|
+
const documents = await rate.getDocuments();
|
|
161
|
+
|
|
162
|
+
console.log(company, price, coverage, raw, documents.getConditionUrls());
|
|
163
|
+
}
|
|
61
164
|
```
|
|
62
165
|
|
|
63
|
-
|
|
64
|
-
Change code in comparison.webtest.js, change request if needed or create new one in directory (src/tests/browser/requests)
|
|
166
|
+
Provider-specific rate models can expose additional helper methods such as `getAdditionalCoverages`. For strongly typed integrations, the matching service method can also be used directly, for example `getRiskAdditionalCoverages`, `getMoneyviewAdditionalCoverages`, or `getVergelijkdirectAdditionalCoverages`.
|
|
65
167
|
|
|
66
|
-
|
|
168
|
+
## Selected Rate Storage
|
|
169
|
+
|
|
170
|
+
`InsuranceTransmissionClient` stores selected rate data through the adapter passed to its constructor.
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
client.save(rate); // append a selected rate for its category
|
|
174
|
+
client.saveNew(rate); // replace previous selected rates for that category
|
|
175
|
+
client.get('moped').first(); // read selected moped rate
|
|
176
|
+
client.get('moped').count(); // count selected moped rates
|
|
177
|
+
client.remove('moped'); // clear selected moped rates
|
|
67
178
|
```
|
|
68
|
-
|
|
179
|
+
|
|
180
|
+
`LocalStorageAdapter` is browser-oriented and uses `window.localStorage`. For Node, SSR, or custom persistence, provide an adapter with `get`, `save`, `put`, `remove`, and `all` methods.
|
|
181
|
+
|
|
182
|
+
## Supported Categories and Providers
|
|
183
|
+
|
|
184
|
+
The comparison module can override the enabled provider list per funnel. If no remote configuration is available, the client falls back to these built-in providers:
|
|
185
|
+
|
|
186
|
+
| Category | Built-in providers | Notes |
|
|
187
|
+
| --- | --- | --- |
|
|
188
|
+
| `moped` | risk, moneyview, vergelijkdirect, enra, unigarant | Rates, coverage comparison, vehicle find/check, additional coverages |
|
|
189
|
+
| `motor` | risk, moneyview, rolls, voogd | Rates, coverage comparison, vehicle find/check, additional coverages |
|
|
190
|
+
| `car` | risk, moneyview, rolls, ominimo, voogd | Rates, vehicle find/check, additional coverages |
|
|
191
|
+
| `car-business` | risk, rolls, voogd | Rates, Rolls business info, additional coverages |
|
|
192
|
+
| `bike` | risk, laka, enra, vergelijkdirect, fietszeker | Rates and Enra rate lookup |
|
|
193
|
+
| `caravan` | risk | Rates, coverage comparison, brands, models, types, catalog price |
|
|
194
|
+
| `pet` | petsecur | Rates, additional coverages, breeds, filters |
|
|
195
|
+
| `home` | risk, moneyview, rolls | Rates, home amount, find, addition |
|
|
196
|
+
| `household` | risk, moneyview, rolls | Rates and insured amount |
|
|
197
|
+
| `housing` | risk, moneyview, rolls | Rates and direct Moneyview rates |
|
|
198
|
+
| `liability` | risk, moneyview, nn | Rates |
|
|
199
|
+
| `legal-assistance` | risk, moneyview, vergelijkdirect | Rates and additional coverages |
|
|
200
|
+
| `travel` | risk, vergelijkdirect, moneyview | Rates and additional coverages |
|
|
201
|
+
| `loan` | dkm | Rates, field values, loan request |
|
|
202
|
+
|
|
203
|
+
## Other Services
|
|
204
|
+
|
|
205
|
+
| Service | Purpose |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| `ComparisonService` | Create, get, update, and persist comparison sessions |
|
|
208
|
+
| `PackageService` | Calculate packages, discounts, annual discounts, package requests, and package saves |
|
|
209
|
+
| `DataService` | Vehicle lookup/checks, IBAN validation, maximum loan amount, loan documents, KvK search/profile/SBI, Kickbite tracking |
|
|
210
|
+
| `DataValidationService` | Email/address, phone, IBAN, and zipcode validation |
|
|
211
|
+
| `DocumentService` | Moneyview document lists and document models |
|
|
212
|
+
| `PartnerService` | Partner info and partner API version |
|
|
213
|
+
| `ComparisonModuleService` | Comparison-module initialization data and script source |
|
|
214
|
+
| `GoogleService` | Google reviews |
|
|
215
|
+
| `UserService` | User creation |
|
|
216
|
+
| `V1Service` | Legacy pet, health, bike, and car endpoints |
|
|
217
|
+
|
|
218
|
+
## Comparison Sessions
|
|
219
|
+
|
|
220
|
+
After `client.configure(...)`, comparison sessions can be loaded and updated:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
import { ComparisonService } from '@vergelijkdirect/insurance-transmission-client';
|
|
224
|
+
|
|
225
|
+
const comparisonService = new ComparisonService();
|
|
226
|
+
|
|
227
|
+
const comparison = await comparisonService.get('65a7942e29a57');
|
|
228
|
+
const data = comparison.getData();
|
|
229
|
+
const user = comparison.getUser();
|
|
230
|
+
|
|
231
|
+
console.log(comparison.getId(), comparison.getFunnel(), data.all(), user);
|
|
232
|
+
|
|
233
|
+
const updatedComparison = await comparisonService.update(comparison);
|
|
69
234
|
```
|
|
70
|
-
|
|
235
|
+
|
|
236
|
+
When a comparison is loaded, the client stores the comparison funnel in the injector. Category calls made afterwards include the `X-Comparison-Funnel` header so the API can resolve funnel-specific provider configuration.
|
|
237
|
+
|
|
238
|
+
## Development
|
|
239
|
+
|
|
240
|
+
Install dependencies:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
npm install
|
|
71
244
|
```
|
|
72
|
-
|
|
245
|
+
|
|
246
|
+
Run the TypeScript build:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
npm run compile
|
|
73
250
|
```
|
|
74
251
|
|
|
75
|
-
|
|
252
|
+
Run tests:
|
|
76
253
|
|
|
254
|
+
```bash
|
|
255
|
+
npm test
|
|
77
256
|
```
|
|
257
|
+
|
|
258
|
+
Run one Jest test by name:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
78
261
|
npm run test -- api --testNamePattern="VehicleData"
|
|
79
|
-
```
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Browser Testing
|
|
265
|
+
|
|
266
|
+
Some behavior should be verified in a real browser because browser `fetch`, CORS, and `localStorage` can differ from the Node/Jest environment.
|
|
267
|
+
|
|
268
|
+
Install Browserify if needed:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
npm install -g browserify
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Compile the client and build a browser test bundle:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
npm run compile
|
|
278
|
+
npm run browserify --arg=comparison
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Open `src/tests/browser/index.html` in a browser, open the console, and call:
|
|
282
|
+
|
|
283
|
+
```js
|
|
284
|
+
makeItcCall();
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Change the relevant `src/tests/browser/*.webtest.js` file or JSON payload in `src/tests/browser/requests` when testing a specific flow.
|
|
288
|
+
|
|
289
|
+
## Partner Integration Checklist
|
|
290
|
+
|
|
291
|
+
- Configure `baseUrl` for the target API environment.
|
|
292
|
+
- Configure `api.version` as `v2.1`.
|
|
293
|
+
- Call `client.configure(...)` before constructing API services.
|
|
294
|
+
- Use complete payloads from the API contract, with category-specific PascalCase fields.
|
|
295
|
+
- Pass partner/broker fields required by the API, such as `BrokerID`, `PartnerId`, and provision/payment fields where applicable.
|
|
296
|
+
- Use `RateCollection` and rate model helpers for display and selection.
|
|
297
|
+
- Store selected rates through `saveNew` when only one selected rate per category should exist.
|
|
298
|
+
- Browser integrations must provide `window`, `localStorage`, and a CORS-enabled API endpoint.
|
|
299
|
+
- Before publishing to partners, run `npm test` and `npm run compile`.
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AdditionalCoveragesRequestInterface } from "../interfaces";
|
|
2
|
-
import CategoriesResource from "./categories.resource";
|
|
3
|
-
declare class BusinessLiabilityResource extends CategoriesResource {
|
|
4
|
-
protected getCategory(): string;
|
|
5
|
-
protected getAvailableServices(): string[];
|
|
6
|
-
getRiskAdditionalCoverages(data: AdditionalCoveragesRequestInterface): Promise<any>;
|
|
7
|
-
}
|
|
8
|
-
export default BusinessLiabilityResource;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
var categories_resource_1 = require("./categories.resource");
|
|
19
|
-
var BusinessLiabilityResource = /** @class */ (function (_super) {
|
|
20
|
-
__extends(BusinessLiabilityResource, _super);
|
|
21
|
-
function BusinessLiabilityResource() {
|
|
22
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
-
}
|
|
24
|
-
BusinessLiabilityResource.prototype.getCategory = function () {
|
|
25
|
-
return 'liability-business';
|
|
26
|
-
};
|
|
27
|
-
BusinessLiabilityResource.prototype.getAvailableServices = function () {
|
|
28
|
-
return [
|
|
29
|
-
'risk',
|
|
30
|
-
];
|
|
31
|
-
};
|
|
32
|
-
BusinessLiabilityResource.prototype.getRiskAdditionalCoverages = function (data) {
|
|
33
|
-
return this.http({
|
|
34
|
-
method: 'post',
|
|
35
|
-
url: '/risk/additional_coverages',
|
|
36
|
-
data: data,
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
return BusinessLiabilityResource;
|
|
40
|
-
}(categories_resource_1.default));
|
|
41
|
-
exports.default = BusinessLiabilityResource;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RateCollection } from "../models";
|
|
2
|
-
import { AdditionalCoverageInterface, CalculateRatesInterface } from "../interfaces";
|
|
3
|
-
import { RateService } from "./index";
|
|
4
|
-
declare class BusinessLiabilityService extends RateService implements CalculateRatesInterface {
|
|
5
|
-
private client;
|
|
6
|
-
constructor();
|
|
7
|
-
getRates(data: any): Promise<RateCollection>;
|
|
8
|
-
getRiskAdditionalCoverages(data: any): Promise<AdditionalCoverageInterface[] | []>;
|
|
9
|
-
}
|
|
10
|
-
export default BusinessLiabilityService;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
var resources_1 = require("../resources");
|
|
55
|
-
var models_1 = require("../models");
|
|
56
|
-
var utils_1 = require("../utils");
|
|
57
|
-
var index_1 = require("./index");
|
|
58
|
-
var BusinessLiabilityService = /** @class */ (function (_super) {
|
|
59
|
-
__extends(BusinessLiabilityService, _super);
|
|
60
|
-
function BusinessLiabilityService() {
|
|
61
|
-
var _this = _super.call(this) || this;
|
|
62
|
-
_this.client = new resources_1.BusinessLiabilityResource();
|
|
63
|
-
return _this;
|
|
64
|
-
}
|
|
65
|
-
BusinessLiabilityService.prototype.getRates = function (data) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var services, rates;
|
|
68
|
-
return __generator(this, function (_a) {
|
|
69
|
-
switch (_a.label) {
|
|
70
|
-
case 0: return [4 /*yield*/, this.client.getRates(data)];
|
|
71
|
-
case 1:
|
|
72
|
-
services = _a.sent();
|
|
73
|
-
rates = this.handleRates(services);
|
|
74
|
-
return [2 /*return*/, new models_1.RateCollection('liability-business', rates.sort(utils_1.sortBy.price))];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
BusinessLiabilityService.prototype.getRiskAdditionalCoverages = function (data) {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
-
return __generator(this, function (_a) {
|
|
82
|
-
return [2 /*return*/, this.client.getRiskAdditionalCoverages(data)];
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
return BusinessLiabilityService;
|
|
87
|
-
}(index_1.RateService));
|
|
88
|
-
exports.default = BusinessLiabilityService;
|