@instabrain-sdks/api-client 1.0.0 → 2.0.1
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 +237 -22
- package/dist/client/instabrain-client.d.ts +73 -1
- package/dist/client/instabrain-client.d.ts.map +1 -1
- package/dist/client/instabrain-client.js +94 -0
- package/dist/client/instabrain-client.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -11
- package/dist/index.js.map +1 -1
- package/dist/services/application.service.d.ts +10 -2
- package/dist/services/application.service.d.ts.map +1 -1
- package/dist/services/application.service.js +36 -0
- package/dist/services/application.service.js.map +1 -1
- package/dist/services/auth.service.d.ts +1 -1
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/gigdb.service.d.ts +44 -0
- package/dist/services/gigdb.service.d.ts.map +1 -0
- package/dist/services/gigdb.service.js +182 -0
- package/dist/services/gigdb.service.js.map +1 -0
- package/dist/services/quote.service.d.ts +1 -7
- package/dist/services/quote.service.d.ts.map +1 -1
- package/dist/services/quote.service.js +2 -33
- package/dist/services/quote.service.js.map +1 -1
- package/dist/services/reports.service.d.ts +1 -7
- package/dist/services/reports.service.d.ts.map +1 -1
- package/dist/services/reports.service.js +4 -41
- package/dist/services/reports.service.js.map +1 -1
- package/dist/services/secure-sign.service.d.ts +48 -0
- package/dist/services/secure-sign.service.d.ts.map +1 -0
- package/dist/services/secure-sign.service.js +161 -0
- package/dist/services/secure-sign.service.js.map +1 -0
- package/dist/types/application.types.d.ts +4 -0
- package/dist/types/application.types.d.ts.map +1 -1
- package/dist/types/enums.d.ts +23 -1
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/enums.js +25 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +26 -1
- package/dist/types/errors.js.map +1 -1
- package/dist/types/gigdb.types.d.ts +98 -0
- package/dist/types/gigdb.types.d.ts.map +1 -0
- package/dist/types/gigdb.types.js +3 -0
- package/dist/types/gigdb.types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/secure-sign.types.d.ts +82 -0
- package/dist/types/secure-sign.types.d.ts.map +1 -0
- package/dist/types/secure-sign.types.js +5 -0
- package/dist/types/secure-sign.types.js.map +1 -0
- package/dist/utils/error-utils.d.ts +13 -0
- package/dist/utils/error-utils.d.ts.map +1 -0
- package/dist/utils/error-utils.js +31 -0
- package/dist/utils/error-utils.js.map +1 -0
- package/package.json +55 -51
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApplicationService = void 0;
|
|
4
|
+
const error_utils_1 = require("../utils/error-utils");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
/**
|
|
6
7
|
* Application service for starting insurance applications from quotes
|
|
@@ -37,6 +38,41 @@ class ApplicationService {
|
|
|
37
38
|
throw new types_1.InstaBrainError('Failed to start application: ' + error.message);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Submit the application to the carrier for a final underwriting decision
|
|
43
|
+
* Shared across all products. Call after the signing flow is complete.
|
|
44
|
+
* Note: A null policyNumber does not indicate failure — it means the carrier has not yet issued a number (pending decision).
|
|
45
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
46
|
+
* @returns Promise with the final submit response containing policyNumber
|
|
47
|
+
*/
|
|
48
|
+
async finalSubmit(opportunityId) {
|
|
49
|
+
if (!this.httpClient.isAuthenticated()) {
|
|
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
|
+
}
|
|
75
|
+
}
|
|
40
76
|
}
|
|
41
77
|
exports.ApplicationService = ApplicationService;
|
|
42
78
|
//# sourceMappingURL=application.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.service.js","sourceRoot":"","sources":["../../src/services/application.service.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"application.service.js","sourceRoot":"","sources":["../../src/services/application.service.ts"],"names":[],"mappings":";;;AACA,sDAAwD;AACxD,oCAQkB;AAElB;;GAEG;AACH,MAAa,kBAAkB;IAC7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,kBAAiD;QACtE,yBAAyB;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,2BAAmB,CAAC,yEAAyE,CAAC,CAAC;QAC3G,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAA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C;qBAAM,CAAC;oBACN,MAAM,IAAI,uBAAe,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;gBACzD,CAAC;YACH,CAAC;YAED,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACpB,MAAM,IAAI,uBAAe,CAAC,2CAA2C,CAAC,CAAC;YACzE,CAAC;YAED,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,uBAAe,EAAE,CAAC;gBACrC,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,IAAI,uBAAe,CAAC,gCAAgC,GAAI,KAAe,CAAC,OAAO,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;CACF;AAhFD,gDAgFC"}
|
|
@@ -3,7 +3,7 @@ import { HttpClient } from '../utils/http-client';
|
|
|
3
3
|
* Authentication service for managing JWT tokens and authorization
|
|
4
4
|
*/
|
|
5
5
|
export declare class AuthService {
|
|
6
|
-
private httpClient;
|
|
6
|
+
private readonly httpClient;
|
|
7
7
|
constructor(httpClient: HttpClient);
|
|
8
8
|
/**
|
|
9
9
|
* Authenticate with the InstaBrain API and obtain a JWT token
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAQlD;;GAEG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAQlD;;GAEG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEnD;;;;;OAKG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmCxE;;;OAGG;IACH,eAAe,IAAI,OAAO;IAI1B;;;OAGG;IACH,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAG9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":";;;AACA,oCAKkB;AAElB;;GAEG;AACH,MAAa,WAAW;IACtB,
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":";;;AACA,oCAKkB;AAElB;;GAEG;AACH,MAAa,WAAW;IACtB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,WAAmB;;QACpD,IAAI,CAAC;YACH,MAAM,OAAO,GAAyB;gBACpC,MAAM;gBACN,WAAW;aACZ,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CACzC,sBAAsB,EACtB,OAAO,CACR,CAAC;YAEF,uCAAuC;YACvC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACzB,MAAM,IAAI,2BAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,uBAAuB,CAAC,CAAC;YAC3E,CAAC;YAED,MAAM,QAAQ,GAAG,MAAA,QAAQ,CAAC,KAAK,0CAAE,QAAQ,CAAC;YAE1C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,2BAAmB,CAAC,mCAAmC,CAAC,CAAC;YACrE,CAAC;YAED,8FAA8F;YAC9F,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAExD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qDAAqD;YACrD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AA1ED,kCA0EC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
import { ThirdPartyGigdbQuoteRequest, ThirdPartyGigdbUpdateQuoteReq, ThirdPartyGigdbAppReq, ThirdPartyEftPaymentReq, ThirdPartyQuoteResp, ThirdPartyStartAppResp } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* GIGDB (Guaranteed Issue Group Decreasing Benefit) service
|
|
5
|
+
* Handles quote, application, and EFT payment for the GIGDB product (ages 50-85, $5k-$25k)
|
|
6
|
+
*/
|
|
7
|
+
export declare class GigdbService {
|
|
8
|
+
private readonly httpClient;
|
|
9
|
+
constructor(httpClient: HttpClient);
|
|
10
|
+
/**
|
|
11
|
+
* Get a GIGDB insurance quote
|
|
12
|
+
* @param request - The GIGDB quote request parameters
|
|
13
|
+
* @returns Promise with the quote response
|
|
14
|
+
*/
|
|
15
|
+
getQuote(request: ThirdPartyGigdbQuoteRequest): Promise<ThirdPartyQuoteResp>;
|
|
16
|
+
/**
|
|
17
|
+
* Start a GIGDB application from a quote
|
|
18
|
+
* Note: isDeclined=true is a valid success response (knockout), not an error
|
|
19
|
+
* @param request - The GIGDB application request parameters
|
|
20
|
+
* @returns Promise with the application response
|
|
21
|
+
*/
|
|
22
|
+
startApplication(request: ThirdPartyGigdbAppReq): Promise<ThirdPartyStartAppResp>;
|
|
23
|
+
/**
|
|
24
|
+
* Save EFT payment details for a GIGDB application
|
|
25
|
+
* @param request - The EFT payment request with account details
|
|
26
|
+
* @returns Promise with payment validation response
|
|
27
|
+
*/
|
|
28
|
+
saveEftPayment(request: ThirdPartyEftPaymentReq): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Update a GIGDB quote with a different face amount or payment frequency
|
|
31
|
+
* Use after application has been started to re-quote for the same opportunity
|
|
32
|
+
* @param request - The update quote request with opportunityId, faceAmount, and paymentFreq
|
|
33
|
+
* @returns Promise with the updated quote response
|
|
34
|
+
*/
|
|
35
|
+
updateQuote(request: ThirdPartyGigdbUpdateQuoteReq): Promise<ThirdPartyQuoteResp>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the existing quote for a GIGDB opportunity
|
|
38
|
+
* Use when startApplication returns isQuoteChanged=true to get the updated quote
|
|
39
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
40
|
+
* @returns Promise with the current quote response
|
|
41
|
+
*/
|
|
42
|
+
getExistingQuote(opportunityId: string): Promise<ThirdPartyQuoteResp>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=gigdb.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gigdb.service.d.ts","sourceRoot":"","sources":["../../src/services/gigdb.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EAKvB,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEnD;;;;OAIG;IACG,QAAQ,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmClF;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmCvF;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC;IA+BxE;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmCvF;;;;;OAKG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAmC5E"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GigdbService = void 0;
|
|
4
|
+
const error_utils_1 = require("../utils/error-utils");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
/**
|
|
7
|
+
* GIGDB (Guaranteed Issue Group Decreasing Benefit) service
|
|
8
|
+
* Handles quote, application, and EFT payment for the GIGDB product (ages 50-85, $5k-$25k)
|
|
9
|
+
*/
|
|
10
|
+
class GigdbService {
|
|
11
|
+
constructor(httpClient) {
|
|
12
|
+
this.httpClient = httpClient;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get a GIGDB insurance quote
|
|
16
|
+
* @param request - The GIGDB quote request parameters
|
|
17
|
+
* @returns Promise with the quote response
|
|
18
|
+
*/
|
|
19
|
+
async getQuote(request) {
|
|
20
|
+
if (!this.httpClient.isAuthenticated()) {
|
|
21
|
+
throw new types_1.AuthenticationError('Must be authenticated to get GIGDB quote. Call authenticate() first.');
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const response = await this.httpClient.post('/api/ThirdPartyIbGigdbQuote/get', request);
|
|
25
|
+
if (!response.flagStatus) {
|
|
26
|
+
const errorMessage = response.error || 'Failed to get GIGDB quote';
|
|
27
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
28
|
+
if (errorCode) {
|
|
29
|
+
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new types_1.InstaBrainError(errorMessage, 400, response);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!response.value) {
|
|
36
|
+
throw new types_1.InstaBrainError('No GIGDB quote data received from server');
|
|
37
|
+
}
|
|
38
|
+
return response.value;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof types_1.InstaBrainError) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
throw new types_1.InstaBrainError('Failed to get GIGDB quote: ' + error.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Start a GIGDB application from a quote
|
|
49
|
+
* Note: isDeclined=true is a valid success response (knockout), not an error
|
|
50
|
+
* @param request - The GIGDB application request parameters
|
|
51
|
+
* @returns Promise with the application response
|
|
52
|
+
*/
|
|
53
|
+
async startApplication(request) {
|
|
54
|
+
if (!this.httpClient.isAuthenticated()) {
|
|
55
|
+
throw new types_1.AuthenticationError('Must be authenticated to start GIGDB application. Call authenticate() first.');
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const response = await this.httpClient.post('/api/ThirdPartyGigdbApplication/start-application', request);
|
|
59
|
+
if (!response.flagStatus) {
|
|
60
|
+
const errorMessage = response.error || 'Failed to start GIGDB application';
|
|
61
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
62
|
+
if (errorCode) {
|
|
63
|
+
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new types_1.InstaBrainError(errorMessage, 400, response);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!response.value) {
|
|
70
|
+
throw new types_1.InstaBrainError('No GIGDB application data received from server');
|
|
71
|
+
}
|
|
72
|
+
return response.value;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof types_1.InstaBrainError) {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
throw new types_1.InstaBrainError('Failed to start GIGDB application: ' + error.message);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Save EFT payment details for a GIGDB application
|
|
83
|
+
* @param request - The EFT payment request with account details
|
|
84
|
+
* @returns Promise with payment validation response
|
|
85
|
+
*/
|
|
86
|
+
async saveEftPayment(request) {
|
|
87
|
+
var _a;
|
|
88
|
+
if (!this.httpClient.isAuthenticated()) {
|
|
89
|
+
throw new types_1.AuthenticationError('Must be authenticated to save EFT payment. Call authenticate() first.');
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const response = await this.httpClient.post('/api/ThirdPartyPayment/save-eft-payment', request);
|
|
93
|
+
if (!response.flagStatus) {
|
|
94
|
+
const errorMessage = response.error || 'Failed to save EFT payment';
|
|
95
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
96
|
+
if (errorCode) {
|
|
97
|
+
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new types_1.InstaBrainError(errorMessage, 400, response);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return (_a = response.value) !== null && _a !== void 0 ? _a : true;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof types_1.InstaBrainError) {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
throw new types_1.InstaBrainError('Failed to save EFT payment: ' + error.message);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Update a GIGDB quote with a different face amount or payment frequency
|
|
114
|
+
* Use after application has been started to re-quote for the same opportunity
|
|
115
|
+
* @param request - The update quote request with opportunityId, faceAmount, and paymentFreq
|
|
116
|
+
* @returns Promise with the updated quote response
|
|
117
|
+
*/
|
|
118
|
+
async updateQuote(request) {
|
|
119
|
+
if (!this.httpClient.isAuthenticated()) {
|
|
120
|
+
throw new types_1.AuthenticationError('Must be authenticated to update GIGDB quote. Call authenticate() first.');
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const response = await this.httpClient.post('/api/ThirdPartyIbGigdbQuote/update', request);
|
|
124
|
+
if (!response.flagStatus) {
|
|
125
|
+
const errorMessage = response.error || 'Failed to update GIGDB quote';
|
|
126
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
127
|
+
if (errorCode) {
|
|
128
|
+
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new types_1.InstaBrainError(errorMessage, 400, response);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!response.value) {
|
|
135
|
+
throw new types_1.InstaBrainError('No GIGDB quote data received from server');
|
|
136
|
+
}
|
|
137
|
+
return response.value;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (error instanceof types_1.InstaBrainError) {
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
throw new types_1.InstaBrainError('Failed to update GIGDB quote: ' + error.message);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get the existing quote for a GIGDB opportunity
|
|
148
|
+
* Use when startApplication returns isQuoteChanged=true to get the updated quote
|
|
149
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
150
|
+
* @returns Promise with the current quote response
|
|
151
|
+
*/
|
|
152
|
+
async getExistingQuote(opportunityId) {
|
|
153
|
+
if (!this.httpClient.isAuthenticated()) {
|
|
154
|
+
throw new types_1.AuthenticationError('Must be authenticated to get existing GIGDB quote. Call authenticate() first.');
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const response = await this.httpClient.get('/api/ThirdPartyIbGigdbQuote/get-existing-quote', { params: { opportunityId } });
|
|
158
|
+
if (!response.flagStatus) {
|
|
159
|
+
const errorMessage = response.error || 'Failed to get existing GIGDB quote';
|
|
160
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
161
|
+
if (errorCode) {
|
|
162
|
+
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
throw new types_1.InstaBrainError(errorMessage, 400, response);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (!response.value) {
|
|
169
|
+
throw new types_1.InstaBrainError('No GIGDB quote data received from server');
|
|
170
|
+
}
|
|
171
|
+
return response.value;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
if (error instanceof types_1.InstaBrainError) {
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
throw new types_1.InstaBrainError('Failed to get existing GIGDB quote: ' + error.message);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.GigdbService = GigdbService;
|
|
182
|
+
//# sourceMappingURL=gigdb.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gigdb.service.js","sourceRoot":"","sources":["../../src/services/gigdb.service.ts"],"names":[],"mappings":";;;AACA,sDAAwD;AACxD,oCAWkB;AAElB;;;GAGG;AACH,MAAa,YAAY;IACvB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD;;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Q,CAAC,CAAC;gBACzD,CAAC;YACH,CAAC;YAED,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACpB,MAAM,IAAI,uBAAe,CAAC,0CAA0C,CAAC,CAAC;YACxE,CAAC;YAED,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,uBAAe,EAAE,CAAC;gBACrC,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,IAAI,uBAAe,CAAC,sCAAsC,GAAI,KAAe,CAAC,OAAO,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;CAEF;AA1MD,oCA0MC"}
|
|
@@ -4,7 +4,7 @@ import { ThirdPartyQuoteReq, ThirdPartyQuoteResp } from '../types';
|
|
|
4
4
|
* Quote service for getting insurance quotes from the InstaBrain API
|
|
5
5
|
*/
|
|
6
6
|
export declare class QuoteService {
|
|
7
|
-
private httpClient;
|
|
7
|
+
private readonly httpClient;
|
|
8
8
|
constructor(httpClient: HttpClient);
|
|
9
9
|
/**
|
|
10
10
|
* Get an insurance quote based on the provided parameters
|
|
@@ -22,11 +22,5 @@ export declare class QuoteService {
|
|
|
22
22
|
* @returns Promise with the quote response
|
|
23
23
|
*/
|
|
24
24
|
getQuote(quoteRequest: ThirdPartyQuoteReq): Promise<ThirdPartyQuoteResp>;
|
|
25
|
-
/**
|
|
26
|
-
* Extract error code from API response
|
|
27
|
-
* @param response - The API response
|
|
28
|
-
* @returns The error code if found, null otherwise
|
|
29
|
-
*/
|
|
30
|
-
private extractErrorCode;
|
|
31
25
|
}
|
|
32
26
|
//# sourceMappingURL=quote.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.service.d.ts","sourceRoot":"","sources":["../../src/services/quote.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"quote.service.d.ts","sourceRoot":"","sources":["../../src/services/quote.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAKpB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEnD;;;;;;;;;;;;;;OAcG;IACG,QAAQ,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAwC/E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QuoteService = void 0;
|
|
4
|
+
const error_utils_1 = require("../utils/error-utils");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
/**
|
|
6
7
|
* Quote service for getting insurance quotes from the InstaBrain API
|
|
@@ -36,7 +37,7 @@ class QuoteService {
|
|
|
36
37
|
// Handle API validation errors with specific error codes
|
|
37
38
|
const errorMessage = response.error || 'Failed to get quote';
|
|
38
39
|
// Try to extract error code from response
|
|
39
|
-
const errorCode =
|
|
40
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
40
41
|
if (errorCode) {
|
|
41
42
|
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
42
43
|
}
|
|
@@ -56,38 +57,6 @@ class QuoteService {
|
|
|
56
57
|
throw new types_1.InstaBrainError('Failed to get quote: ' + error.message);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Extract error code from API response
|
|
61
|
-
* @param response - The API response
|
|
62
|
-
* @returns The error code if found, null otherwise
|
|
63
|
-
*/
|
|
64
|
-
extractErrorCode(response) {
|
|
65
|
-
// The API documentation indicates that error codes are returned
|
|
66
|
-
// when flagStatus is false. The exact format may vary.
|
|
67
|
-
// Common patterns to check:
|
|
68
|
-
// Check if error code is directly in the response
|
|
69
|
-
if (response.errorCode) {
|
|
70
|
-
return response.errorCode;
|
|
71
|
-
}
|
|
72
|
-
// Check if error code is in error message or nested structure
|
|
73
|
-
if (response.error && typeof response.error === 'string') {
|
|
74
|
-
// Known API error codes from documentation
|
|
75
|
-
const knownErrorCodes = [
|
|
76
|
-
'stateNotFound', 'RateClassNotFound', 'RiderNotAvailable',
|
|
77
|
-
'HeightNotValid', 'InvalidRateclass', 'InvalidHealthClass',
|
|
78
|
-
'ZipCodeNotFound', 'outsideBuildChart', 'QuoteNotEligibleForGivenConditions',
|
|
79
|
-
'NotAvailableForState', 'BenefitPeriodNotAvailable', 'CoverageNotAvailable',
|
|
80
|
-
'RiderFaceAmountNotValid'
|
|
81
|
-
];
|
|
82
|
-
// Try to find error code in the error message
|
|
83
|
-
for (const errorCode of knownErrorCodes) {
|
|
84
|
-
if (response.error.includes(errorCode)) {
|
|
85
|
-
return errorCode;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
60
|
}
|
|
92
61
|
exports.QuoteService = QuoteService;
|
|
93
62
|
//# sourceMappingURL=quote.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.service.js","sourceRoot":"","sources":["../../src/services/quote.service.ts"],"names":[],"mappings":";;;AACA,oCAOkB;AAElB;;GAEG;AACH,MAAa,YAAY;IACvB,
|
|
1
|
+
{"version":3,"file":"quote.service.js","sourceRoot":"","sources":["../../src/services/quote.service.ts"],"names":[],"mappings":";;;AACA,sDAAwD;AACxD,oCAOkB;AAElB;;GAEG;AACH,MAAa,YAAY;IACvB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,QAAQ,CAAC,YAAgC;QAC7C,yBAAyB;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,2BAAmB,CAAC,iEAAiE,CAAC,CAAC;QACnG,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CACzC,gCAAgC,EAChC,YAAY,CACb,CAAC;YAEF,uCAAuC;YACvC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACzB,yDAAyD;gBACzD,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,IAAI,qBAAqB,CAAC;gBAE7D,0CAA0C;gBAC1C,MAAM,SAAS,GAAG,IAAA,8BAAgB,EAAC,QAAQ,CAAC,CAAC;gBAE7C,IAAI,SAAS,EAAE,CAAC;oBACd,MAAM,IAAI,0BAAkB,CAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;gBAClE,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,uBAAe,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;gBACzD,CAAC;YACH,CAAC;YAED,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACpB,MAAM,IAAI,uBAAe,CAAC,oCAAoC,CAAC,CAAC;YAClE,CAAC;YAED,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,uBAAe,EAAE,CAAC;gBACrC,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,IAAI,uBAAe,CAAC,uBAAuB,GAAI,KAAe,CAAC,OAAO,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;CAEF;AA1DD,oCA0DC"}
|
|
@@ -5,7 +5,7 @@ import { AgentPortalReq, ThirdPartyProspectsResp, ThirdPartySalesReportRes, Thir
|
|
|
5
5
|
* These APIs provide dashboard-ready data for agent portals and reporting systems
|
|
6
6
|
*/
|
|
7
7
|
export declare class ReportsService {
|
|
8
|
-
private httpClient;
|
|
8
|
+
private readonly httpClient;
|
|
9
9
|
constructor(httpClient: HttpClient);
|
|
10
10
|
/**
|
|
11
11
|
* Get prospects data - quotes that haven't been converted to applications yet
|
|
@@ -54,11 +54,5 @@ export declare class ReportsService {
|
|
|
54
54
|
* @returns Promise with applications data including status and completion info
|
|
55
55
|
*/
|
|
56
56
|
getApplications(request: AgentPortalReq): Promise<ThirdPartyApplicationReportRes>;
|
|
57
|
-
/**
|
|
58
|
-
* Extract error code from API response
|
|
59
|
-
* @param response - The API response
|
|
60
|
-
* @returns The error code if found, null otherwise
|
|
61
|
-
*/
|
|
62
|
-
private extractErrorCode;
|
|
63
57
|
}
|
|
64
58
|
//# sourceMappingURL=reports.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.service.d.ts","sourceRoot":"","sources":["../../src/services/reports.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"reports.service.d.ts","sourceRoot":"","sources":["../../src/services/reports.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAK/B,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEnD;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAoC7E;;;;;;;;;;;;;;OAcG;IACG,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAoC1E;;;;;;;;;;;;;;;OAeG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,8BAA8B,CAAC;CAoCxF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReportsService = void 0;
|
|
4
|
+
const error_utils_1 = require("../utils/error-utils");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
/**
|
|
6
7
|
* Reports service for getting prospects, sales, and applications data from InstaBrain API
|
|
@@ -30,12 +31,9 @@ class ReportsService {
|
|
|
30
31
|
}
|
|
31
32
|
try {
|
|
32
33
|
const response = await this.httpClient.post('/api/ThirdParty/get-prospects', request);
|
|
33
|
-
// Check if the response was successful
|
|
34
34
|
if (!response.flagStatus) {
|
|
35
|
-
// Handle API validation errors with specific error codes
|
|
36
35
|
const errorMessage = response.error || 'Failed to get prospects';
|
|
37
|
-
|
|
38
|
-
const errorCode = this.extractErrorCode(response);
|
|
36
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
39
37
|
if (errorCode) {
|
|
40
38
|
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
41
39
|
}
|
|
@@ -77,12 +75,9 @@ class ReportsService {
|
|
|
77
75
|
}
|
|
78
76
|
try {
|
|
79
77
|
const response = await this.httpClient.post('/api/ThirdParty/get-sales', request);
|
|
80
|
-
// Check if the response was successful
|
|
81
78
|
if (!response.flagStatus) {
|
|
82
|
-
// Handle API validation errors with specific error codes
|
|
83
79
|
const errorMessage = response.error || 'Failed to get sales';
|
|
84
|
-
|
|
85
|
-
const errorCode = this.extractErrorCode(response);
|
|
80
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
86
81
|
if (errorCode) {
|
|
87
82
|
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
88
83
|
}
|
|
@@ -125,12 +120,9 @@ class ReportsService {
|
|
|
125
120
|
}
|
|
126
121
|
try {
|
|
127
122
|
const response = await this.httpClient.post('/api/ThirdParty/get-application', request);
|
|
128
|
-
// Check if the response was successful
|
|
129
123
|
if (!response.flagStatus) {
|
|
130
|
-
// Handle API validation errors with specific error codes
|
|
131
124
|
const errorMessage = response.error || 'Failed to get applications';
|
|
132
|
-
|
|
133
|
-
const errorCode = this.extractErrorCode(response);
|
|
125
|
+
const errorCode = (0, error_utils_1.extractErrorCode)(response);
|
|
134
126
|
if (errorCode) {
|
|
135
127
|
throw new types_1.APIValidationError(errorMessage, errorCode, response);
|
|
136
128
|
}
|
|
@@ -150,35 +142,6 @@ class ReportsService {
|
|
|
150
142
|
throw new types_1.InstaBrainError('Failed to get applications: ' + error.message);
|
|
151
143
|
}
|
|
152
144
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Extract error code from API response
|
|
155
|
-
* @param response - The API response
|
|
156
|
-
* @returns The error code if found, null otherwise
|
|
157
|
-
*/
|
|
158
|
-
extractErrorCode(response) {
|
|
159
|
-
// Check if error code is directly in the response
|
|
160
|
-
if (response.errorCode) {
|
|
161
|
-
return response.errorCode;
|
|
162
|
-
}
|
|
163
|
-
// Check if error code is in error message or nested structure
|
|
164
|
-
if (response.error && typeof response.error === 'string') {
|
|
165
|
-
// Known API error codes from documentation
|
|
166
|
-
const knownErrorCodes = [
|
|
167
|
-
'stateNotFound', 'RateClassNotFound', 'RiderNotAvailable',
|
|
168
|
-
'HeightNotValid', 'InvalidRateclass', 'InvalidHealthClass',
|
|
169
|
-
'ZipCodeNotFound', 'outsideBuildChart', 'QuoteNotEligibleForGivenConditions',
|
|
170
|
-
'NotAvailableForState', 'BenefitPeriodNotAvailable', 'CoverageNotAvailable',
|
|
171
|
-
'RiderFaceAmountNotValid'
|
|
172
|
-
];
|
|
173
|
-
// Try to find error code in the error message
|
|
174
|
-
for (const errorCode of knownErrorCodes) {
|
|
175
|
-
if (response.error.includes(errorCode)) {
|
|
176
|
-
return errorCode;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
145
|
}
|
|
183
146
|
exports.ReportsService = ReportsService;
|
|
184
147
|
//# sourceMappingURL=reports.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.service.js","sourceRoot":"","sources":["../../src/services/reports.service.ts"],"names":[],"mappings":";;;AACA,oCASkB;AAElB;;;GAGG;AACH,MAAa,cAAc;IACzB,
|
|
1
|
+
{"version":3,"file":"reports.service.js","sourceRoot":"","sources":["../../src/services/reports.service.ts"],"names":[],"mappings":";;;AACA,sDAAwD;AACxD,oCASkB;AAElB;;;GAGG;AACH,MAAa,cAAc;IACzB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,YAAY,CAAC,OAAuB;QACxC,yBAAyB;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,2BAAmB,CAAC,oEAAoE,CAAC,CAAC;QACtG,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CACzC,+BAA+B,EAC/B,OAAO,CACR,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACzB,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,IAAI,yBAAyB,CAAC;gBACjE,MAAM,SAAS,GAAG,IAAA,8BAAgB,EAAC,QAAQ,CAAC,CAAC;gBAE7C,IAAI,SAAS,EAAE,CAAC;oBACd,MAAM,IAAI,0BAAkB,CAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;gBAClE,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,uBAAe,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;gBACzD,CAAC;YACH,CAAC;YAED,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACpB,MAAM,IAAI,uBAAe,CAAC,wCAAwC,CAAC,CAAC;YACtE,CAAC;YAED,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;AA3JD,wCA2JC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { HttpClient } from '../utils/http-client';
|
|
2
|
+
import { ThirdPartySendPinReq, ThirdPartyResendPinReq, ThirdPartyVerifyPinReq, ThirdPartyPrepareDocsResp, ThirdPartySendPinResp, ThirdPartyResendPinResp, ThirdPartyVerifyPinResp } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Secure Sign service for document signing flow
|
|
5
|
+
* Shared across all third-party products — not specific to GIGDB.
|
|
6
|
+
* Call these endpoints after EFT payment has been saved successfully.
|
|
7
|
+
*
|
|
8
|
+
* Typical flow:
|
|
9
|
+
* 1. prepareDocsAndGetDeliveryChannels() — prepare signing package, check channels
|
|
10
|
+
* 2. sendPinAndGetDocumentsLink() — send PIN via SMS/Email, get documents link
|
|
11
|
+
* 3. resendPin() (optional) — resend if signer didn't receive PIN
|
|
12
|
+
* 4. verifyPin() — verify PIN to complete signing
|
|
13
|
+
*/
|
|
14
|
+
export declare class SecureSignService {
|
|
15
|
+
private readonly httpClient;
|
|
16
|
+
constructor(httpClient: HttpClient);
|
|
17
|
+
/**
|
|
18
|
+
* Prepare the signing package and check available delivery channels
|
|
19
|
+
* Always call this first — it prepares the signing package.
|
|
20
|
+
* If isSignCompleted is true, skip the PIN flow and proceed to Final Submit.
|
|
21
|
+
* @param opportunityId - The OpportunityId from the Start Application response
|
|
22
|
+
* @returns Promise with delivery channels and sign completion status
|
|
23
|
+
*/
|
|
24
|
+
prepareDocsAndGetDeliveryChannels(opportunityId: string): Promise<ThirdPartyPrepareDocsResp>;
|
|
25
|
+
/**
|
|
26
|
+
* Send a verification PIN via SMS and/or Email and receive the documents link
|
|
27
|
+
* At least one of flagSendSms or flagSendEmail must be true.
|
|
28
|
+
* The returned script must be read aloud to the proposed insured before signing.
|
|
29
|
+
* @param request - The send PIN request with delivery preferences
|
|
30
|
+
* @returns Promise with documents link and disclosure script
|
|
31
|
+
*/
|
|
32
|
+
sendPinAndGetDocumentsLink(request: ThirdPartySendPinReq): Promise<ThirdPartySendPinResp>;
|
|
33
|
+
/**
|
|
34
|
+
* Resend the verification PIN if the signer did not receive it
|
|
35
|
+
* Unlike sendPinAndGetDocumentsLink, this does NOT return the documents link.
|
|
36
|
+
* @param request - The resend PIN request with delivery preferences
|
|
37
|
+
* @returns Promise with PIN sent confirmation
|
|
38
|
+
*/
|
|
39
|
+
resendPin(request: ThirdPartyResendPinReq): Promise<ThirdPartyResendPinResp>;
|
|
40
|
+
/**
|
|
41
|
+
* Verify the PIN entered by the signer to complete document signing
|
|
42
|
+
* The disclosure script must have been read aloud before calling this.
|
|
43
|
+
* @param request - The verify PIN request with PIN and script confirmation
|
|
44
|
+
* @returns Promise with verification result
|
|
45
|
+
*/
|
|
46
|
+
verifyPin(request: ThirdPartyVerifyPinReq): Promise<ThirdPartyVerifyPinResp>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=secure-sign.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-sign.service.d.ts","sourceRoot":"","sources":["../../src/services/secure-sign.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EAKxB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;GAUG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEnD;;;;;;OAMG;IACG,iCAAiC,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAmClG;;;;;;OAMG;IACG,0BAA0B,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAmC/F;;;;;OAKG;IACG,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmClF;;;;;OAKG;IACG,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAkCnF"}
|