@instabrain-sdks/api-client 2.0.1 → 2.2.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 +1457 -351
- package/dist/client/instabrain-client.d.ts +55 -5
- package/dist/client/instabrain-client.js +67 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/services/adb.service.d.ts +65 -0
- package/dist/services/adb.service.js +87 -0
- package/dist/services/application.service.d.ts +2 -3
- package/dist/services/application.service.js +5 -52
- package/dist/services/auth.service.d.ts +0 -1
- package/dist/services/auth.service.js +0 -1
- package/dist/services/base.service.d.ts +45 -0
- package/dist/services/base.service.js +92 -0
- package/dist/services/gigdb.service.d.ts +2 -3
- package/dist/services/gigdb.service.js +12 -133
- package/dist/services/quote.service.d.ts +2 -3
- package/dist/services/quote.service.js +4 -35
- package/dist/services/reports.service.d.ts +2 -3
- package/dist/services/reports.service.js +6 -86
- package/dist/services/secure-sign.service.d.ts +2 -3
- package/dist/services/secure-sign.service.js +7 -109
- package/dist/types/adb.types.d.ts +154 -0
- package/dist/types/adb.types.js +2 -0
- package/dist/types/application.types.d.ts +0 -1
- package/dist/types/application.types.js +0 -1
- package/dist/types/auth.types.d.ts +0 -1
- package/dist/types/auth.types.js +0 -1
- package/dist/types/beneficiary.types.d.ts +54 -0
- package/dist/types/beneficiary.types.js +2 -0
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.js +0 -1
- package/dist/types/enums.d.ts +384 -5
- package/dist/types/enums.js +403 -9
- package/dist/types/errors.d.ts +0 -1
- package/dist/types/errors.js +0 -1
- package/dist/types/gigdb.types.d.ts +50 -15
- package/dist/types/gigdb.types.js +0 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +2 -1
- package/dist/types/quote.types.d.ts +0 -1
- package/dist/types/quote.types.js +0 -1
- package/dist/types/reports.types.d.ts +0 -1
- package/dist/types/reports.types.js +0 -1
- package/dist/types/secure-sign.types.d.ts +0 -1
- package/dist/types/secure-sign.types.js +0 -1
- package/dist/utils/error-utils.d.ts +0 -1
- package/dist/utils/error-utils.js +0 -1
- package/dist/utils/http-client.d.ts +0 -1
- package/dist/utils/http-client.js +0 -4
- package/package.json +2 -3
- package/dist/client/instabrain-client.d.ts.map +0 -1
- package/dist/client/instabrain-client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/services/application.service.d.ts.map +0 -1
- package/dist/services/application.service.js.map +0 -1
- package/dist/services/auth.service.d.ts.map +0 -1
- package/dist/services/auth.service.js.map +0 -1
- package/dist/services/gigdb.service.d.ts.map +0 -1
- package/dist/services/gigdb.service.js.map +0 -1
- package/dist/services/quote.service.d.ts.map +0 -1
- package/dist/services/quote.service.js.map +0 -1
- package/dist/services/reports.service.d.ts.map +0 -1
- package/dist/services/reports.service.js.map +0 -1
- package/dist/services/secure-sign.service.d.ts.map +0 -1
- package/dist/services/secure-sign.service.js.map +0 -1
- package/dist/types/application.types.d.ts.map +0 -1
- package/dist/types/application.types.js.map +0 -1
- package/dist/types/auth.types.d.ts.map +0 -1
- package/dist/types/auth.types.js.map +0 -1
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/constants.js.map +0 -1
- package/dist/types/enums.d.ts.map +0 -1
- package/dist/types/enums.js.map +0 -1
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/errors.js.map +0 -1
- package/dist/types/gigdb.types.d.ts.map +0 -1
- package/dist/types/gigdb.types.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/quote.types.d.ts.map +0 -1
- package/dist/types/quote.types.js.map +0 -1
- package/dist/types/reports.types.d.ts.map +0 -1
- package/dist/types/reports.types.js.map +0 -1
- package/dist/types/secure-sign.types.d.ts.map +0 -1
- package/dist/types/secure-sign.types.js.map +0 -1
- package/dist/utils/error-utils.d.ts.map +0 -1
- package/dist/utils/error-utils.js.map +0 -1
- package/dist/utils/http-client.d.ts.map +0 -1
- package/dist/utils/http-client.js.map +0 -1
|
@@ -3,8 +3,9 @@ import { QuoteService } from '../services/quote.service';
|
|
|
3
3
|
import { ApplicationService } from '../services/application.service';
|
|
4
4
|
import { ReportsService } from '../services/reports.service';
|
|
5
5
|
import { GigdbService } from '../services/gigdb.service';
|
|
6
|
+
import { AdbService } from '../services/adb.service';
|
|
6
7
|
import { SecureSignService } from '../services/secure-sign.service';
|
|
7
|
-
import { InstaBrainConfig, Environment, ThirdPartyQuoteReq, ThirdPartyQuoteResp, ThirdPartyStartApplicationReq, ThirdPartyStartAppResp, AgentPortalReq, ThirdPartyProspectsResp, ThirdPartySalesReportRes, ThirdPartyApplicationReportRes, ThirdPartyGigdbQuoteRequest, ThirdPartyGigdbUpdateQuoteReq, ThirdPartyGigdbAppReq, ThirdPartyEftPaymentReq, ThirdPartySendPinReq, ThirdPartyResendPinReq, ThirdPartyVerifyPinReq, ThirdPartyPrepareDocsResp, ThirdPartySendPinResp, ThirdPartyResendPinResp, ThirdPartyVerifyPinResp, ThirdPartyFinalSubmitResp } from '../types';
|
|
8
|
+
import { InstaBrainConfig, Environment, ThirdPartyQuoteReq, ThirdPartyQuoteResp, ThirdPartyStartApplicationReq, ThirdPartyStartAppResp, AgentPortalReq, ThirdPartyProspectsResp, ThirdPartySalesReportRes, ThirdPartyApplicationReportRes, ThirdPartyGigdbQuoteRequest, ThirdPartyGigdbUpdateQuoteReq, ThirdPartyGigdbAppReq, ThirdPartyEftPaymentReq, ThirdPartyAdbQuoteRequest, ThirdPartyAdbUpdateQuoteReq, ThirdPartyAdbAppReq, ThirdPartyAdbStartAppResp, AdbRiderDetailsResp, ThirdPartySendPinReq, ThirdPartyResendPinReq, ThirdPartyVerifyPinReq, ThirdPartyPrepareDocsResp, ThirdPartySendPinResp, ThirdPartyResendPinResp, ThirdPartyVerifyPinResp, ThirdPartyFinalSubmitResp } from '../types';
|
|
8
9
|
/**
|
|
9
10
|
* Main InstaBrain SDK client
|
|
10
11
|
*/
|
|
@@ -15,6 +16,7 @@ export declare class InstaBrainClient {
|
|
|
15
16
|
readonly application: ApplicationService;
|
|
16
17
|
readonly reports: ReportsService;
|
|
17
18
|
readonly gigdb: GigdbService;
|
|
19
|
+
readonly adb: AdbService;
|
|
18
20
|
readonly secureSign: SecureSignService;
|
|
19
21
|
constructor(config?: InstaBrainConfig);
|
|
20
22
|
/**
|
|
@@ -73,9 +75,10 @@ export declare class InstaBrainClient {
|
|
|
73
75
|
*/
|
|
74
76
|
startGigdbApplication(request: ThirdPartyGigdbAppReq): Promise<ThirdPartyStartAppResp>;
|
|
75
77
|
/**
|
|
76
|
-
* Save EFT payment details for a GIGDB application
|
|
77
|
-
*
|
|
78
|
-
* @
|
|
78
|
+
* Save EFT payment details for a GIGDB or ADB application
|
|
79
|
+
* Must be called after startGigdbApplication / startAdbApplication and before the SecureSign flow.
|
|
80
|
+
* @param request - The EFT payment request with opportunityId and bank account details
|
|
81
|
+
* @returns Promise resolving to true on success
|
|
79
82
|
*/
|
|
80
83
|
saveEftPayment(request: ThirdPartyEftPaymentReq): Promise<boolean>;
|
|
81
84
|
/**
|
|
@@ -92,6 +95,54 @@ export declare class InstaBrainClient {
|
|
|
92
95
|
* @returns Promise with the current quote response
|
|
93
96
|
*/
|
|
94
97
|
getExistingGigdbQuote(opportunityId: string): Promise<ThirdPartyQuoteResp>;
|
|
98
|
+
/**
|
|
99
|
+
* Get an ADB (Accidental Death Benefit) insurance quote (ages 20-59)
|
|
100
|
+
* @param request - The ADB quote request parameters
|
|
101
|
+
* @returns Promise with the quote response containing quoteResponseId
|
|
102
|
+
*/
|
|
103
|
+
getAdbQuote(request: ThirdPartyAdbQuoteRequest): Promise<ThirdPartyQuoteResp>;
|
|
104
|
+
/**
|
|
105
|
+
* Start an ADB application from a quote
|
|
106
|
+
* Note: isDeclined=true is a valid success response (knockout), not an error.
|
|
107
|
+
* Knockout conditions: isPayerAlsoOwnerAndInsured=false, or isUsCitizen=false AND isLegalUsResident=false.
|
|
108
|
+
* After this, call saveEftPayment() then the shared SecureSign flow then finalSubmit().
|
|
109
|
+
* @param request - The ADB application request parameters
|
|
110
|
+
* @returns Promise with opportunityId and isDeclined flag
|
|
111
|
+
*/
|
|
112
|
+
startAdbApplication(request: ThirdPartyAdbAppReq): Promise<ThirdPartyAdbStartAppResp>;
|
|
113
|
+
/**
|
|
114
|
+
* Get available riders for the ADB product in a given US state.
|
|
115
|
+
* Call this before getAdbQuote() to check if ADB is available in the state
|
|
116
|
+
* and to collect riderCodes to include in the quote request.
|
|
117
|
+
* CA is not a supported state.
|
|
118
|
+
* @param stateCode - Two-letter US state abbreviation (e.g. "AZ")
|
|
119
|
+
* @returns Promise with riders list and product availability flag
|
|
120
|
+
*/
|
|
121
|
+
getAdbRiderDetails(stateCode: string): Promise<AdbRiderDetailsResp>;
|
|
122
|
+
/**
|
|
123
|
+
* Update an ADB quote with a different face amount, payment frequency, or riders.
|
|
124
|
+
* Use after application has been started to re-quote for the same opportunity.
|
|
125
|
+
* Business error: "Quote update is not allowed when payment is already made".
|
|
126
|
+
* @param request - The update quote request with opportunityId, faceAmount, paymentFreq, and riders
|
|
127
|
+
* @returns Promise with the updated quote response
|
|
128
|
+
*/
|
|
129
|
+
updateAdbQuote(request: ThirdPartyAdbUpdateQuoteReq): Promise<ThirdPartyQuoteResp>;
|
|
130
|
+
/**
|
|
131
|
+
* Get the existing quote for an ADB opportunity.
|
|
132
|
+
* Use when startAdbApplication returns isQuoteChanged=true, or any time you need
|
|
133
|
+
* the current quote details for an in-flight ADB opportunity.
|
|
134
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
135
|
+
* @returns Promise with the current quote response
|
|
136
|
+
*/
|
|
137
|
+
getExistingAdbQuote(opportunityId: string): Promise<ThirdPartyQuoteResp>;
|
|
138
|
+
/**
|
|
139
|
+
* Search occupation labels for the ADB product.
|
|
140
|
+
* Required only for California residents — occupation must be supplied on
|
|
141
|
+
* ThirdPartyAdbAppReq when address.state === "CA".
|
|
142
|
+
* @param query - Optional filter term. When omitted, returns the full list.
|
|
143
|
+
* @returns Promise with the list of matching occupation labels
|
|
144
|
+
*/
|
|
145
|
+
getAdbOccupationOptions(query?: string): Promise<string[]>;
|
|
95
146
|
/**
|
|
96
147
|
* Prepare the signing package and check available delivery channels
|
|
97
148
|
* Always call this first in the signing flow. If isSignCompleted is true, skip to finalSubmit().
|
|
@@ -152,4 +203,3 @@ export declare class InstaBrainClient {
|
|
|
152
203
|
*/
|
|
153
204
|
getBaseUrl(): string;
|
|
154
205
|
}
|
|
155
|
-
//# sourceMappingURL=instabrain-client.d.ts.map
|
|
@@ -7,6 +7,7 @@ const quote_service_1 = require("../services/quote.service");
|
|
|
7
7
|
const application_service_1 = require("../services/application.service");
|
|
8
8
|
const reports_service_1 = require("../services/reports.service");
|
|
9
9
|
const gigdb_service_1 = require("../services/gigdb.service");
|
|
10
|
+
const adb_service_1 = require("../services/adb.service");
|
|
10
11
|
const secure_sign_service_1 = require("../services/secure-sign.service");
|
|
11
12
|
/**
|
|
12
13
|
* Main InstaBrain SDK client
|
|
@@ -19,6 +20,7 @@ class InstaBrainClient {
|
|
|
19
20
|
this.application = new application_service_1.ApplicationService(this.httpClient);
|
|
20
21
|
this.reports = new reports_service_1.ReportsService(this.httpClient);
|
|
21
22
|
this.gigdb = new gigdb_service_1.GigdbService(this.httpClient);
|
|
23
|
+
this.adb = new adb_service_1.AdbService(this.httpClient);
|
|
22
24
|
this.secureSign = new secure_sign_service_1.SecureSignService(this.httpClient);
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
@@ -100,9 +102,10 @@ class InstaBrainClient {
|
|
|
100
102
|
return this.gigdb.startApplication(request);
|
|
101
103
|
}
|
|
102
104
|
/**
|
|
103
|
-
* Save EFT payment details for a GIGDB application
|
|
104
|
-
*
|
|
105
|
-
* @
|
|
105
|
+
* Save EFT payment details for a GIGDB or ADB application
|
|
106
|
+
* Must be called after startGigdbApplication / startAdbApplication and before the SecureSign flow.
|
|
107
|
+
* @param request - The EFT payment request with opportunityId and bank account details
|
|
108
|
+
* @returns Promise resolving to true on success
|
|
106
109
|
*/
|
|
107
110
|
async saveEftPayment(request) {
|
|
108
111
|
return this.gigdb.saveEftPayment(request);
|
|
@@ -125,6 +128,67 @@ class InstaBrainClient {
|
|
|
125
128
|
async getExistingGigdbQuote(opportunityId) {
|
|
126
129
|
return this.gigdb.getExistingQuote(opportunityId);
|
|
127
130
|
}
|
|
131
|
+
// ── ADB Methods ────────────────────────────────────────────────────
|
|
132
|
+
/**
|
|
133
|
+
* Get an ADB (Accidental Death Benefit) insurance quote (ages 20-59)
|
|
134
|
+
* @param request - The ADB quote request parameters
|
|
135
|
+
* @returns Promise with the quote response containing quoteResponseId
|
|
136
|
+
*/
|
|
137
|
+
async getAdbQuote(request) {
|
|
138
|
+
return this.adb.getQuote(request);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Start an ADB application from a quote
|
|
142
|
+
* Note: isDeclined=true is a valid success response (knockout), not an error.
|
|
143
|
+
* Knockout conditions: isPayerAlsoOwnerAndInsured=false, or isUsCitizen=false AND isLegalUsResident=false.
|
|
144
|
+
* After this, call saveEftPayment() then the shared SecureSign flow then finalSubmit().
|
|
145
|
+
* @param request - The ADB application request parameters
|
|
146
|
+
* @returns Promise with opportunityId and isDeclined flag
|
|
147
|
+
*/
|
|
148
|
+
async startAdbApplication(request) {
|
|
149
|
+
return this.adb.startApplication(request);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get available riders for the ADB product in a given US state.
|
|
153
|
+
* Call this before getAdbQuote() to check if ADB is available in the state
|
|
154
|
+
* and to collect riderCodes to include in the quote request.
|
|
155
|
+
* CA is not a supported state.
|
|
156
|
+
* @param stateCode - Two-letter US state abbreviation (e.g. "AZ")
|
|
157
|
+
* @returns Promise with riders list and product availability flag
|
|
158
|
+
*/
|
|
159
|
+
async getAdbRiderDetails(stateCode) {
|
|
160
|
+
return this.adb.getRiderDetails(stateCode);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Update an ADB quote with a different face amount, payment frequency, or riders.
|
|
164
|
+
* Use after application has been started to re-quote for the same opportunity.
|
|
165
|
+
* Business error: "Quote update is not allowed when payment is already made".
|
|
166
|
+
* @param request - The update quote request with opportunityId, faceAmount, paymentFreq, and riders
|
|
167
|
+
* @returns Promise with the updated quote response
|
|
168
|
+
*/
|
|
169
|
+
async updateAdbQuote(request) {
|
|
170
|
+
return this.adb.updateQuote(request);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get the existing quote for an ADB opportunity.
|
|
174
|
+
* Use when startAdbApplication returns isQuoteChanged=true, or any time you need
|
|
175
|
+
* the current quote details for an in-flight ADB opportunity.
|
|
176
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
177
|
+
* @returns Promise with the current quote response
|
|
178
|
+
*/
|
|
179
|
+
async getExistingAdbQuote(opportunityId) {
|
|
180
|
+
return this.adb.getExistingQuote(opportunityId);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Search occupation labels for the ADB product.
|
|
184
|
+
* Required only for California residents — occupation must be supplied on
|
|
185
|
+
* ThirdPartyAdbAppReq when address.state === "CA".
|
|
186
|
+
* @param query - Optional filter term. When omitted, returns the full list.
|
|
187
|
+
* @returns Promise with the list of matching occupation labels
|
|
188
|
+
*/
|
|
189
|
+
async getAdbOccupationOptions(query) {
|
|
190
|
+
return this.adb.getOccupationOptions(query);
|
|
191
|
+
}
|
|
128
192
|
// ── Secure Sign Methods ─────────────────────────────────────────────
|
|
129
193
|
/**
|
|
130
194
|
* Prepare the signing package and check available delivery channels
|
|
@@ -208,4 +272,3 @@ class InstaBrainClient {
|
|
|
208
272
|
}
|
|
209
273
|
}
|
|
210
274
|
exports.InstaBrainClient = InstaBrainClient;
|
|
211
|
-
//# sourceMappingURL=instabrain-client.js.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,4 +23,3 @@ __exportStar(require("./types"), exports);
|
|
|
23
23
|
// Default export
|
|
24
24
|
var instabrain_client_2 = require("./client/instabrain-client");
|
|
25
25
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return instabrain_client_2.InstaBrainClient; } });
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
import { BaseService } from './base.service';
|
|
3
|
+
import { ThirdPartyAdbQuoteRequest, ThirdPartyAdbUpdateQuoteReq, ThirdPartyAdbAppReq, ThirdPartyAdbStartAppResp, ThirdPartyQuoteResp, AdbRiderDetailsResp } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* ADB (Accidental Death Benefit) service
|
|
6
|
+
* Handles quote, application, and EFT payment for the ADB product (ages 20-59)
|
|
7
|
+
* Distributed through Fidelity Life — no medical exam required
|
|
8
|
+
*
|
|
9
|
+
* Flow:
|
|
10
|
+
* 1. getQuote() → quoteResponseId
|
|
11
|
+
* 2. startApplication() → opportunityId (or isDeclined=true)
|
|
12
|
+
* 3. GigdbService.saveEftPayment() → true (shared endpoint — use via InstaBrainClient.saveEftPayment)
|
|
13
|
+
* 4. SecureSign flow → (shared — use SecureSignService)
|
|
14
|
+
* 5. Final Submit → (shared — use ApplicationService.finalSubmit)
|
|
15
|
+
*/
|
|
16
|
+
export declare class AdbService extends BaseService {
|
|
17
|
+
constructor(httpClient: HttpClient);
|
|
18
|
+
/**
|
|
19
|
+
* Get an ADB insurance quote
|
|
20
|
+
* @param request - The ADB quote request (ages 20-59)
|
|
21
|
+
* @returns Promise with the quote response containing quoteResponseId
|
|
22
|
+
*/
|
|
23
|
+
getQuote(request: ThirdPartyAdbQuoteRequest): Promise<ThirdPartyQuoteResp>;
|
|
24
|
+
/**
|
|
25
|
+
* Update an ADB quote with a different face amount, payment frequency, or riders.
|
|
26
|
+
* Use after application has been started to re-quote for the same opportunity.
|
|
27
|
+
* Business error: "Quote update is not allowed when payment is already made"
|
|
28
|
+
* @param request - The update quote request with opportunityId, faceAmount, paymentFreq, and riders
|
|
29
|
+
* @returns Promise with the updated quote response
|
|
30
|
+
*/
|
|
31
|
+
updateQuote(request: ThirdPartyAdbUpdateQuoteReq): Promise<ThirdPartyQuoteResp>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the existing quote for an ADB opportunity.
|
|
34
|
+
* Use when startAdbApplication returns isQuoteChanged=true, or any time you need
|
|
35
|
+
* the current quote details for an in-flight ADB opportunity.
|
|
36
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
37
|
+
* @returns Promise with the current quote response
|
|
38
|
+
*/
|
|
39
|
+
getExistingQuote(opportunityId: string): Promise<ThirdPartyQuoteResp>;
|
|
40
|
+
/**
|
|
41
|
+
* Search occupation labels for the ADB product.
|
|
42
|
+
* Required only for California residents — occupation must be supplied on
|
|
43
|
+
* ThirdPartyAdbAppReq when address.state === "CA".
|
|
44
|
+
* @param query - Optional filter term. When omitted, returns the full list.
|
|
45
|
+
* @returns Promise with the list of matching occupation labels
|
|
46
|
+
*/
|
|
47
|
+
getOccupationOptions(query?: string): Promise<string[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Start an ADB application from a quote
|
|
50
|
+
* Note: isDeclined=true is a valid success response (knockout), not an error.
|
|
51
|
+
* Knockout conditions:
|
|
52
|
+
* - isPayerAlsoOwnerAndInsured = false
|
|
53
|
+
* - isUsCitizen = false AND isLegalUsResident = false
|
|
54
|
+
* @param request - The ADB application request parameters
|
|
55
|
+
* @returns Promise with opportunityId and isDeclined flag
|
|
56
|
+
*/
|
|
57
|
+
startApplication(request: ThirdPartyAdbAppReq): Promise<ThirdPartyAdbStartAppResp>;
|
|
58
|
+
/**
|
|
59
|
+
* Get available riders for the ADB product in a given state.
|
|
60
|
+
* Call before getQuote() to check state availability and collect rider codes.
|
|
61
|
+
* @param stateCode - Two-letter US state abbreviation (e.g. "AZ"). CA is not supported.
|
|
62
|
+
* @returns Promise with riders list and flagProductNotAvailableForState flag
|
|
63
|
+
*/
|
|
64
|
+
getRiderDetails(stateCode: string): Promise<AdbRiderDetailsResp>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdbService = void 0;
|
|
4
|
+
const base_service_1 = require("./base.service");
|
|
5
|
+
/**
|
|
6
|
+
* ADB (Accidental Death Benefit) service
|
|
7
|
+
* Handles quote, application, and EFT payment for the ADB product (ages 20-59)
|
|
8
|
+
* Distributed through Fidelity Life — no medical exam required
|
|
9
|
+
*
|
|
10
|
+
* Flow:
|
|
11
|
+
* 1. getQuote() → quoteResponseId
|
|
12
|
+
* 2. startApplication() → opportunityId (or isDeclined=true)
|
|
13
|
+
* 3. GigdbService.saveEftPayment() → true (shared endpoint — use via InstaBrainClient.saveEftPayment)
|
|
14
|
+
* 4. SecureSign flow → (shared — use SecureSignService)
|
|
15
|
+
* 5. Final Submit → (shared — use ApplicationService.finalSubmit)
|
|
16
|
+
*/
|
|
17
|
+
class AdbService extends base_service_1.BaseService {
|
|
18
|
+
constructor(httpClient) {
|
|
19
|
+
super(httpClient);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get an ADB insurance quote
|
|
23
|
+
* @param request - The ADB quote request (ages 20-59)
|
|
24
|
+
* @returns Promise with the quote response containing quoteResponseId
|
|
25
|
+
*/
|
|
26
|
+
async getQuote(request) {
|
|
27
|
+
return this.post('get ADB quote', '/api/ThirdPartyIbAdbQuote/get', request);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Update an ADB quote with a different face amount, payment frequency, or riders.
|
|
31
|
+
* Use after application has been started to re-quote for the same opportunity.
|
|
32
|
+
* Business error: "Quote update is not allowed when payment is already made"
|
|
33
|
+
* @param request - The update quote request with opportunityId, faceAmount, paymentFreq, and riders
|
|
34
|
+
* @returns Promise with the updated quote response
|
|
35
|
+
*/
|
|
36
|
+
async updateQuote(request) {
|
|
37
|
+
return this.post('update ADB quote', '/api/ThirdPartyIbAdbQuote/update', request);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the existing quote for an ADB opportunity.
|
|
41
|
+
* Use when startAdbApplication returns isQuoteChanged=true, or any time you need
|
|
42
|
+
* the current quote details for an in-flight ADB opportunity.
|
|
43
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
44
|
+
* @returns Promise with the current quote response
|
|
45
|
+
*/
|
|
46
|
+
async getExistingQuote(opportunityId) {
|
|
47
|
+
return this.get('get existing ADB quote', '/api/ThirdPartyIbAdbQuote/get-existing-quote', {
|
|
48
|
+
params: { opportunityId },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Search occupation labels for the ADB product.
|
|
53
|
+
* Required only for California residents — occupation must be supplied on
|
|
54
|
+
* ThirdPartyAdbAppReq when address.state === "CA".
|
|
55
|
+
* @param query - Optional filter term. When omitted, returns the full list.
|
|
56
|
+
* @returns Promise with the list of matching occupation labels
|
|
57
|
+
*/
|
|
58
|
+
async getOccupationOptions(query) {
|
|
59
|
+
return this.get('get ADB occupation options', '/api/ThirdPartyAdbLookup/occupation-options', {
|
|
60
|
+
params: query ? { query } : {},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Start an ADB application from a quote
|
|
65
|
+
* Note: isDeclined=true is a valid success response (knockout), not an error.
|
|
66
|
+
* Knockout conditions:
|
|
67
|
+
* - isPayerAlsoOwnerAndInsured = false
|
|
68
|
+
* - isUsCitizen = false AND isLegalUsResident = false
|
|
69
|
+
* @param request - The ADB application request parameters
|
|
70
|
+
* @returns Promise with opportunityId and isDeclined flag
|
|
71
|
+
*/
|
|
72
|
+
async startApplication(request) {
|
|
73
|
+
return this.post('start ADB application', '/api/ThirdPartyAdbApplication/start-application', request);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get available riders for the ADB product in a given state.
|
|
77
|
+
* Call before getQuote() to check state availability and collect rider codes.
|
|
78
|
+
* @param stateCode - Two-letter US state abbreviation (e.g. "AZ"). CA is not supported.
|
|
79
|
+
* @returns Promise with riders list and flagProductNotAvailableForState flag
|
|
80
|
+
*/
|
|
81
|
+
async getRiderDetails(stateCode) {
|
|
82
|
+
return this.get('get ADB rider details', '/api/ThirdPartyAdbLookup/get-rider-details', {
|
|
83
|
+
params: { stateCode },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.AdbService = AdbService;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
import { BaseService } from './base.service';
|
|
2
3
|
import { ThirdPartyStartApplicationReq, ThirdPartyStartAppResp, ThirdPartyFinalSubmitResp } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* Application service for starting insurance applications from quotes
|
|
5
6
|
*/
|
|
6
|
-
export declare class ApplicationService {
|
|
7
|
-
private readonly httpClient;
|
|
7
|
+
export declare class ApplicationService extends BaseService {
|
|
8
8
|
constructor(httpClient: HttpClient);
|
|
9
9
|
/**
|
|
10
10
|
* Start an insurance application based on a quote response ID
|
|
@@ -21,4 +21,3 @@ export declare class ApplicationService {
|
|
|
21
21
|
*/
|
|
22
22
|
finalSubmit(opportunityId: string): Promise<ThirdPartyFinalSubmitResp>;
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=application.service.d.ts.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApplicationService = void 0;
|
|
4
|
-
const
|
|
5
|
-
const types_1 = require("../types");
|
|
4
|
+
const base_service_1 = require("./base.service");
|
|
6
5
|
/**
|
|
7
6
|
* Application service for starting insurance applications from quotes
|
|
8
7
|
*/
|
|
9
|
-
class ApplicationService {
|
|
8
|
+
class ApplicationService extends base_service_1.BaseService {
|
|
10
9
|
constructor(httpClient) {
|
|
11
|
-
|
|
10
|
+
super(httpClient);
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* Start an insurance application based on a quote response ID
|
|
@@ -16,27 +15,7 @@ class ApplicationService {
|
|
|
16
15
|
* @returns Promise with the application response containing links
|
|
17
16
|
*/
|
|
18
17
|
async startApplication(applicationRequest) {
|
|
19
|
-
|
|
20
|
-
if (!this.httpClient.isAuthenticated()) {
|
|
21
|
-
throw new types_1.AuthenticationError('Must be authenticated to start applications. Call authenticate() first.');
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
const response = await this.httpClient.post('/api/ThirdPartyIbTermStartApp/start-application', applicationRequest);
|
|
25
|
-
// Check if the response was successful
|
|
26
|
-
if (!response.flagStatus) {
|
|
27
|
-
throw new types_1.InstaBrainError(response.error || 'Failed to start application');
|
|
28
|
-
}
|
|
29
|
-
if (!response.value) {
|
|
30
|
-
throw new types_1.InstaBrainError('No application data received from server');
|
|
31
|
-
}
|
|
32
|
-
return response.value;
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
if (error instanceof types_1.InstaBrainError) {
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
throw new types_1.InstaBrainError('Failed to start application: ' + error.message);
|
|
39
|
-
}
|
|
18
|
+
return this.post('start application', '/api/ThirdPartyIbTermStartApp/start-application', applicationRequest);
|
|
40
19
|
}
|
|
41
20
|
/**
|
|
42
21
|
* Submit the application to the carrier for a final underwriting decision
|
|
@@ -46,33 +25,7 @@ class ApplicationService {
|
|
|
46
25
|
* @returns Promise with the final submit response containing policyNumber
|
|
47
26
|
*/
|
|
48
27
|
async finalSubmit(opportunityId) {
|
|
49
|
-
|
|
50
|
-
throw new types_1.AuthenticationError('Must be authenticated to submit application. Call authenticate() first.');
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
const response = await this.httpClient.post('/api/ThirdPartyApplication/final-submit', null, { params: { opportunityId } });
|
|
54
|
-
if (!response.flagStatus) {
|
|
55
|
-
const errorMessage = response.error || 'Failed to submit application';
|
|
56
|
-
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
57
|
-
if (errorCode) {
|
|
58
|
-
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
throw new types_1.InstaBrainError(errorMessage, 400, response);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (!response.value) {
|
|
65
|
-
throw new types_1.InstaBrainError('No final submit data received from server');
|
|
66
|
-
}
|
|
67
|
-
return response.value;
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error instanceof types_1.InstaBrainError) {
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
throw new types_1.InstaBrainError('Failed to submit application: ' + error.message);
|
|
74
|
-
}
|
|
28
|
+
return this.post('submit application', '/api/ThirdPartyApplication/final-submit', null, { params: { opportunityId } });
|
|
75
29
|
}
|
|
76
30
|
}
|
|
77
31
|
exports.ApplicationService = ApplicationService;
|
|
78
|
-
//# sourceMappingURL=application.service.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { HttpClient } from '../utils/http-client';
|
|
3
|
+
/**
|
|
4
|
+
* Base service class that provides shared request execution logic.
|
|
5
|
+
* All API services extend this to eliminate duplicated auth checks,
|
|
6
|
+
* response validation, error extraction, and catch wrapping.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class BaseService {
|
|
9
|
+
protected readonly httpClient: HttpClient;
|
|
10
|
+
constructor(httpClient: HttpClient);
|
|
11
|
+
/**
|
|
12
|
+
* Ensure the client is authenticated before making an API call.
|
|
13
|
+
* @param action - Human-readable action name for the error message
|
|
14
|
+
*/
|
|
15
|
+
protected requireAuth(action: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Execute a POST request with standard response handling.
|
|
18
|
+
* Handles: auth check, flagStatus validation, error code extraction, value null check, and error wrapping.
|
|
19
|
+
*
|
|
20
|
+
* @param action - Human-readable action name (e.g. "get quote")
|
|
21
|
+
* @param url - API endpoint path
|
|
22
|
+
* @param data - Request body (null for query-param-only calls)
|
|
23
|
+
* @param config - Optional Axios config (e.g. { params: { opportunityId } })
|
|
24
|
+
* @param allowNullValue - If true, skips the null-value check (used by saveEftPayment)
|
|
25
|
+
* @returns The response value of type T
|
|
26
|
+
*/
|
|
27
|
+
protected post<T>(action: string, url: string, data: unknown, config?: AxiosRequestConfig, allowNullValue?: boolean): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Execute a GET request with standard response handling.
|
|
30
|
+
*
|
|
31
|
+
* @param action - Human-readable action name
|
|
32
|
+
* @param url - API endpoint path
|
|
33
|
+
* @param config - Optional Axios config (e.g. { params: { opportunityId } })
|
|
34
|
+
* @returns The response value of type T
|
|
35
|
+
*/
|
|
36
|
+
protected get<T>(action: string, url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Validate an API response: check flagStatus, extract error codes, and verify value.
|
|
39
|
+
*/
|
|
40
|
+
private handleResponse;
|
|
41
|
+
/**
|
|
42
|
+
* Re-throw InstaBrainError subclasses as-is; wrap anything else.
|
|
43
|
+
*/
|
|
44
|
+
private rethrowOrWrap;
|
|
45
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseService = void 0;
|
|
4
|
+
const error_utils_1 = require("../utils/error-utils");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
/**
|
|
7
|
+
* Base service class that provides shared request execution logic.
|
|
8
|
+
* All API services extend this to eliminate duplicated auth checks,
|
|
9
|
+
* response validation, error extraction, and catch wrapping.
|
|
10
|
+
*/
|
|
11
|
+
class BaseService {
|
|
12
|
+
constructor(httpClient) {
|
|
13
|
+
this.httpClient = httpClient;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Ensure the client is authenticated before making an API call.
|
|
17
|
+
* @param action - Human-readable action name for the error message
|
|
18
|
+
*/
|
|
19
|
+
requireAuth(action) {
|
|
20
|
+
if (!this.httpClient.isAuthenticated()) {
|
|
21
|
+
throw new types_1.AuthenticationError(`Must be authenticated to ${action}. Call authenticate() first.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Execute a POST request with standard response handling.
|
|
26
|
+
* Handles: auth check, flagStatus validation, error code extraction, value null check, and error wrapping.
|
|
27
|
+
*
|
|
28
|
+
* @param action - Human-readable action name (e.g. "get quote")
|
|
29
|
+
* @param url - API endpoint path
|
|
30
|
+
* @param data - Request body (null for query-param-only calls)
|
|
31
|
+
* @param config - Optional Axios config (e.g. { params: { opportunityId } })
|
|
32
|
+
* @param allowNullValue - If true, skips the null-value check (used by saveEftPayment)
|
|
33
|
+
* @returns The response value of type T
|
|
34
|
+
*/
|
|
35
|
+
async post(action, url, data, config, allowNullValue = false) {
|
|
36
|
+
this.requireAuth(action);
|
|
37
|
+
try {
|
|
38
|
+
const response = await this.httpClient.post(url, data, config);
|
|
39
|
+
return this.handleResponse(response, action, allowNullValue);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
this.rethrowOrWrap(error, action);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execute a GET request with standard response handling.
|
|
47
|
+
*
|
|
48
|
+
* @param action - Human-readable action name
|
|
49
|
+
* @param url - API endpoint path
|
|
50
|
+
* @param config - Optional Axios config (e.g. { params: { opportunityId } })
|
|
51
|
+
* @returns The response value of type T
|
|
52
|
+
*/
|
|
53
|
+
async get(action, url, config) {
|
|
54
|
+
this.requireAuth(action);
|
|
55
|
+
try {
|
|
56
|
+
const response = await this.httpClient.get(url, config);
|
|
57
|
+
return this.handleResponse(response, action);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
this.rethrowOrWrap(error, action);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Validate an API response: check flagStatus, extract error codes, and verify value.
|
|
65
|
+
*/
|
|
66
|
+
handleResponse(response, action, allowNullValue = false) {
|
|
67
|
+
if (!response.flagStatus) {
|
|
68
|
+
const errorMessage = response.error || `Failed to ${action}`;
|
|
69
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
70
|
+
if (errorCode) {
|
|
71
|
+
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
throw new types_1.InstaBrainError(errorMessage, 400, response);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!allowNullValue && !response.value) {
|
|
78
|
+
throw new types_1.InstaBrainError(`No ${action} data received from server`);
|
|
79
|
+
}
|
|
80
|
+
return response.value;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Re-throw InstaBrainError subclasses as-is; wrap anything else.
|
|
84
|
+
*/
|
|
85
|
+
rethrowOrWrap(error, action) {
|
|
86
|
+
if (error instanceof types_1.InstaBrainError) {
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
throw new types_1.InstaBrainError(`Failed to ${action}: ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.BaseService = BaseService;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
import { BaseService } from './base.service';
|
|
2
3
|
import { ThirdPartyGigdbQuoteRequest, ThirdPartyGigdbUpdateQuoteReq, ThirdPartyGigdbAppReq, ThirdPartyEftPaymentReq, ThirdPartyQuoteResp, ThirdPartyStartAppResp } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* GIGDB (Guaranteed Issue Group Decreasing Benefit) service
|
|
5
6
|
* Handles quote, application, and EFT payment for the GIGDB product (ages 50-85, $5k-$25k)
|
|
6
7
|
*/
|
|
7
|
-
export declare class GigdbService {
|
|
8
|
-
private readonly httpClient;
|
|
8
|
+
export declare class GigdbService extends BaseService {
|
|
9
9
|
constructor(httpClient: HttpClient);
|
|
10
10
|
/**
|
|
11
11
|
* Get a GIGDB insurance quote
|
|
@@ -41,4 +41,3 @@ export declare class GigdbService {
|
|
|
41
41
|
*/
|
|
42
42
|
getExistingQuote(opportunityId: string): Promise<ThirdPartyQuoteResp>;
|
|
43
43
|
}
|
|
44
|
-
//# sourceMappingURL=gigdb.service.d.ts.map
|