@instabrain-sdks/api-client 2.5.0 → 2.7.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/LICENSE.md +31 -0
- package/README.md +684 -66
- package/dist/client/instabrain-client.d.ts +96 -14
- package/dist/client/instabrain-client.js +102 -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 +24 -6
- package/dist/services/finalexpense.service.js +24 -6
- 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/pivot.service.d.ts +104 -0
- package/dist/services/pivot.service.js +116 -0
- package/dist/services/pureterm.service.d.ts +12 -4
- package/dist/services/pureterm.service.js +12 -4
- 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 +55 -5
- package/dist/types/enums.js +66 -5
- package/dist/types/errors.d.ts +4 -4
- package/dist/types/errors.js +8 -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 +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/pivot.types.d.ts +122 -0
- package/dist/types/pivot.types.js +2 -0
- 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 +27 -16
|
@@ -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`.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
import { BaseService } from './base.service';
|
|
3
|
+
import { PivotQuotesResp, CustomizePivotQuoteReq, CustomizePivotQuoteResp, ConvertPivotToApplicationReq, ConvertPivotToApplicationResp } from '../types/pivot.types';
|
|
4
|
+
/**
|
|
5
|
+
* Pivot service — offering an alternative product after a decline.
|
|
6
|
+
*
|
|
7
|
+
* Today this covers the Final Expense → GIGDB pivot. It is not a product of its
|
|
8
|
+
* own: every call keys off an `opportunityId` that a Final Expense
|
|
9
|
+
* `startApplication()` returned alongside `isDeclined: true`.
|
|
10
|
+
*
|
|
11
|
+
* Flow:
|
|
12
|
+
* 1. getPivotQuotes(opportunityId) → alternative quote options
|
|
13
|
+
* 2. customizePivotQuote(request) → optional re-price
|
|
14
|
+
* 3. convertPivotToApplication(request) → new opportunityId on the new product
|
|
15
|
+
*
|
|
16
|
+
* **Entry condition:** Final Expense start-application returned
|
|
17
|
+
* `isDeclined: true` with a **non-zero** `opportunityId`. An all-zero id means
|
|
18
|
+
* no application was created and there is nothing to pivot from.
|
|
19
|
+
*
|
|
20
|
+
* After a successful conversion, leave this service behind — continue with the
|
|
21
|
+
* alternative product's own lifecycle using the new `opportunityId`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class PivotService extends BaseService {
|
|
24
|
+
constructor(httpClient: HttpClient);
|
|
25
|
+
/**
|
|
26
|
+
* Get alternative-product quotes for a declined application.
|
|
27
|
+
*
|
|
28
|
+
* Only call this when Final Expense start-application returned
|
|
29
|
+
* `isDeclined: true` with a **non-zero** `opportunityId`. Do not call it for
|
|
30
|
+
* approved applications, all-zero declines, or products that do not support
|
|
31
|
+
* pivot (today, Final Expense is the only source product).
|
|
32
|
+
*
|
|
33
|
+
* Calling repeatedly for the same opportunity is safe.
|
|
34
|
+
*
|
|
35
|
+
* **Persist `quotes[n].pivotProductCode`** — it is required by both
|
|
36
|
+
* {@link customizePivotQuote} and {@link convertPivotToApplication}.
|
|
37
|
+
*
|
|
38
|
+
* Errors:
|
|
39
|
+
* - `InvalidRequestFormat` — missing/malformed/unknown `opportunityId`, or a
|
|
40
|
+
* source product that does not support pivot. Inspect `value.fields`.
|
|
41
|
+
* - `PivotNotAvailable` — the opportunity cannot be pivoted. Top-level,
|
|
42
|
+
* `value: null`. This is a business state, not a malformed request.
|
|
43
|
+
* - HTTP 403 — the `opportunityId` is not authorized for this token. No body.
|
|
44
|
+
*
|
|
45
|
+
* @param opportunityId - The non-zero `opportunityId` from the declined application.
|
|
46
|
+
* @returns Promise with `pivotReason` and the available `quotes`.
|
|
47
|
+
*/
|
|
48
|
+
getPivotQuotes(opportunityId: string): Promise<PivotQuotesResp>;
|
|
49
|
+
/**
|
|
50
|
+
* Re-price an alternative-product quote for a different coverage amount or
|
|
51
|
+
* billing frequency.
|
|
52
|
+
*
|
|
53
|
+
* Optional — only needed when the applicant wants something other than the
|
|
54
|
+
* default quote returned by {@link getPivotQuotes}. The response is a single
|
|
55
|
+
* quote item with the same shape as one element of that list.
|
|
56
|
+
*
|
|
57
|
+
* This does **not** persist the choice. `convertPivotToApplication()` still
|
|
58
|
+
* requires `faceAmount` and `paymentFreq` to be sent explicitly.
|
|
59
|
+
*
|
|
60
|
+
* Errors:
|
|
61
|
+
* - `InvalidRequestFormat` — missing/malformed body fields, unknown
|
|
62
|
+
* `opportunityId`, or an invalid `pivotProductCode`.
|
|
63
|
+
* - `CoverageNotAvailable` — `faceAmount` is outside the alternative
|
|
64
|
+
* product's range or off its required increment (GIGDB: $5,000–$25,000 in
|
|
65
|
+
* $1,000 steps). Top-level, `value: null`.
|
|
66
|
+
* - `PivotNotAvailable` — the opportunity cannot be pivoted, or pricing
|
|
67
|
+
* could not produce a quote. Top-level, `value: null`.
|
|
68
|
+
* - HTTP 403 — `opportunityId` not authorized for this token.
|
|
69
|
+
*
|
|
70
|
+
* @param request - Opportunity, product code, and the desired coverage / frequency.
|
|
71
|
+
* @returns Promise with the recalculated quote.
|
|
72
|
+
*/
|
|
73
|
+
customizePivotQuote(request: CustomizePivotQuoteReq): Promise<CustomizePivotQuoteResp>;
|
|
74
|
+
/**
|
|
75
|
+
* Create the alternative-product application.
|
|
76
|
+
*
|
|
77
|
+
* Call only once the applicant has confirmed the coverage amount and payment
|
|
78
|
+
* frequency they want. `faceAmount` and `paymentFreq` are required on every
|
|
79
|
+
* call — they are not inherited from a prior {@link customizePivotQuote}.
|
|
80
|
+
*
|
|
81
|
+
* **The returned `opportunityId` is new** and belongs to the alternative
|
|
82
|
+
* product. Persist it and use it for everything that follows; the Final
|
|
83
|
+
* Expense id is finished at this point.
|
|
84
|
+
*
|
|
85
|
+
* The response carries no premium by design. Call the alternative product's
|
|
86
|
+
* own get-existing-quote with the new id to read the current amount, then
|
|
87
|
+
* continue that product's normal lifecycle.
|
|
88
|
+
*
|
|
89
|
+
* **Do not retry after a successful conversion** — a second attempt on the
|
|
90
|
+
* same opportunity returns `PivotNotAvailable`.
|
|
91
|
+
*
|
|
92
|
+
* Errors:
|
|
93
|
+
* - `InvalidRequestFormat` — missing/malformed body fields, unknown
|
|
94
|
+
* `opportunityId` (`OpportunityId does not exist.`), unsupported product,
|
|
95
|
+
* or an invalid `pivotProductCode`.
|
|
96
|
+
* - `CoverageNotAvailable` — `faceAmount` outside range or off-increment.
|
|
97
|
+
* - `PivotNotAvailable` — no longer fit to pivot, e.g. already converted.
|
|
98
|
+
* - HTTP 403 — `opportunityId` not authorized for this token.
|
|
99
|
+
*
|
|
100
|
+
* @param request - Opportunity, product code, and confirmed coverage / frequency.
|
|
101
|
+
* @returns Promise with the new `opportunityId` and its `productCode`.
|
|
102
|
+
*/
|
|
103
|
+
convertPivotToApplication(request: ConvertPivotToApplicationReq): Promise<ConvertPivotToApplicationResp>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PivotService = void 0;
|
|
4
|
+
const base_service_1 = require("./base.service");
|
|
5
|
+
/**
|
|
6
|
+
* Pivot service — offering an alternative product after a decline.
|
|
7
|
+
*
|
|
8
|
+
* Today this covers the Final Expense → GIGDB pivot. It is not a product of its
|
|
9
|
+
* own: every call keys off an `opportunityId` that a Final Expense
|
|
10
|
+
* `startApplication()` returned alongside `isDeclined: true`.
|
|
11
|
+
*
|
|
12
|
+
* Flow:
|
|
13
|
+
* 1. getPivotQuotes(opportunityId) → alternative quote options
|
|
14
|
+
* 2. customizePivotQuote(request) → optional re-price
|
|
15
|
+
* 3. convertPivotToApplication(request) → new opportunityId on the new product
|
|
16
|
+
*
|
|
17
|
+
* **Entry condition:** Final Expense start-application returned
|
|
18
|
+
* `isDeclined: true` with a **non-zero** `opportunityId`. An all-zero id means
|
|
19
|
+
* no application was created and there is nothing to pivot from.
|
|
20
|
+
*
|
|
21
|
+
* After a successful conversion, leave this service behind — continue with the
|
|
22
|
+
* alternative product's own lifecycle using the new `opportunityId`.
|
|
23
|
+
*/
|
|
24
|
+
class PivotService extends base_service_1.BaseService {
|
|
25
|
+
constructor(httpClient) {
|
|
26
|
+
super(httpClient);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get alternative-product quotes for a declined application.
|
|
30
|
+
*
|
|
31
|
+
* Only call this when Final Expense start-application returned
|
|
32
|
+
* `isDeclined: true` with a **non-zero** `opportunityId`. Do not call it for
|
|
33
|
+
* approved applications, all-zero declines, or products that do not support
|
|
34
|
+
* pivot (today, Final Expense is the only source product).
|
|
35
|
+
*
|
|
36
|
+
* Calling repeatedly for the same opportunity is safe.
|
|
37
|
+
*
|
|
38
|
+
* **Persist `quotes[n].pivotProductCode`** — it is required by both
|
|
39
|
+
* {@link customizePivotQuote} and {@link convertPivotToApplication}.
|
|
40
|
+
*
|
|
41
|
+
* Errors:
|
|
42
|
+
* - `InvalidRequestFormat` — missing/malformed/unknown `opportunityId`, or a
|
|
43
|
+
* source product that does not support pivot. Inspect `value.fields`.
|
|
44
|
+
* - `PivotNotAvailable` — the opportunity cannot be pivoted. Top-level,
|
|
45
|
+
* `value: null`. This is a business state, not a malformed request.
|
|
46
|
+
* - HTTP 403 — the `opportunityId` is not authorized for this token. No body.
|
|
47
|
+
*
|
|
48
|
+
* @param opportunityId - The non-zero `opportunityId` from the declined application.
|
|
49
|
+
* @returns Promise with `pivotReason` and the available `quotes`.
|
|
50
|
+
*/
|
|
51
|
+
async getPivotQuotes(opportunityId) {
|
|
52
|
+
return this.get('get pivot quotes', '/api/ThirdPartyPivot/get-pivot-quotes', {
|
|
53
|
+
params: { opportunityId },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Re-price an alternative-product quote for a different coverage amount or
|
|
58
|
+
* billing frequency.
|
|
59
|
+
*
|
|
60
|
+
* Optional — only needed when the applicant wants something other than the
|
|
61
|
+
* default quote returned by {@link getPivotQuotes}. The response is a single
|
|
62
|
+
* quote item with the same shape as one element of that list.
|
|
63
|
+
*
|
|
64
|
+
* This does **not** persist the choice. `convertPivotToApplication()` still
|
|
65
|
+
* requires `faceAmount` and `paymentFreq` to be sent explicitly.
|
|
66
|
+
*
|
|
67
|
+
* Errors:
|
|
68
|
+
* - `InvalidRequestFormat` — missing/malformed body fields, unknown
|
|
69
|
+
* `opportunityId`, or an invalid `pivotProductCode`.
|
|
70
|
+
* - `CoverageNotAvailable` — `faceAmount` is outside the alternative
|
|
71
|
+
* product's range or off its required increment (GIGDB: $5,000–$25,000 in
|
|
72
|
+
* $1,000 steps). Top-level, `value: null`.
|
|
73
|
+
* - `PivotNotAvailable` — the opportunity cannot be pivoted, or pricing
|
|
74
|
+
* could not produce a quote. Top-level, `value: null`.
|
|
75
|
+
* - HTTP 403 — `opportunityId` not authorized for this token.
|
|
76
|
+
*
|
|
77
|
+
* @param request - Opportunity, product code, and the desired coverage / frequency.
|
|
78
|
+
* @returns Promise with the recalculated quote.
|
|
79
|
+
*/
|
|
80
|
+
async customizePivotQuote(request) {
|
|
81
|
+
return this.post('customize pivot quote', '/api/ThirdPartyPivot/customize-pivot-quote', request);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create the alternative-product application.
|
|
85
|
+
*
|
|
86
|
+
* Call only once the applicant has confirmed the coverage amount and payment
|
|
87
|
+
* frequency they want. `faceAmount` and `paymentFreq` are required on every
|
|
88
|
+
* call — they are not inherited from a prior {@link customizePivotQuote}.
|
|
89
|
+
*
|
|
90
|
+
* **The returned `opportunityId` is new** and belongs to the alternative
|
|
91
|
+
* product. Persist it and use it for everything that follows; the Final
|
|
92
|
+
* Expense id is finished at this point.
|
|
93
|
+
*
|
|
94
|
+
* The response carries no premium by design. Call the alternative product's
|
|
95
|
+
* own get-existing-quote with the new id to read the current amount, then
|
|
96
|
+
* continue that product's normal lifecycle.
|
|
97
|
+
*
|
|
98
|
+
* **Do not retry after a successful conversion** — a second attempt on the
|
|
99
|
+
* same opportunity returns `PivotNotAvailable`.
|
|
100
|
+
*
|
|
101
|
+
* Errors:
|
|
102
|
+
* - `InvalidRequestFormat` — missing/malformed body fields, unknown
|
|
103
|
+
* `opportunityId` (`OpportunityId does not exist.`), unsupported product,
|
|
104
|
+
* or an invalid `pivotProductCode`.
|
|
105
|
+
* - `CoverageNotAvailable` — `faceAmount` outside range or off-increment.
|
|
106
|
+
* - `PivotNotAvailable` — no longer fit to pivot, e.g. already converted.
|
|
107
|
+
* - HTTP 403 — `opportunityId` not authorized for this token.
|
|
108
|
+
*
|
|
109
|
+
* @param request - Opportunity, product code, and confirmed coverage / frequency.
|
|
110
|
+
* @returns Promise with the new `opportunityId` and its `productCode`.
|
|
111
|
+
*/
|
|
112
|
+
async convertPivotToApplication(request) {
|
|
113
|
+
return this.post('convert pivot to application', '/api/ThirdPartyPivot/convert-pivot-to-application', request);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.PivotService = PivotService;
|
|
@@ -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`.
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { WebhookRegistrationDetails } from './webhook.types';
|
|
1
2
|
/**
|
|
2
3
|
* Request body for `POST /api/ThirdPartyStartApp/start-application`.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* The older, generic start-application endpoint. Returns `opportunityId` plus
|
|
6
|
+
* `agentLink`, `applicantLink`, and `eAppAgentLink` for the InstaBrain frontend.
|
|
7
|
+
* IB Term and Pure Term also have dedicated endpoints with full request
|
|
8
|
+
* contracts (`startIBTermApplication()`, `startPureTermApplication()`), which
|
|
9
|
+
* InstaBrain recommends for those products.
|
|
7
10
|
*
|
|
8
11
|
* Source of truth: ThirdPartyStartApplicationReq.cs
|
|
9
12
|
*/
|
|
@@ -19,14 +22,33 @@ export interface ThirdPartyStartApplicationReq {
|
|
|
19
22
|
* Contact InstaBrain support to obtain the correct code for a specific variant.
|
|
20
23
|
*/
|
|
21
24
|
proCode?: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Optional. Opt in to application-status webhooks for the opportunity this
|
|
27
|
+
* call creates. Omit or pass `null` for no callbacks. When sent, both
|
|
28
|
+
* `callbackUrl` (absolute HTTPS) and `secretKey` (16–256 characters) are
|
|
29
|
+
* required. See {@link WebhookRegistrationDetails}.
|
|
30
|
+
*/
|
|
31
|
+
webhookRegistrationDetails?: WebhookRegistrationDetails | null;
|
|
22
32
|
}
|
|
23
33
|
export interface ThirdPartyStartAppResp {
|
|
34
|
+
/**
|
|
35
|
+
* GUID of the created application. Empty or all-zero on a knockout decline,
|
|
36
|
+
* when no application exists. The same value arrives as `opportunityUid` on
|
|
37
|
+
* webhook deliveries — use it to correlate them.
|
|
38
|
+
*/
|
|
24
39
|
opportunityId: string;
|
|
25
40
|
agentLink: string | null;
|
|
26
41
|
eAppAgentLink: string | null;
|
|
27
42
|
applicantLink: string | null;
|
|
28
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* `true` when the application is declined (knockout or underwriting decision).
|
|
45
|
+
* Read it with `opportunityId`. Returned by GIGDB, IB Term, and Pure Term;
|
|
46
|
+
* normally `false` on the generic route.
|
|
47
|
+
*/
|
|
29
48
|
isDeclined: boolean;
|
|
30
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* `true` when re-quote logic updated values during start-application processing.
|
|
51
|
+
* Returned by GIGDB, IB Term, and Pure Term; normally `false` on the generic route.
|
|
52
|
+
*/
|
|
31
53
|
isQuoteChanged: boolean;
|
|
32
54
|
}
|
|
@@ -63,3 +63,14 @@ export declare const BENEFIT_PERIOD_AVAILABILITY: {
|
|
|
63
63
|
readonly AGE_45_50_TOBACCO: readonly [10, 20];
|
|
64
64
|
readonly AGE_51_60: readonly [10, 20];
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* `webhookRegistrationDetails` limits on start-application (IB Term, Pure Term,
|
|
68
|
+
* and generic). Reference only — the API validates them and returns HTTP 400
|
|
69
|
+
* `InvalidRequestFormat` when they are not met. `callbackUrl` must also be an
|
|
70
|
+
* absolute HTTPS URL in both sandbox and production.
|
|
71
|
+
*/
|
|
72
|
+
export declare const WEBHOOK_REGISTRATION_LIMITS: {
|
|
73
|
+
readonly CALLBACK_URL_MAX_LENGTH: 2048;
|
|
74
|
+
readonly SECRET_KEY_MIN_LENGTH: 16;
|
|
75
|
+
readonly SECRET_KEY_MAX_LENGTH: 256;
|
|
76
|
+
};
|
package/dist/types/constants.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* All validation is handled by the API.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.BENEFIT_PERIOD_AVAILABILITY = exports.FACE_AMOUNT_LIMITS_BY_AGE = exports.AGE_LIMITS = exports.RIDER_LIMITS = exports.NO_RIDERS_AVAILABLE_STATES = exports.CHILD_RIDER_UNAVAILABLE_STATES = exports.CHILD_RIDER_AVAILABLE_STATES = exports.ADB_RIDER_AVAILABLE_STATES = exports.UNAVAILABLE_STATES = void 0;
|
|
8
|
+
exports.WEBHOOK_REGISTRATION_LIMITS = exports.BENEFIT_PERIOD_AVAILABILITY = exports.FACE_AMOUNT_LIMITS_BY_AGE = exports.AGE_LIMITS = exports.RIDER_LIMITS = exports.NO_RIDERS_AVAILABLE_STATES = exports.CHILD_RIDER_UNAVAILABLE_STATES = exports.CHILD_RIDER_AVAILABLE_STATES = exports.ADB_RIDER_AVAILABLE_STATES = exports.UNAVAILABLE_STATES = void 0;
|
|
9
9
|
/** States where the product is not available */
|
|
10
10
|
exports.UNAVAILABLE_STATES = ['WY', 'NY'];
|
|
11
11
|
/** States where ADB Rider is available */
|
|
@@ -52,3 +52,14 @@ exports.BENEFIT_PERIOD_AVAILABILITY = {
|
|
|
52
52
|
AGE_45_50_TOBACCO: [10, 20],
|
|
53
53
|
AGE_51_60: [10, 20]
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* `webhookRegistrationDetails` limits on start-application (IB Term, Pure Term,
|
|
57
|
+
* and generic). Reference only — the API validates them and returns HTTP 400
|
|
58
|
+
* `InvalidRequestFormat` when they are not met. `callbackUrl` must also be an
|
|
59
|
+
* absolute HTTPS URL in both sandbox and production.
|
|
60
|
+
*/
|
|
61
|
+
exports.WEBHOOK_REGISTRATION_LIMITS = {
|
|
62
|
+
CALLBACK_URL_MAX_LENGTH: 2048,
|
|
63
|
+
SECRET_KEY_MIN_LENGTH: 16,
|
|
64
|
+
SECRET_KEY_MAX_LENGTH: 256
|
|
65
|
+
};
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -454,9 +454,37 @@ export declare enum AdbRiderType {
|
|
|
454
454
|
export declare enum APIErrorCode {
|
|
455
455
|
/** Top-level code for every FluentValidation failure across all products. Inspect `value.fields` for field-level details. */
|
|
456
456
|
InvalidRequestFormat = "InvalidRequestFormat",
|
|
457
|
+
/**
|
|
458
|
+
* Get Quote — the product has no carrier configuration for the requested
|
|
459
|
+
* state, or its configuration is flagged unavailable there. Field message:
|
|
460
|
+
* "This product is not available for the selected state."
|
|
461
|
+
*
|
|
462
|
+
* Previously surfaced as a plain `InvalidRequestFormat` field message; it is
|
|
463
|
+
* now its own top-level code. Not returned by start-application, update
|
|
464
|
+
* quote, or get-existing-quote.
|
|
465
|
+
*/
|
|
466
|
+
ProductNotAvailableForState = "ProductNotAvailableForState",
|
|
467
|
+
/**
|
|
468
|
+
* Get Quote — the authenticated agent is not licensed in the requested
|
|
469
|
+
* state, or the agent could not be resolved from the token. Field message:
|
|
470
|
+
* "Agent is not licensed for the selected state."
|
|
471
|
+
*
|
|
472
|
+
* Distinct from `ProductNotApprovedForHierarchy`, which is a
|
|
473
|
+
* start-application product-hierarchy check, not state licensing. Because
|
|
474
|
+
* the cascade stops at the first failure, this is only reachable once
|
|
475
|
+
* product availability has passed.
|
|
476
|
+
*/
|
|
477
|
+
AgentNotLicensedForState = "AgentNotLicensedForState",
|
|
457
478
|
/** State code missing or not recognized for the product. */
|
|
458
479
|
StateNotFound = "stateNotFound",
|
|
459
|
-
/**
|
|
480
|
+
/**
|
|
481
|
+
* Post-validation eligibility — the product is not offered for the selected
|
|
482
|
+
* state, determined after request validation passed. Carries `value: null`.
|
|
483
|
+
*
|
|
484
|
+
* NOT the same as `ProductNotAvailableForState`, which is a request-validation
|
|
485
|
+
* failure carrying `value.fields.StateCode`. Both can occur for the same
|
|
486
|
+
* state; they are raised at different stages and must stay separate.
|
|
487
|
+
*/
|
|
460
488
|
NotAvailableForState = "NotAvailableForState",
|
|
461
489
|
/** Quote not eligible for the given combination of state, age, and smoker status. */
|
|
462
490
|
QuoteNotEligibleForGivenConditions = "QuoteNotEligibleForGivenConditions",
|
|
@@ -472,6 +500,15 @@ export declare enum APIErrorCode {
|
|
|
472
500
|
BenefitPeriodNotAvailable = "BenefitPeriodNotAvailable",
|
|
473
501
|
/** IB Term Quote only — height + weight fall outside the carrier's acceptable build chart. */
|
|
474
502
|
OutsideBuildChart = "outsideBuildChart",
|
|
503
|
+
/**
|
|
504
|
+
* The opportunity cannot be pivoted to an alternative product — not eligible,
|
|
505
|
+
* pricing could not produce a quote, or it has already been converted once.
|
|
506
|
+
* Top-level with `value: null`.
|
|
507
|
+
*
|
|
508
|
+
* A business state, not a malformed request — do not lump it in with
|
|
509
|
+
* `InvalidRequestFormat` handling.
|
|
510
|
+
*/
|
|
511
|
+
PivotNotAvailable = "PivotNotAvailable",
|
|
475
512
|
/** ADB / GIGDB / Final Expense Start Application only — same SSN, email, or phone already has a policy generated within the last 30 days. IB Term does NOT use this code. */
|
|
476
513
|
ApplicationLimitReached = "ApplicationLimitReached",
|
|
477
514
|
/** Quote state and `Address.State` on Start Application refer to different US states (case-insensitive compare). Returned only after request validation passes. */
|
|
@@ -500,6 +537,23 @@ export declare enum APIErrorCode {
|
|
|
500
537
|
* credit card as mutually exclusive per `opportunityId`.
|
|
501
538
|
*/
|
|
502
539
|
PaymentAlreadyMade = "PaymentAlreadyMade",
|
|
540
|
+
/**
|
|
541
|
+
* `saveEftPayment()` — `payLaterDate` was sent, but Pay Later is switched off
|
|
542
|
+
* on the platform. The switch is environment-wide, not specific to the
|
|
543
|
+
* opportunity, despite the message wording. Retry without `payLaterDate` to
|
|
544
|
+
* draft immediately. HTTP 400 with the message under `value.fields.PayLaterDate`.
|
|
545
|
+
*/
|
|
546
|
+
PayLaterNotAvailable = "PayLaterNotAvailable",
|
|
547
|
+
/**
|
|
548
|
+
* `saveEftPayment()` — `payLaterDate` is outside the allowed range: today
|
|
549
|
+
* (UTC) or earlier, beyond the platform's pay later window (30 days by
|
|
550
|
+
* default), after the applicant's next birthday, or sent on the applicant's
|
|
551
|
+
* birthday (UTC date). HTTP 400 with the message under
|
|
552
|
+
* `value.fields.PayLaterDate`.
|
|
553
|
+
*/
|
|
554
|
+
InvalidPaymentScheduledDate = "InvalidPaymentScheduledDate",
|
|
555
|
+
/** `saveEftPayment()` — the EFT details could not be saved. */
|
|
556
|
+
ErrorInSaveEftPaymentDetails = "ErrorInSaveEftPaymentDetails",
|
|
503
557
|
/** `getCcPaymentIframeUrl()` — a link already exists and the latest attempt has not failed (capture is `pending` or already `approved`). Reuse the URL you already have; a new one is only issued after a `failed` attempt. */
|
|
504
558
|
TcIframeLinkAlreadyGenerated = "TcIframeLinkAlreadyGenerated",
|
|
505
559
|
/** `getCcPaymentIframeUrl()` — the product does not support the credit card iframe. Returned for IB Term / Pure Term, which use shared EFT or their hand-off links instead. */
|
|
@@ -591,10 +645,6 @@ export declare enum APIErrorCode {
|
|
|
591
645
|
InvalidResidenceState = "InvalidResidenceState",
|
|
592
646
|
/** @deprecated No longer returned as a top-level code. */
|
|
593
647
|
OneOfTheExistingCoveragesQuestionsNotFound = "OneOfTheExistingCoveragesQuestionsNotFound",
|
|
594
|
-
/** @deprecated Prefer `InvalidRequestFormat` on EFT fields. */
|
|
595
|
-
ErrorInSaveEftPaymentDetails = "ErrorInSaveEftPaymentDetails",
|
|
596
|
-
/** @deprecated Prefer `InvalidRequestFormat` on EFT fields. */
|
|
597
|
-
InvalidPaymentScheduledDate = "InvalidPaymentScheduledDate",
|
|
598
648
|
/** @deprecated Legacy get-existing-quote code; prefer `InvalidRequestFormat`. */
|
|
599
649
|
ThirdPartyQuoteError = "ThirdPartyQuoteError",
|
|
600
650
|
/** @deprecated No longer returned as a top-level code. */
|