@instabrain-sdks/api-client 2.6.0 → 2.8.0
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 +540 -74
- package/dist/client/instabrain-client.d.ts +53 -13
- package/dist/client/instabrain-client.js +53 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/services/adb.service.d.ts +1 -1
- package/dist/services/adb.service.js +1 -1
- package/dist/services/application.service.d.ts +9 -2
- package/dist/services/application.service.js +9 -2
- package/dist/services/finalexpense.service.d.ts +1 -1
- package/dist/services/finalexpense.service.js +1 -1
- package/dist/services/gigdb.service.d.ts +19 -8
- package/dist/services/gigdb.service.js +20 -9
- package/dist/services/ibterm.service.d.ts +17 -5
- package/dist/services/ibterm.service.js +17 -5
- package/dist/services/pureterm.service.d.ts +12 -4
- package/dist/services/pureterm.service.js +12 -4
- package/dist/services/reports.service.d.ts +3 -0
- package/dist/services/reports.service.js +3 -0
- package/dist/types/application.types.d.ts +27 -5
- package/dist/types/constants.d.ts +11 -0
- package/dist/types/constants.js +12 -1
- package/dist/types/enums.d.ts +17 -4
- package/dist/types/enums.js +18 -4
- package/dist/types/errors.d.ts +4 -4
- package/dist/types/errors.js +3 -2
- package/dist/types/gigdb.types.d.ts +34 -7
- package/dist/types/ibterm.types.d.ts +9 -0
- package/dist/types/index.d.ts +1 -7
- package/dist/types/index.js +1 -0
- package/dist/types/reports.types.d.ts +78 -18
- package/dist/types/reports.types.js +29 -2
- package/dist/types/webhook.types.d.ts +55 -0
- package/dist/types/webhook.types.js +3 -0
- package/dist/utils/webhook-signature.d.ts +72 -0
- package/dist/utils/webhook-signature.js +172 -0
- package/package.json +19 -13
|
@@ -48,9 +48,20 @@ export declare class InstaBrainClient {
|
|
|
48
48
|
*/
|
|
49
49
|
getQuote(quoteRequest: ThirdPartyQuoteReq): Promise<ThirdPartyQuoteResp>;
|
|
50
50
|
/**
|
|
51
|
-
* Start an
|
|
51
|
+
* Start an application from a quote via the generic
|
|
52
|
+
* `POST /api/ThirdPartyStartApp/start-application` endpoint.
|
|
53
|
+
*
|
|
54
|
+
* Returns `opportunityId` plus `agentLink`, `applicantLink`, and `eAppAgentLink`.
|
|
55
|
+
* Pass `proCode` to start a specific product variant. For IB Term and Pure Term,
|
|
56
|
+
* InstaBrain recommends the dedicated `startIBTermApplication()` /
|
|
57
|
+
* `startPureTermApplication()` instead.
|
|
58
|
+
*
|
|
59
|
+
* Optionally opt in to application-status webhooks with
|
|
60
|
+
* `webhookRegistrationDetails`, and verify each delivery with
|
|
61
|
+
* `verifyWebhookSignature()`.
|
|
62
|
+
*
|
|
52
63
|
* @param applicationRequest - The application request parameters
|
|
53
|
-
* @returns Promise with the application
|
|
64
|
+
* @returns Promise with `opportunityId` and the application links
|
|
54
65
|
*/
|
|
55
66
|
startApplication(applicationRequest: ThirdPartyStartApplicationReq): Promise<ThirdPartyStartAppResp>;
|
|
56
67
|
/**
|
|
@@ -61,6 +72,10 @@ export declare class InstaBrainClient {
|
|
|
61
72
|
getProspects(request: AgentPortalReq): Promise<ThirdPartyProspectsResp>;
|
|
62
73
|
/**
|
|
63
74
|
* Get sales data - completed/sold policies
|
|
75
|
+
*
|
|
76
|
+
* Each sale returns the rate class in its own `rateClass` field; `applicationStatus`
|
|
77
|
+
* holds only the current status (After-Sale status when received) and, when one
|
|
78
|
+
* applies, ` : {Assessment Factor}` - e.g. `"Approved : Drug Use"`.
|
|
64
79
|
* @param request - The agent portal request with filters, pagination, etc.
|
|
65
80
|
* @returns Promise with sales data including total premium amount
|
|
66
81
|
*/
|
|
@@ -85,12 +100,21 @@ export declare class InstaBrainClient {
|
|
|
85
100
|
*/
|
|
86
101
|
startGigdbApplication(request: ThirdPartyGigdbAppReq): Promise<ThirdPartyStartAppResp>;
|
|
87
102
|
/**
|
|
88
|
-
* Save EFT payment details for
|
|
89
|
-
*
|
|
90
|
-
*
|
|
103
|
+
* Save EFT (bank account) payment details for an application. Shared across
|
|
104
|
+
* all products. Call after start-application and, for full-flow products,
|
|
105
|
+
* before the SecureSign flow.
|
|
106
|
+
*
|
|
107
|
+
* `accountHolderName` is required: at most 100 characters and, in practice,
|
|
108
|
+
* about 35 under the name format rules. `routingNumber` is 9 digits;
|
|
109
|
+
* `accountNumber` is 4–17.
|
|
91
110
|
*
|
|
92
|
-
* `
|
|
93
|
-
*
|
|
111
|
+
* **Pay Later:** send `payLaterDate` (`yyyy-MM-dd`, date only) to schedule the
|
|
112
|
+
* draft; omit it to draft immediately. The date must be after today in **UTC**
|
|
113
|
+
* and no later than the earlier of the pay later window (30 days by default)
|
|
114
|
+
* and the applicant's next birthday (the birthday itself is allowed); nothing
|
|
115
|
+
* is accepted on the applicant's birthday (UTC date). Failures return
|
|
116
|
+
* `InvalidPaymentScheduledDate`, or `PayLaterNotAvailable` when Pay Later is
|
|
117
|
+
* switched off on the platform; both carry `value.fields.PayLaterDate`.
|
|
94
118
|
*
|
|
95
119
|
* EFT and credit card are mutually exclusive per opportunity — a successful
|
|
96
120
|
* payment that already exists returns `PaymentAlreadyMade`, and after a
|
|
@@ -98,8 +122,10 @@ export declare class InstaBrainClient {
|
|
|
98
122
|
* `EftPaymentAlreadyCompleted`. A successful save satisfies the payment
|
|
99
123
|
* prerequisite for `finalSubmit()`; no charge runs again at final submit.
|
|
100
124
|
*
|
|
101
|
-
* @param request - The EFT payment request with opportunityId
|
|
102
|
-
* @returns
|
|
125
|
+
* @param request - The EFT payment request with opportunityId, bank account details, and optional payLaterDate
|
|
126
|
+
* @returns Resolves on success; failures throw. The declared type is `boolean`
|
|
127
|
+
* for backward compatibility — at runtime the value is the API's per-field
|
|
128
|
+
* validation result object, which is truthy.
|
|
103
129
|
*/
|
|
104
130
|
saveEftPayment(request: ThirdPartyEftPaymentReq): Promise<boolean>;
|
|
105
131
|
/**
|
|
@@ -181,9 +207,16 @@ export declare class InstaBrainClient {
|
|
|
181
207
|
/**
|
|
182
208
|
* Start an IB Term application from a prior IB Term quote.
|
|
183
209
|
*
|
|
184
|
-
* `isDeclined: true` is a valid success response
|
|
210
|
+
* `isDeclined: true` is a valid success response, not an error. Read it together
|
|
211
|
+
* with `opportunityId`: an empty or all-zero id is a knockout — no application
|
|
212
|
+
* exists, so stop. A real id means the application exists but was declined —
|
|
213
|
+
* keep the id and any returned links.
|
|
185
214
|
* IB Term does NOT use `ApplicationLimitReached` (that applies to ADB/GIGDB only).
|
|
186
215
|
*
|
|
216
|
+
* Optionally opt in to application-status webhooks with
|
|
217
|
+
* `webhookRegistrationDetails`, and verify each delivery with
|
|
218
|
+
* `verifyWebhookSignature()`.
|
|
219
|
+
*
|
|
187
220
|
* @param request - The IB Term application request payload
|
|
188
221
|
* @returns Promise with opportunityId, isDeclined flag, and isQuoteChanged
|
|
189
222
|
*/
|
|
@@ -252,16 +285,23 @@ export declare class InstaBrainClient {
|
|
|
252
285
|
/**
|
|
253
286
|
* Start a Pure Term application from a prior Pure Term quote.
|
|
254
287
|
*
|
|
255
|
-
* Dedicated endpoint — separate from the generic `startApplication()
|
|
256
|
-
*
|
|
288
|
+
* Dedicated endpoint — separate from the generic `startApplication()`. Do not
|
|
289
|
+
* substitute one for the other.
|
|
257
290
|
*
|
|
258
|
-
* `isDeclined: true` is a valid success response
|
|
291
|
+
* `isDeclined: true` is a valid success response, not an error. Read it together
|
|
292
|
+
* with `opportunityId`: an empty or all-zero id is a knockout — no application
|
|
293
|
+
* exists, so stop. A real id means the application exists but was declined —
|
|
294
|
+
* keep the id and any returned links.
|
|
259
295
|
* Pure Term does NOT use `ApplicationLimitReached` (ADB / GIGDB / Final Expense
|
|
260
296
|
* only). `childRiderInfo` must be sent only when the Dependent Child Rider was
|
|
261
297
|
* on the quote. After a non-declined start, hand off via the returned links —
|
|
262
298
|
* do not wire this `opportunityId` into SecureSign, `finalSubmit()`, or the
|
|
263
299
|
* credit-card iframe.
|
|
264
300
|
*
|
|
301
|
+
* Optionally opt in to application-status webhooks with
|
|
302
|
+
* `webhookRegistrationDetails`, and verify each delivery with
|
|
303
|
+
* `verifyWebhookSignature()`.
|
|
304
|
+
*
|
|
265
305
|
* @param request - The Pure Term application request payload
|
|
266
306
|
* @returns Promise with opportunityId, links, isDeclined flag, and isQuoteChanged
|
|
267
307
|
*/
|
|
@@ -63,9 +63,20 @@ class InstaBrainClient {
|
|
|
63
63
|
return this.quote.getQuote(quoteRequest);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Start an
|
|
66
|
+
* Start an application from a quote via the generic
|
|
67
|
+
* `POST /api/ThirdPartyStartApp/start-application` endpoint.
|
|
68
|
+
*
|
|
69
|
+
* Returns `opportunityId` plus `agentLink`, `applicantLink`, and `eAppAgentLink`.
|
|
70
|
+
* Pass `proCode` to start a specific product variant. For IB Term and Pure Term,
|
|
71
|
+
* InstaBrain recommends the dedicated `startIBTermApplication()` /
|
|
72
|
+
* `startPureTermApplication()` instead.
|
|
73
|
+
*
|
|
74
|
+
* Optionally opt in to application-status webhooks with
|
|
75
|
+
* `webhookRegistrationDetails`, and verify each delivery with
|
|
76
|
+
* `verifyWebhookSignature()`.
|
|
77
|
+
*
|
|
67
78
|
* @param applicationRequest - The application request parameters
|
|
68
|
-
* @returns Promise with the application
|
|
79
|
+
* @returns Promise with `opportunityId` and the application links
|
|
69
80
|
*/
|
|
70
81
|
async startApplication(applicationRequest) {
|
|
71
82
|
return this.application.startApplication(applicationRequest);
|
|
@@ -80,6 +91,10 @@ class InstaBrainClient {
|
|
|
80
91
|
}
|
|
81
92
|
/**
|
|
82
93
|
* Get sales data - completed/sold policies
|
|
94
|
+
*
|
|
95
|
+
* Each sale returns the rate class in its own `rateClass` field; `applicationStatus`
|
|
96
|
+
* holds only the current status (After-Sale status when received) and, when one
|
|
97
|
+
* applies, ` : {Assessment Factor}` - e.g. `"Approved : Drug Use"`.
|
|
83
98
|
* @param request - The agent portal request with filters, pagination, etc.
|
|
84
99
|
* @returns Promise with sales data including total premium amount
|
|
85
100
|
*/
|
|
@@ -112,12 +127,21 @@ class InstaBrainClient {
|
|
|
112
127
|
return this.gigdb.startApplication(request);
|
|
113
128
|
}
|
|
114
129
|
/**
|
|
115
|
-
* Save EFT payment details for
|
|
116
|
-
*
|
|
117
|
-
*
|
|
130
|
+
* Save EFT (bank account) payment details for an application. Shared across
|
|
131
|
+
* all products. Call after start-application and, for full-flow products,
|
|
132
|
+
* before the SecureSign flow.
|
|
133
|
+
*
|
|
134
|
+
* `accountHolderName` is required: at most 100 characters and, in practice,
|
|
135
|
+
* about 35 under the name format rules. `routingNumber` is 9 digits;
|
|
136
|
+
* `accountNumber` is 4–17.
|
|
118
137
|
*
|
|
119
|
-
* `
|
|
120
|
-
*
|
|
138
|
+
* **Pay Later:** send `payLaterDate` (`yyyy-MM-dd`, date only) to schedule the
|
|
139
|
+
* draft; omit it to draft immediately. The date must be after today in **UTC**
|
|
140
|
+
* and no later than the earlier of the pay later window (30 days by default)
|
|
141
|
+
* and the applicant's next birthday (the birthday itself is allowed); nothing
|
|
142
|
+
* is accepted on the applicant's birthday (UTC date). Failures return
|
|
143
|
+
* `InvalidPaymentScheduledDate`, or `PayLaterNotAvailable` when Pay Later is
|
|
144
|
+
* switched off on the platform; both carry `value.fields.PayLaterDate`.
|
|
121
145
|
*
|
|
122
146
|
* EFT and credit card are mutually exclusive per opportunity — a successful
|
|
123
147
|
* payment that already exists returns `PaymentAlreadyMade`, and after a
|
|
@@ -125,8 +149,10 @@ class InstaBrainClient {
|
|
|
125
149
|
* `EftPaymentAlreadyCompleted`. A successful save satisfies the payment
|
|
126
150
|
* prerequisite for `finalSubmit()`; no charge runs again at final submit.
|
|
127
151
|
*
|
|
128
|
-
* @param request - The EFT payment request with opportunityId
|
|
129
|
-
* @returns
|
|
152
|
+
* @param request - The EFT payment request with opportunityId, bank account details, and optional payLaterDate
|
|
153
|
+
* @returns Resolves on success; failures throw. The declared type is `boolean`
|
|
154
|
+
* for backward compatibility — at runtime the value is the API's per-field
|
|
155
|
+
* validation result object, which is truthy.
|
|
130
156
|
*/
|
|
131
157
|
async saveEftPayment(request) {
|
|
132
158
|
return this.gigdb.saveEftPayment(request);
|
|
@@ -230,9 +256,16 @@ class InstaBrainClient {
|
|
|
230
256
|
/**
|
|
231
257
|
* Start an IB Term application from a prior IB Term quote.
|
|
232
258
|
*
|
|
233
|
-
* `isDeclined: true` is a valid success response
|
|
259
|
+
* `isDeclined: true` is a valid success response, not an error. Read it together
|
|
260
|
+
* with `opportunityId`: an empty or all-zero id is a knockout — no application
|
|
261
|
+
* exists, so stop. A real id means the application exists but was declined —
|
|
262
|
+
* keep the id and any returned links.
|
|
234
263
|
* IB Term does NOT use `ApplicationLimitReached` (that applies to ADB/GIGDB only).
|
|
235
264
|
*
|
|
265
|
+
* Optionally opt in to application-status webhooks with
|
|
266
|
+
* `webhookRegistrationDetails`, and verify each delivery with
|
|
267
|
+
* `verifyWebhookSignature()`.
|
|
268
|
+
*
|
|
236
269
|
* @param request - The IB Term application request payload
|
|
237
270
|
* @returns Promise with opportunityId, isDeclined flag, and isQuoteChanged
|
|
238
271
|
*/
|
|
@@ -312,16 +345,23 @@ class InstaBrainClient {
|
|
|
312
345
|
/**
|
|
313
346
|
* Start a Pure Term application from a prior Pure Term quote.
|
|
314
347
|
*
|
|
315
|
-
* Dedicated endpoint — separate from the generic `startApplication()
|
|
316
|
-
*
|
|
348
|
+
* Dedicated endpoint — separate from the generic `startApplication()`. Do not
|
|
349
|
+
* substitute one for the other.
|
|
317
350
|
*
|
|
318
|
-
* `isDeclined: true` is a valid success response
|
|
351
|
+
* `isDeclined: true` is a valid success response, not an error. Read it together
|
|
352
|
+
* with `opportunityId`: an empty or all-zero id is a knockout — no application
|
|
353
|
+
* exists, so stop. A real id means the application exists but was declined —
|
|
354
|
+
* keep the id and any returned links.
|
|
319
355
|
* Pure Term does NOT use `ApplicationLimitReached` (ADB / GIGDB / Final Expense
|
|
320
356
|
* only). `childRiderInfo` must be sent only when the Dependent Child Rider was
|
|
321
357
|
* on the quote. After a non-declined start, hand off via the returned links —
|
|
322
358
|
* do not wire this `opportunityId` into SecureSign, `finalSubmit()`, or the
|
|
323
359
|
* credit-card iframe.
|
|
324
360
|
*
|
|
361
|
+
* Optionally opt in to application-status webhooks with
|
|
362
|
+
* `webhookRegistrationDetails`, and verify each delivery with
|
|
363
|
+
* `verifyWebhookSignature()`.
|
|
364
|
+
*
|
|
325
365
|
* @param request - The Pure Term application request payload
|
|
326
366
|
* @returns Promise with opportunityId, links, isDeclined flag, and isQuoteChanged
|
|
327
367
|
*/
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,12 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.default = exports.InstaBrainClient = void 0;
|
|
17
|
+
exports.default = exports.WEBHOOK_HEADERS = exports.verifyWebhookSignature = exports.InstaBrainClient = void 0;
|
|
18
18
|
// Main exports
|
|
19
19
|
var instabrain_client_1 = require("./client/instabrain-client");
|
|
20
20
|
Object.defineProperty(exports, "InstaBrainClient", { enumerable: true, get: function () { return instabrain_client_1.InstaBrainClient; } });
|
|
21
21
|
// Type exports
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
|
+
// Webhook signature verification (receiving side of application-status webhooks)
|
|
24
|
+
var webhook_signature_1 = require("./utils/webhook-signature");
|
|
25
|
+
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return webhook_signature_1.verifyWebhookSignature; } });
|
|
26
|
+
Object.defineProperty(exports, "WEBHOOK_HEADERS", { enumerable: true, get: function () { return webhook_signature_1.WEBHOOK_HEADERS; } });
|
|
23
27
|
// Default export
|
|
24
28
|
var instabrain_client_2 = require("./client/instabrain-client");
|
|
25
29
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return instabrain_client_2.InstaBrainClient; } });
|
|
@@ -9,7 +9,7 @@ import { ThirdPartyAdbQuoteRequest, ThirdPartyAdbUpdateQuoteReq, ThirdPartyAdbAp
|
|
|
9
9
|
* Flow:
|
|
10
10
|
* 1. getQuote() → quoteResponseId
|
|
11
11
|
* 2. startApplication() → opportunityId (or isDeclined=true)
|
|
12
|
-
* 3. GigdbService.saveEftPayment() →
|
|
12
|
+
* 3. GigdbService.saveEftPayment() → resolves on success (shared endpoint — use via InstaBrainClient.saveEftPayment)
|
|
13
13
|
* 4. SecureSign flow → (shared — use SecureSignService)
|
|
14
14
|
* 5. Final Submit → (shared — use ApplicationService.finalSubmit)
|
|
15
15
|
*/
|
|
@@ -10,7 +10,7 @@ const base_service_1 = require("./base.service");
|
|
|
10
10
|
* Flow:
|
|
11
11
|
* 1. getQuote() → quoteResponseId
|
|
12
12
|
* 2. startApplication() → opportunityId (or isDeclined=true)
|
|
13
|
-
* 3. GigdbService.saveEftPayment() →
|
|
13
|
+
* 3. GigdbService.saveEftPayment() → resolves on success (shared endpoint — use via InstaBrainClient.saveEftPayment)
|
|
14
14
|
* 4. SecureSign flow → (shared — use SecureSignService)
|
|
15
15
|
* 5. Final Submit → (shared — use ApplicationService.finalSubmit)
|
|
16
16
|
*/
|
|
@@ -7,9 +7,16 @@ import { ThirdPartyStartApplicationReq, ThirdPartyStartAppResp, ThirdPartyFinalS
|
|
|
7
7
|
export declare class ApplicationService extends BaseService {
|
|
8
8
|
constructor(httpClient: HttpClient);
|
|
9
9
|
/**
|
|
10
|
-
* Start an
|
|
10
|
+
* Start an application via the generic
|
|
11
|
+
* `POST /api/ThirdPartyStartApp/start-application` endpoint.
|
|
12
|
+
*
|
|
13
|
+
* Accepts optional `webhookRegistrationDetails` to opt in to application-status
|
|
14
|
+
* webhooks. When sent, both `callbackUrl` (absolute HTTPS) and `secretKey` are
|
|
15
|
+
* required; invalid details fail with HTTP 400 `InvalidRequestFormat` and no
|
|
16
|
+
* application is created.
|
|
17
|
+
*
|
|
11
18
|
* @param applicationRequest - The application request parameters
|
|
12
|
-
* @returns Promise with the application
|
|
19
|
+
* @returns Promise with `opportunityId` and the application links
|
|
13
20
|
*/
|
|
14
21
|
startApplication(applicationRequest: ThirdPartyStartApplicationReq): Promise<ThirdPartyStartAppResp>;
|
|
15
22
|
/**
|
|
@@ -10,9 +10,16 @@ class ApplicationService extends base_service_1.BaseService {
|
|
|
10
10
|
super(httpClient);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Start an
|
|
13
|
+
* Start an application via the generic
|
|
14
|
+
* `POST /api/ThirdPartyStartApp/start-application` endpoint.
|
|
15
|
+
*
|
|
16
|
+
* Accepts optional `webhookRegistrationDetails` to opt in to application-status
|
|
17
|
+
* webhooks. When sent, both `callbackUrl` (absolute HTTPS) and `secretKey` are
|
|
18
|
+
* required; invalid details fail with HTTP 400 `InvalidRequestFormat` and no
|
|
19
|
+
* application is created.
|
|
20
|
+
*
|
|
14
21
|
* @param applicationRequest - The application request parameters
|
|
15
|
-
* @returns Promise with the application
|
|
22
|
+
* @returns Promise with `opportunityId` and the application links
|
|
16
23
|
*/
|
|
17
24
|
async startApplication(applicationRequest) {
|
|
18
25
|
return this.post('start application', '/api/ThirdPartyStartApp/start-application', applicationRequest);
|
|
@@ -8,7 +8,7 @@ import { ThirdPartyFinalExpenseQuoteReq, ThirdPartyFinalExpenseQuoteRes, ThirdPa
|
|
|
8
8
|
* Fidelity Life. Full flow (same as GIGDB / ADB):
|
|
9
9
|
* 1. getQuote() → quoteResponseId
|
|
10
10
|
* 2. startApplication() → opportunityId (or isDeclined=true)
|
|
11
|
-
* 3. InstaBrainClient.saveEftPayment() →
|
|
11
|
+
* 3. InstaBrainClient.saveEftPayment() → resolves on success (shared endpoint)
|
|
12
12
|
* 4. SecureSign flow → (shared — use SecureSignService)
|
|
13
13
|
* 5. InstaBrainClient.finalSubmit() → applicationStatus: 'InProgress' (async!)
|
|
14
14
|
* 6. pollUnderwritingStatus() → terminal status + policyNumber
|
|
@@ -22,7 +22,7 @@ const RATE_LIMIT_RETRY_MS = 2000;
|
|
|
22
22
|
* Fidelity Life. Full flow (same as GIGDB / ADB):
|
|
23
23
|
* 1. getQuote() → quoteResponseId
|
|
24
24
|
* 2. startApplication() → opportunityId (or isDeclined=true)
|
|
25
|
-
* 3. InstaBrainClient.saveEftPayment() →
|
|
25
|
+
* 3. InstaBrainClient.saveEftPayment() → resolves on success (shared endpoint)
|
|
26
26
|
* 4. SecureSign flow → (shared — use SecureSignService)
|
|
27
27
|
* 5. InstaBrainClient.finalSubmit() → applicationStatus: 'InProgress' (async!)
|
|
28
28
|
* 6. pollUnderwritingStatus() → terminal status + policyNumber
|
|
@@ -23,15 +23,24 @@ export declare class GigdbService extends BaseService {
|
|
|
23
23
|
/**
|
|
24
24
|
* Save bank-account (EFT) payment details for an in-progress application.
|
|
25
25
|
*
|
|
26
|
-
* Shared endpoint — used by
|
|
27
|
-
*
|
|
26
|
+
* Shared endpoint — used by every product. Call after Start Application and,
|
|
27
|
+
* for full-flow products, before `prepareDocsAndGetDeliveryChannels()`.
|
|
28
28
|
*
|
|
29
|
-
* Validation: `accountHolderName` is required,
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* `
|
|
29
|
+
* Validation: `accountHolderName` is required, at most 100 characters, and
|
|
30
|
+
* must pass the name format rules (in practice about 35 characters: letters,
|
|
31
|
+
* spaces, hyphens, apostrophes, and `*`; no consecutive special characters;
|
|
32
|
+
* must end with a letter); `routingNumber` is exactly 9 digits;
|
|
33
|
+
* `accountNumber` is 4–17 digits. Failures return `InvalidRequestFormat` with
|
|
34
|
+
* the field under `value.fields`.
|
|
33
35
|
*
|
|
34
36
|
* Business rules:
|
|
37
|
+
* - **Pay Later:** `payLaterDate` (`yyyy-MM-dd`, date only) schedules the
|
|
38
|
+
* draft; omit it to draft immediately. It must be after today (UTC) and no
|
|
39
|
+
* later than the earlier of the pay later window (30 days by default) and
|
|
40
|
+
* the applicant's next birthday, and is refused on the applicant's
|
|
41
|
+
* birthday (UTC date). Failures return
|
|
42
|
+
* `InvalidPaymentScheduledDate`; `PayLaterNotAvailable` means Pay Later is
|
|
43
|
+
* switched off on the platform. Both carry `value.fields.PayLaterDate`.
|
|
35
44
|
* - **EFT and credit card are mutually exclusive** per `opportunityId`.
|
|
36
45
|
* A successful payment that already exists (a prior EFT save, or a card
|
|
37
46
|
* that has already been charged) returns `PaymentAlreadyMade`. Afterwards,
|
|
@@ -44,8 +53,10 @@ export declare class GigdbService extends BaseService {
|
|
|
44
53
|
* `paymentNotMade` nor `LatestPaymentNotSuccessful` will be returned for
|
|
45
54
|
* payment reasons.
|
|
46
55
|
*
|
|
47
|
-
* @param request - The EFT payment request with opportunityId
|
|
48
|
-
* @returns
|
|
56
|
+
* @param request - The EFT payment request with opportunityId, bank account details, and optional payLaterDate
|
|
57
|
+
* @returns Resolves on success; failures throw. The declared type is `boolean`
|
|
58
|
+
* for backward compatibility — at runtime the value is the API's per-field
|
|
59
|
+
* validation result object, which is truthy.
|
|
49
60
|
*/
|
|
50
61
|
saveEftPayment(request: ThirdPartyEftPaymentReq): Promise<boolean>;
|
|
51
62
|
/**
|
|
@@ -30,15 +30,24 @@ class GigdbService extends base_service_1.BaseService {
|
|
|
30
30
|
/**
|
|
31
31
|
* Save bank-account (EFT) payment details for an in-progress application.
|
|
32
32
|
*
|
|
33
|
-
* Shared endpoint — used by
|
|
34
|
-
*
|
|
33
|
+
* Shared endpoint — used by every product. Call after Start Application and,
|
|
34
|
+
* for full-flow products, before `prepareDocsAndGetDeliveryChannels()`.
|
|
35
35
|
*
|
|
36
|
-
* Validation: `accountHolderName` is required,
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* `
|
|
36
|
+
* Validation: `accountHolderName` is required, at most 100 characters, and
|
|
37
|
+
* must pass the name format rules (in practice about 35 characters: letters,
|
|
38
|
+
* spaces, hyphens, apostrophes, and `*`; no consecutive special characters;
|
|
39
|
+
* must end with a letter); `routingNumber` is exactly 9 digits;
|
|
40
|
+
* `accountNumber` is 4–17 digits. Failures return `InvalidRequestFormat` with
|
|
41
|
+
* the field under `value.fields`.
|
|
40
42
|
*
|
|
41
43
|
* Business rules:
|
|
44
|
+
* - **Pay Later:** `payLaterDate` (`yyyy-MM-dd`, date only) schedules the
|
|
45
|
+
* draft; omit it to draft immediately. It must be after today (UTC) and no
|
|
46
|
+
* later than the earlier of the pay later window (30 days by default) and
|
|
47
|
+
* the applicant's next birthday, and is refused on the applicant's
|
|
48
|
+
* birthday (UTC date). Failures return
|
|
49
|
+
* `InvalidPaymentScheduledDate`; `PayLaterNotAvailable` means Pay Later is
|
|
50
|
+
* switched off on the platform. Both carry `value.fields.PayLaterDate`.
|
|
42
51
|
* - **EFT and credit card are mutually exclusive** per `opportunityId`.
|
|
43
52
|
* A successful payment that already exists (a prior EFT save, or a card
|
|
44
53
|
* that has already been charged) returns `PaymentAlreadyMade`. Afterwards,
|
|
@@ -51,11 +60,13 @@ class GigdbService extends base_service_1.BaseService {
|
|
|
51
60
|
* `paymentNotMade` nor `LatestPaymentNotSuccessful` will be returned for
|
|
52
61
|
* payment reasons.
|
|
53
62
|
*
|
|
54
|
-
* @param request - The EFT payment request with opportunityId
|
|
55
|
-
* @returns
|
|
63
|
+
* @param request - The EFT payment request with opportunityId, bank account details, and optional payLaterDate
|
|
64
|
+
* @returns Resolves on success; failures throw. The declared type is `boolean`
|
|
65
|
+
* for backward compatibility — at runtime the value is the API's per-field
|
|
66
|
+
* validation result object, which is truthy.
|
|
56
67
|
*/
|
|
57
68
|
async saveEftPayment(request) {
|
|
58
|
-
const result = await this.post('save EFT payment', '/api/ThirdPartyPayment/save-eft-payment', request, undefined, true // allowNullValue —
|
|
69
|
+
const result = await this.post('save EFT payment', '/api/ThirdPartyPayment/save-eft-payment', request, undefined, true // allowNullValue — value is the per-field validation object (typed boolean for back-compat); a null value resolves to true
|
|
59
70
|
);
|
|
60
71
|
return result !== null && result !== void 0 ? result : true;
|
|
61
72
|
}
|
|
@@ -10,10 +10,16 @@ import { ThirdPartyStartAppResp, ThirdPartyQuoteResp } from '../types';
|
|
|
10
10
|
* Flow:
|
|
11
11
|
* 1. (optional) getRiderDetails(stateCode, age, flagNicotineUse) → rider availability + codes
|
|
12
12
|
* 2. InstaBrainClient.getQuote() → quoteResponseId (uses ThirdPartyIbTermQuote/get via QuoteService)
|
|
13
|
-
* 3. startApplication() → opportunityId
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* 3. startApplication() → opportunityId + links; isDeclined=true with an
|
|
14
|
+
* empty/all-zero id = knockout (stop), with a real
|
|
15
|
+
* id = declined (keep the id and links)
|
|
16
|
+
* 4. (optional) InstaBrainClient.saveEftPayment() → resolves on success (shared endpoint)
|
|
17
|
+
*
|
|
18
|
+
* After startApplication(), direct the agent or applicant to the returned link.
|
|
19
|
+
* All remaining steps (underwriting, payment, signing) complete inside the
|
|
20
|
+
* InstaBrain frontend. Do NOT wire an IB Term `opportunityId` into the shared
|
|
21
|
+
* SecureSign, finalSubmit(), or credit-card iframe clients. Shared EFT
|
|
22
|
+
* (`saveEftPayment()`, including Pay Later) is allowed.
|
|
17
23
|
*/
|
|
18
24
|
export declare class IBTermService extends BaseService {
|
|
19
25
|
constructor(httpClient: HttpClient);
|
|
@@ -36,11 +42,17 @@ export declare class IBTermService extends BaseService {
|
|
|
36
42
|
* Start an IB Term application from a prior IB Term quote.
|
|
37
43
|
*
|
|
38
44
|
* Notes:
|
|
39
|
-
* - `isDeclined: true` is a valid success response
|
|
45
|
+
* - `isDeclined: true` is a valid success response, not an error. An empty or
|
|
46
|
+
* all-zero `opportunityId` is a knockout (no application — stop); a real id
|
|
47
|
+
* means the application exists but was declined (keep it and any links).
|
|
40
48
|
* - IB Term does NOT use `ApplicationLimitReached` (that applies to ADB/GIGDB only).
|
|
41
49
|
* - When the Dependent Child Rider was selected on the quote, `childRiderInfo`
|
|
42
50
|
* becomes required. Setting any of the 4 child knockout questions to `true`
|
|
43
51
|
* declines the application.
|
|
52
|
+
* - Optional `webhookRegistrationDetails` opts in to application-status
|
|
53
|
+
* webhooks. When sent, both `callbackUrl` (absolute HTTPS) and `secretKey`
|
|
54
|
+
* are required; invalid details fail with HTTP 400 `InvalidRequestFormat`
|
|
55
|
+
* and no application is created.
|
|
44
56
|
*
|
|
45
57
|
* @param request - The IB Term application request payload.
|
|
46
58
|
* @returns Promise with opportunityId, isDeclined flag, and `isQuoteChanged`.
|
|
@@ -10,10 +10,16 @@ const base_service_1 = require("./base.service");
|
|
|
10
10
|
* Flow:
|
|
11
11
|
* 1. (optional) getRiderDetails(stateCode, age, flagNicotineUse) → rider availability + codes
|
|
12
12
|
* 2. InstaBrainClient.getQuote() → quoteResponseId (uses ThirdPartyIbTermQuote/get via QuoteService)
|
|
13
|
-
* 3. startApplication() → opportunityId
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* 3. startApplication() → opportunityId + links; isDeclined=true with an
|
|
14
|
+
* empty/all-zero id = knockout (stop), with a real
|
|
15
|
+
* id = declined (keep the id and links)
|
|
16
|
+
* 4. (optional) InstaBrainClient.saveEftPayment() → resolves on success (shared endpoint)
|
|
17
|
+
*
|
|
18
|
+
* After startApplication(), direct the agent or applicant to the returned link.
|
|
19
|
+
* All remaining steps (underwriting, payment, signing) complete inside the
|
|
20
|
+
* InstaBrain frontend. Do NOT wire an IB Term `opportunityId` into the shared
|
|
21
|
+
* SecureSign, finalSubmit(), or credit-card iframe clients. Shared EFT
|
|
22
|
+
* (`saveEftPayment()`, including Pay Later) is allowed.
|
|
17
23
|
*/
|
|
18
24
|
class IBTermService extends base_service_1.BaseService {
|
|
19
25
|
constructor(httpClient) {
|
|
@@ -40,11 +46,17 @@ class IBTermService extends base_service_1.BaseService {
|
|
|
40
46
|
* Start an IB Term application from a prior IB Term quote.
|
|
41
47
|
*
|
|
42
48
|
* Notes:
|
|
43
|
-
* - `isDeclined: true` is a valid success response
|
|
49
|
+
* - `isDeclined: true` is a valid success response, not an error. An empty or
|
|
50
|
+
* all-zero `opportunityId` is a knockout (no application — stop); a real id
|
|
51
|
+
* means the application exists but was declined (keep it and any links).
|
|
44
52
|
* - IB Term does NOT use `ApplicationLimitReached` (that applies to ADB/GIGDB only).
|
|
45
53
|
* - When the Dependent Child Rider was selected on the quote, `childRiderInfo`
|
|
46
54
|
* becomes required. Setting any of the 4 child knockout questions to `true`
|
|
47
55
|
* declines the application.
|
|
56
|
+
* - Optional `webhookRegistrationDetails` opts in to application-status
|
|
57
|
+
* webhooks. When sent, both `callbackUrl` (absolute HTTPS) and `secretKey`
|
|
58
|
+
* are required; invalid details fail with HTTP 400 `InvalidRequestFormat`
|
|
59
|
+
* and no application is created.
|
|
48
60
|
*
|
|
49
61
|
* @param request - The IB Term application request payload.
|
|
50
62
|
* @returns Promise with opportunityId, isDeclined flag, and `isQuoteChanged`.
|
|
@@ -9,7 +9,9 @@ import { ThirdPartyQuoteResp, ThirdPartyStartAppResp } from '../types';
|
|
|
9
9
|
* Flow:
|
|
10
10
|
* 1. (optional) getRiderDetails(stateCode, age, flagNicotineUse) → rider availability + codes
|
|
11
11
|
* 2. getQuote() → quoteResponseId
|
|
12
|
-
* 3. startApplication() → opportunityId + links
|
|
12
|
+
* 3. startApplication() → opportunityId + links; isDeclined=true with an
|
|
13
|
+
* empty/all-zero id = knockout (stop), with a real
|
|
14
|
+
* id = declined (keep the id and links)
|
|
13
15
|
* 4. (optional) getExistingQuote(opportunityId) → re-fetch the stored quote
|
|
14
16
|
*
|
|
15
17
|
* After startApplication(), direct the agent or applicant to the returned link.
|
|
@@ -89,11 +91,13 @@ export declare class PureTermService extends BaseService {
|
|
|
89
91
|
* Start a Pure Term application from a prior Pure Term quote.
|
|
90
92
|
*
|
|
91
93
|
* This is a dedicated endpoint, separate from the generic
|
|
92
|
-
* `InstaBrainClient.startApplication()` (`/api/ThirdPartyStartApp/start-application`)
|
|
93
|
-
*
|
|
94
|
+
* `InstaBrainClient.startApplication()` (`/api/ThirdPartyStartApp/start-application`).
|
|
95
|
+
* Do not substitute one for the other.
|
|
94
96
|
*
|
|
95
97
|
* Notes:
|
|
96
|
-
* - `isDeclined: true` is a valid success response
|
|
98
|
+
* - `isDeclined: true` is a valid success response, not an error. An empty or
|
|
99
|
+
* all-zero `opportunityId` is a knockout (no application — stop); a real id
|
|
100
|
+
* means the application exists but was declined (keep it and any links).
|
|
97
101
|
* Knockouts: `isUsCitizenOrIsPermanentResident=false`,
|
|
98
102
|
* `isPayerAlsoOwnerAndInsured=false`, `isHoldingValidDriverLicense=false`,
|
|
99
103
|
* `areListedConditionsNotApplicable=false`, any of the four `childRiderInfo`
|
|
@@ -109,6 +113,10 @@ export declare class PureTermService extends BaseService {
|
|
|
109
113
|
* `dataNotFound` (quote response not found), or `internalServerError`.
|
|
110
114
|
* - After a successful, non-declined start, hand off via the returned links —
|
|
111
115
|
* do not continue into shared SecureSign / finalSubmit with this `opportunityId`.
|
|
116
|
+
* - Optional `webhookRegistrationDetails` opts in to application-status
|
|
117
|
+
* webhooks. When sent, both `callbackUrl` (absolute HTTPS) and `secretKey`
|
|
118
|
+
* are required; invalid details fail with HTTP 400 `InvalidRequestFormat`
|
|
119
|
+
* and no application is created.
|
|
112
120
|
*
|
|
113
121
|
* @param request - The Pure Term application request payload.
|
|
114
122
|
* @returns Promise with opportunityId, links, isDeclined flag, and `isQuoteChanged`.
|
|
@@ -9,7 +9,9 @@ const base_service_1 = require("./base.service");
|
|
|
9
9
|
* Flow:
|
|
10
10
|
* 1. (optional) getRiderDetails(stateCode, age, flagNicotineUse) → rider availability + codes
|
|
11
11
|
* 2. getQuote() → quoteResponseId
|
|
12
|
-
* 3. startApplication() → opportunityId + links
|
|
12
|
+
* 3. startApplication() → opportunityId + links; isDeclined=true with an
|
|
13
|
+
* empty/all-zero id = knockout (stop), with a real
|
|
14
|
+
* id = declined (keep the id and links)
|
|
13
15
|
* 4. (optional) getExistingQuote(opportunityId) → re-fetch the stored quote
|
|
14
16
|
*
|
|
15
17
|
* After startApplication(), direct the agent or applicant to the returned link.
|
|
@@ -97,11 +99,13 @@ class PureTermService extends base_service_1.BaseService {
|
|
|
97
99
|
* Start a Pure Term application from a prior Pure Term quote.
|
|
98
100
|
*
|
|
99
101
|
* This is a dedicated endpoint, separate from the generic
|
|
100
|
-
* `InstaBrainClient.startApplication()` (`/api/ThirdPartyStartApp/start-application`)
|
|
101
|
-
*
|
|
102
|
+
* `InstaBrainClient.startApplication()` (`/api/ThirdPartyStartApp/start-application`).
|
|
103
|
+
* Do not substitute one for the other.
|
|
102
104
|
*
|
|
103
105
|
* Notes:
|
|
104
|
-
* - `isDeclined: true` is a valid success response
|
|
106
|
+
* - `isDeclined: true` is a valid success response, not an error. An empty or
|
|
107
|
+
* all-zero `opportunityId` is a knockout (no application — stop); a real id
|
|
108
|
+
* means the application exists but was declined (keep it and any links).
|
|
105
109
|
* Knockouts: `isUsCitizenOrIsPermanentResident=false`,
|
|
106
110
|
* `isPayerAlsoOwnerAndInsured=false`, `isHoldingValidDriverLicense=false`,
|
|
107
111
|
* `areListedConditionsNotApplicable=false`, any of the four `childRiderInfo`
|
|
@@ -117,6 +121,10 @@ class PureTermService extends base_service_1.BaseService {
|
|
|
117
121
|
* `dataNotFound` (quote response not found), or `internalServerError`.
|
|
118
122
|
* - After a successful, non-declined start, hand off via the returned links —
|
|
119
123
|
* do not continue into shared SecureSign / finalSubmit with this `opportunityId`.
|
|
124
|
+
* - Optional `webhookRegistrationDetails` opts in to application-status
|
|
125
|
+
* webhooks. When sent, both `callbackUrl` (absolute HTTPS) and `secretKey`
|
|
126
|
+
* are required; invalid details fail with HTTP 400 `InvalidRequestFormat`
|
|
127
|
+
* and no application is created.
|
|
120
128
|
*
|
|
121
129
|
* @param request - The Pure Term application request payload.
|
|
122
130
|
* @returns Promise with opportunityId, links, isDeclined flag, and `isQuoteChanged`.
|
|
@@ -33,6 +33,9 @@ export declare class ReportsService extends BaseService {
|
|
|
33
33
|
* - Total premium amount calculation
|
|
34
34
|
* - Available filters metadata
|
|
35
35
|
*
|
|
36
|
+
* Each sale carries the rate class in `rateClass`; `applicationStatus` no longer
|
|
37
|
+
* includes it (format: `{Status}` or `{Status} : {Assessment Factor}`).
|
|
38
|
+
*
|
|
36
39
|
* @param request - The agent portal request with filters, pagination, etc.
|
|
37
40
|
* @returns Promise with sales data including total premium amount
|
|
38
41
|
*/
|
|
@@ -38,6 +38,9 @@ class ReportsService extends base_service_1.BaseService {
|
|
|
38
38
|
* - Total premium amount calculation
|
|
39
39
|
* - Available filters metadata
|
|
40
40
|
*
|
|
41
|
+
* Each sale carries the rate class in `rateClass`; `applicationStatus` no longer
|
|
42
|
+
* includes it (format: `{Status}` or `{Status} : {Assessment Factor}`).
|
|
43
|
+
*
|
|
41
44
|
* @param request - The agent portal request with filters, pagination, etc.
|
|
42
45
|
* @returns Promise with sales data including total premium amount
|
|
43
46
|
*/
|