@instabrain-sdks/api-client 2.4.0 → 2.6.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.
Files changed (34) hide show
  1. package/LICENSE.md +31 -0
  2. package/README.md +820 -81
  3. package/dist/client/instabrain-client.d.ts +170 -9
  4. package/dist/client/instabrain-client.js +189 -8
  5. package/dist/services/application.service.d.ts +29 -2
  6. package/dist/services/application.service.js +29 -2
  7. package/dist/services/finalexpense.service.d.ts +23 -5
  8. package/dist/services/finalexpense.service.js +23 -5
  9. package/dist/services/gigdb.service.d.ts +25 -3
  10. package/dist/services/gigdb.service.js +25 -3
  11. package/dist/services/payment.service.d.ts +94 -0
  12. package/dist/services/payment.service.js +161 -0
  13. package/dist/services/pivot.service.d.ts +104 -0
  14. package/dist/services/pivot.service.js +116 -0
  15. package/dist/services/pureterm.service.d.ts +96 -10
  16. package/dist/services/pureterm.service.js +100 -8
  17. package/dist/services/secure-sign.service.d.ts +19 -3
  18. package/dist/services/secure-sign.service.js +19 -3
  19. package/dist/types/enums.d.ts +112 -3
  20. package/dist/types/enums.js +134 -4
  21. package/dist/types/errors.js +31 -2
  22. package/dist/types/gigdb.types.d.ts +32 -0
  23. package/dist/types/ibterm.types.d.ts +5 -2
  24. package/dist/types/index.d.ts +2 -0
  25. package/dist/types/index.js +2 -0
  26. package/dist/types/payment.types.d.ts +52 -0
  27. package/dist/types/payment.types.js +3 -0
  28. package/dist/types/pivot.types.d.ts +122 -0
  29. package/dist/types/pivot.types.js +2 -0
  30. package/dist/types/pureterm.types.d.ts +186 -31
  31. package/dist/utils/error-utils.d.ts +9 -1
  32. package/dist/utils/error-utils.js +18 -3
  33. package/dist/utils/http-client.js +11 -2
  34. package/package.json +9 -4
@@ -1,31 +1,117 @@
1
1
  import { HttpClient } from '../utils/http-client';
2
2
  import { BaseService } from './base.service';
3
- import { ThirdPartyPureTermQuoteReq } from '../types/pureterm.types';
4
- import { ThirdPartyQuoteResp } from '../types';
3
+ import { ThirdPartyPureTermQuoteReq, PureTermRiderDetailsResp, PureTermStartApplicationReq } from '../types/pureterm.types';
4
+ import { ThirdPartyQuoteResp, ThirdPartyStartAppResp } from '../types';
5
5
  /**
6
6
  * Pure Term (InstaBrain Pure Term) service
7
- * Handles quoting for the Pure Term product.
7
+ * Handles lookup, quoting, and application for the Pure Term product (ages 18–60).
8
8
  *
9
9
  * Flow:
10
- * 1. getQuote() → quoteResponseId
11
- * 2. InstaBrainClient.startApplication() → agentLink / applicantLink / eAppAgentLink
10
+ * 1. (optional) getRiderDetails(stateCode, age, flagNicotineUse) → rider availability + codes
11
+ * 2. getQuote() → quoteResponseId
12
+ * 3. startApplication() → opportunityId + links (or isDeclined=true)
13
+ * 4. (optional) getExistingQuote(opportunityId) → re-fetch the stored quote
12
14
  *
13
15
  * After startApplication(), direct the agent or applicant to the returned link.
14
16
  * All remaining steps (underwriting, payment, signing) complete inside the
15
- * InstaBrain frontend. Do NOT call saveEftPayment(), SecureSign methods, or
16
- * finalSubmit() for Pure Term.
17
+ * InstaBrain frontend — the same hand-off family as IB Term. Do NOT wire a Pure
18
+ * Term `opportunityId` into the shared SecureSign, finalSubmit(), or credit-card
19
+ * iframe clients. Shared EFT (`saveEftPayment()`) is allowed; the credit-card
20
+ * iframe is not supported for Pure Term and returns
21
+ * `CcPaymentIframeNotSupportedForProduct`.
17
22
  */
18
23
  export declare class PureTermService extends BaseService {
19
24
  constructor(httpClient: HttpClient);
25
+ /**
26
+ * Get available riders for Pure Term in a given state, filtered by the
27
+ * applicant's age and nicotine-use status.
28
+ *
29
+ * Optional pre-quote step. When `flagProductNotAvailableForState` is `true`
30
+ * in the response, Pure Term is not available for these inputs (e.g. WY, NY) —
31
+ * do not proceed to the Quote API. The empty `riders` array in that case is a
32
+ * valid business state, not an error, and is returned as-is by the SDK.
33
+ *
34
+ * Use `riderCode` from the response as `riders[n].rider` on the Pure Term quote.
35
+ *
36
+ * @param stateCode - Two-letter US state code (e.g. "TX").
37
+ * @param age - Applicant's age, integer, 18–60 inclusive.
38
+ * @param flagNicotineUse - Whether the applicant uses nicotine; required by the backend.
39
+ * @returns Rider list + product availability flag.
40
+ */
41
+ getRiderDetails(stateCode: string, age: number, flagNicotineUse: boolean): Promise<PureTermRiderDetailsResp>;
20
42
  /**
21
43
  * Get a Pure Term insurance quote.
22
44
  *
23
- * Provide exactly one rating group: `rateClass`, OR `healthClass`, OR
24
- * both `height` and `weightInLbs`. `benefitPeriod` and `stateCode` are
25
- * required. Supply `age` OR `dateOfBirth` (18–60).
45
+ * `faceAmount`, `benefitPeriod`, `gender`, `stateCode`, and `paymentFreq` are
46
+ * required. Supply at least one rating group — `rateClass`, `healthClass`, or
47
+ * both `height` and `weightInLbs`; passing more than one is allowed. Supply
48
+ * `age` OR `dateOfBirth` (18–60); `dateOfBirth` wins when both are sent.
49
+ * `flagTobaccoUse` defaults to `false`.
50
+ *
51
+ * Pure Term uses the same quote request shape as IB Term but different product
52
+ * rules (rate classes including Rated C/D, term lengths including 15,
53
+ * coverage/benefit tables) — see {@link ThirdPartyPureTermQuoteReq} for the
54
+ * exact rules in check order.
55
+ *
56
+ * **Errors come from two stages.** Request validation issues dedicated
57
+ * top-level codes only for `BenefitPeriodNotAvailable` and
58
+ * `CoverageNotAvailable`; every other field failure surfaces as
59
+ * `InvalidRequestFormat` with PascalCase keys under `value.fields`. Once
60
+ * validation passes, the shared quote-eligibility pipeline can still return
61
+ * `NotAvailableForState`, `QuoteNotEligibleForGivenConditions`,
62
+ * `RiderNotAvailable`, `RiderFaceAmountNotValid`, or `outsideBuildChart` —
63
+ * do not assume those never occur for Pure Term.
26
64
  *
27
65
  * @param request - The Pure Term quote request payload.
28
66
  * @returns Promise with the quote response including `quoteResponseId`.
29
67
  */
30
68
  getQuote(request: ThirdPartyPureTermQuoteReq): Promise<ThirdPartyQuoteResp>;
69
+ /**
70
+ * Get the existing quote for an in-flight Pure Term opportunity.
71
+ *
72
+ * Use to resume or review a previously generated Pure Term quote by its
73
+ * opportunity ID without re-quoting. The response reuses the same shape as
74
+ * `getQuote()` — `productName` is `"InstaBrain Pure Term"`.
75
+ *
76
+ * Unlike rider-details product-unavailability, a not-found result here is an
77
+ * error (surfaced via the SDK error model), not a valid business state:
78
+ * - missing / empty / non-GUID `opportunityId` → `InvalidRequestFormat`
79
+ * ("OpportunityId is required." / "OpportunityId does not exist.")
80
+ * - opportunity belongs to a different product → "OpportunityId does not
81
+ * match selected product." (field-level message under `InvalidRequestFormat`)
82
+ * - opportunity exists but has no stored quote → `QuoteNotFound` (top-level, `value: null`)
83
+ *
84
+ * @param opportunityId - UUID from a prior Pure Term application/quote flow.
85
+ * @returns Promise with the current quote response.
86
+ */
87
+ getExistingQuote(opportunityId: string): Promise<ThirdPartyQuoteResp>;
88
+ /**
89
+ * Start a Pure Term application from a prior Pure Term quote.
90
+ *
91
+ * This is a dedicated endpoint, separate from the generic
92
+ * `InstaBrainClient.startApplication()` (`/api/ThirdPartyStartApp/start-application`),
93
+ * which remains unchanged for other products.
94
+ *
95
+ * Notes:
96
+ * - `isDeclined: true` is a valid success response (knockout), not an error.
97
+ * Knockouts: `isUsCitizenOrIsPermanentResident=false`,
98
+ * `isPayerAlsoOwnerAndInsured=false`, `isHoldingValidDriverLicense=false`,
99
+ * `areListedConditionsNotApplicable=false`, any of the four `childRiderInfo`
100
+ * knockout questions `=true`, or height/weight outside allowed limits.
101
+ * - `quoteResponseId` must belong to the Pure Term product.
102
+ * - `childRiderInfo` is required only when the Dependent Child Rider was on the
103
+ * quote, and must NOT be sent otherwise.
104
+ * - Pure Term does NOT use `ApplicationLimitReached` (ADB / GIGDB / Final Expense only).
105
+ * - Start Application is one shared service across both Term products, so the
106
+ * error set matches IB Term. Business failures return HTTP 400 with
107
+ * `value: null` and a top-level `agentNotFound` (missing user context),
108
+ * `StateMismatchIdentified` (quote state differs from `address.state`),
109
+ * `dataNotFound` (quote response not found), or `internalServerError`.
110
+ * - After a successful, non-declined start, hand off via the returned links —
111
+ * do not continue into shared SecureSign / finalSubmit with this `opportunityId`.
112
+ *
113
+ * @param request - The Pure Term application request payload.
114
+ * @returns Promise with opportunityId, links, isDeclined flag, and `isQuoteChanged`.
115
+ */
116
+ startApplication(request: PureTermStartApplicationReq): Promise<ThirdPartyStartAppResp>;
31
117
  }
@@ -4,27 +4,67 @@ exports.PureTermService = void 0;
4
4
  const base_service_1 = require("./base.service");
5
5
  /**
6
6
  * Pure Term (InstaBrain Pure Term) service
7
- * Handles quoting for the Pure Term product.
7
+ * Handles lookup, quoting, and application for the Pure Term product (ages 18–60).
8
8
  *
9
9
  * Flow:
10
- * 1. getQuote() → quoteResponseId
11
- * 2. InstaBrainClient.startApplication() → agentLink / applicantLink / eAppAgentLink
10
+ * 1. (optional) getRiderDetails(stateCode, age, flagNicotineUse) → rider availability + codes
11
+ * 2. getQuote() → quoteResponseId
12
+ * 3. startApplication() → opportunityId + links (or isDeclined=true)
13
+ * 4. (optional) getExistingQuote(opportunityId) → re-fetch the stored quote
12
14
  *
13
15
  * After startApplication(), direct the agent or applicant to the returned link.
14
16
  * All remaining steps (underwriting, payment, signing) complete inside the
15
- * InstaBrain frontend. Do NOT call saveEftPayment(), SecureSign methods, or
16
- * finalSubmit() for Pure Term.
17
+ * InstaBrain frontend — the same hand-off family as IB Term. Do NOT wire a Pure
18
+ * Term `opportunityId` into the shared SecureSign, finalSubmit(), or credit-card
19
+ * iframe clients. Shared EFT (`saveEftPayment()`) is allowed; the credit-card
20
+ * iframe is not supported for Pure Term and returns
21
+ * `CcPaymentIframeNotSupportedForProduct`.
17
22
  */
18
23
  class PureTermService extends base_service_1.BaseService {
19
24
  constructor(httpClient) {
20
25
  super(httpClient);
21
26
  }
27
+ /**
28
+ * Get available riders for Pure Term in a given state, filtered by the
29
+ * applicant's age and nicotine-use status.
30
+ *
31
+ * Optional pre-quote step. When `flagProductNotAvailableForState` is `true`
32
+ * in the response, Pure Term is not available for these inputs (e.g. WY, NY) —
33
+ * do not proceed to the Quote API. The empty `riders` array in that case is a
34
+ * valid business state, not an error, and is returned as-is by the SDK.
35
+ *
36
+ * Use `riderCode` from the response as `riders[n].rider` on the Pure Term quote.
37
+ *
38
+ * @param stateCode - Two-letter US state code (e.g. "TX").
39
+ * @param age - Applicant's age, integer, 18–60 inclusive.
40
+ * @param flagNicotineUse - Whether the applicant uses nicotine; required by the backend.
41
+ * @returns Rider list + product availability flag.
42
+ */
43
+ async getRiderDetails(stateCode, age, flagNicotineUse) {
44
+ return this.get('get Pure Term rider details', '/api/ThirdPartyIbPureTermLookup/get-rider-details', { params: { stateCode, age, flagNicotineUse } });
45
+ }
22
46
  /**
23
47
  * Get a Pure Term insurance quote.
24
48
  *
25
- * Provide exactly one rating group: `rateClass`, OR `healthClass`, OR
26
- * both `height` and `weightInLbs`. `benefitPeriod` and `stateCode` are
27
- * required. Supply `age` OR `dateOfBirth` (18–60).
49
+ * `faceAmount`, `benefitPeriod`, `gender`, `stateCode`, and `paymentFreq` are
50
+ * required. Supply at least one rating group — `rateClass`, `healthClass`, or
51
+ * both `height` and `weightInLbs`; passing more than one is allowed. Supply
52
+ * `age` OR `dateOfBirth` (18–60); `dateOfBirth` wins when both are sent.
53
+ * `flagTobaccoUse` defaults to `false`.
54
+ *
55
+ * Pure Term uses the same quote request shape as IB Term but different product
56
+ * rules (rate classes including Rated C/D, term lengths including 15,
57
+ * coverage/benefit tables) — see {@link ThirdPartyPureTermQuoteReq} for the
58
+ * exact rules in check order.
59
+ *
60
+ * **Errors come from two stages.** Request validation issues dedicated
61
+ * top-level codes only for `BenefitPeriodNotAvailable` and
62
+ * `CoverageNotAvailable`; every other field failure surfaces as
63
+ * `InvalidRequestFormat` with PascalCase keys under `value.fields`. Once
64
+ * validation passes, the shared quote-eligibility pipeline can still return
65
+ * `NotAvailableForState`, `QuoteNotEligibleForGivenConditions`,
66
+ * `RiderNotAvailable`, `RiderFaceAmountNotValid`, or `outsideBuildChart` —
67
+ * do not assume those never occur for Pure Term.
28
68
  *
29
69
  * @param request - The Pure Term quote request payload.
30
70
  * @returns Promise with the quote response including `quoteResponseId`.
@@ -32,5 +72,57 @@ class PureTermService extends base_service_1.BaseService {
32
72
  async getQuote(request) {
33
73
  return this.post('get Pure Term quote', '/api/ThirdPartyIbPureTermQuote/get', request);
34
74
  }
75
+ /**
76
+ * Get the existing quote for an in-flight Pure Term opportunity.
77
+ *
78
+ * Use to resume or review a previously generated Pure Term quote by its
79
+ * opportunity ID without re-quoting. The response reuses the same shape as
80
+ * `getQuote()` — `productName` is `"InstaBrain Pure Term"`.
81
+ *
82
+ * Unlike rider-details product-unavailability, a not-found result here is an
83
+ * error (surfaced via the SDK error model), not a valid business state:
84
+ * - missing / empty / non-GUID `opportunityId` → `InvalidRequestFormat`
85
+ * ("OpportunityId is required." / "OpportunityId does not exist.")
86
+ * - opportunity belongs to a different product → "OpportunityId does not
87
+ * match selected product." (field-level message under `InvalidRequestFormat`)
88
+ * - opportunity exists but has no stored quote → `QuoteNotFound` (top-level, `value: null`)
89
+ *
90
+ * @param opportunityId - UUID from a prior Pure Term application/quote flow.
91
+ * @returns Promise with the current quote response.
92
+ */
93
+ async getExistingQuote(opportunityId) {
94
+ return this.get('get existing Pure Term quote', '/api/ThirdPartyIbPureTermQuote/get-existing-quote', { params: { opportunityId } });
95
+ }
96
+ /**
97
+ * Start a Pure Term application from a prior Pure Term quote.
98
+ *
99
+ * This is a dedicated endpoint, separate from the generic
100
+ * `InstaBrainClient.startApplication()` (`/api/ThirdPartyStartApp/start-application`),
101
+ * which remains unchanged for other products.
102
+ *
103
+ * Notes:
104
+ * - `isDeclined: true` is a valid success response (knockout), not an error.
105
+ * Knockouts: `isUsCitizenOrIsPermanentResident=false`,
106
+ * `isPayerAlsoOwnerAndInsured=false`, `isHoldingValidDriverLicense=false`,
107
+ * `areListedConditionsNotApplicable=false`, any of the four `childRiderInfo`
108
+ * knockout questions `=true`, or height/weight outside allowed limits.
109
+ * - `quoteResponseId` must belong to the Pure Term product.
110
+ * - `childRiderInfo` is required only when the Dependent Child Rider was on the
111
+ * quote, and must NOT be sent otherwise.
112
+ * - Pure Term does NOT use `ApplicationLimitReached` (ADB / GIGDB / Final Expense only).
113
+ * - Start Application is one shared service across both Term products, so the
114
+ * error set matches IB Term. Business failures return HTTP 400 with
115
+ * `value: null` and a top-level `agentNotFound` (missing user context),
116
+ * `StateMismatchIdentified` (quote state differs from `address.state`),
117
+ * `dataNotFound` (quote response not found), or `internalServerError`.
118
+ * - After a successful, non-declined start, hand off via the returned links —
119
+ * do not continue into shared SecureSign / finalSubmit with this `opportunityId`.
120
+ *
121
+ * @param request - The Pure Term application request payload.
122
+ * @returns Promise with opportunityId, links, isDeclined flag, and `isQuoteChanged`.
123
+ */
124
+ async startApplication(request) {
125
+ return this.post('start Pure Term application', '/api/ThirdPartyPureTermApplication/start-application', request);
126
+ }
35
127
  }
36
128
  exports.PureTermService = PureTermService;
@@ -15,9 +15,25 @@ import { ThirdPartySendPinReq, ThirdPartyResendPinReq, ThirdPartyVerifyPinReq, T
15
15
  export declare class SecureSignService extends BaseService {
16
16
  constructor(httpClient: HttpClient);
17
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.
18
+ * Prepare the signing package and check available delivery channels.
19
+ *
20
+ * Applies to **ADB, GIGDB, and Final Expense**. Always call this first — it
21
+ * prepares the documents server-side. If `isSignCompleted` is `true`, the
22
+ * documents are already signed: skip the PIN flow entirely and go straight to
23
+ * `finalSubmit()`.
24
+ *
25
+ * `isSmsAvailable` / `isEmailAvailable` determine which channels may be
26
+ * selected in `sendPinAndGetDocumentsLink()` — only an available channel is
27
+ * accepted.
28
+ *
29
+ * Errors:
30
+ * - `ApplicationNotReady` — Start Application has not completed
31
+ * successfully, or payment/signing was called too early. This is the same
32
+ * lifecycle gate `getCcPaymentIframeUrl()` applies. Complete Start
33
+ * Application, then retry.
34
+ * - `InvalidRequestFormat` — `opportunityId` missing, non-existent, or the
35
+ * documents are already signed (`Documents are already signed.`).
36
+ *
21
37
  * @param opportunityId - The OpportunityId from the Start Application response
22
38
  * @returns Promise with delivery channels and sign completion status
23
39
  */
@@ -18,9 +18,25 @@ class SecureSignService extends base_service_1.BaseService {
18
18
  super(httpClient);
19
19
  }
20
20
  /**
21
- * Prepare the signing package and check available delivery channels
22
- * Always call this first — it prepares the signing package.
23
- * If isSignCompleted is true, skip the PIN flow and proceed to Final Submit.
21
+ * Prepare the signing package and check available delivery channels.
22
+ *
23
+ * Applies to **ADB, GIGDB, and Final Expense**. Always call this first — it
24
+ * prepares the documents server-side. If `isSignCompleted` is `true`, the
25
+ * documents are already signed: skip the PIN flow entirely and go straight to
26
+ * `finalSubmit()`.
27
+ *
28
+ * `isSmsAvailable` / `isEmailAvailable` determine which channels may be
29
+ * selected in `sendPinAndGetDocumentsLink()` — only an available channel is
30
+ * accepted.
31
+ *
32
+ * Errors:
33
+ * - `ApplicationNotReady` — Start Application has not completed
34
+ * successfully, or payment/signing was called too early. This is the same
35
+ * lifecycle gate `getCcPaymentIframeUrl()` applies. Complete Start
36
+ * Application, then retry.
37
+ * - `InvalidRequestFormat` — `opportunityId` missing, non-existent, or the
38
+ * documents are already signed (`Documents are already signed.`).
39
+ *
24
40
  * @param opportunityId - The OpportunityId from the Start Application response
25
41
  * @returns Promise with delivery channels and sign completion status
26
42
  */
@@ -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
- /** Product not offered for the selected state. */
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. */
@@ -480,8 +517,60 @@ export declare enum APIErrorCode {
480
517
  AgentNotFound = "agentNotFound",
481
518
  /** Unexpected backend failure while processing a Start Application request. */
482
519
  InternalServerError = "internalServerError",
483
- /** Update quote or save EFT when payment is already recorded for the opportunity. */
520
+ /**
521
+ * IB Term / Pure Term Start Application — the quote response referenced by
522
+ * `quoteResponseId` could not be found. HTTP 400 with `value: null`.
523
+ *
524
+ * Note: this code was removed in the 2.3.0 cleanup as "not returned by the
525
+ * API". That was true for the products checked at the time; it **is** returned
526
+ * by the IB Term and Pure Term start-application endpoints, so it is back and
527
+ * scoped. Do not delete it again without checking those two products.
528
+ */
529
+ DataNotFound = "dataNotFound",
530
+ /**
531
+ * Update quote or `saveEftPayment()` when a **successful** payment already
532
+ * exists for the opportunity — a prior EFT save, or a credit card that has
533
+ * already been charged.
534
+ *
535
+ * A credit card that was only captured and not yet charged does not trigger
536
+ * this on request validation. Do not rely on that edge case: treat EFT and
537
+ * credit card as mutually exclusive per `opportunityId`.
538
+ */
484
539
  PaymentAlreadyMade = "PaymentAlreadyMade",
540
+ /** `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. */
541
+ TcIframeLinkAlreadyGenerated = "TcIframeLinkAlreadyGenerated",
542
+ /** `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. */
543
+ CcPaymentIframeNotSupportedForProduct = "CcPaymentIframeNotSupportedForProduct",
544
+ /** `getCcPaymentIframeUrl()` / `prepareDocsAndGetDeliveryChannels()` — Start Application has not completed successfully yet. */
545
+ ApplicationNotReady = "ApplicationNotReady",
546
+ /** `getCcPaymentIframeUrl()` — a successful EFT payment already exists. EFT and credit card are mutually exclusive per opportunity. */
547
+ EftPaymentAlreadyCompleted = "EftPaymentAlreadyCompleted",
548
+ /** Card CVV was rejected. */
549
+ PaymentCvvInvalid = "PaymentCvvInvalid",
550
+ /** Declined — the applicant must contact their bank. */
551
+ PaymentDeclinedContactBank = "PaymentDeclinedContactBank",
552
+ /** Card declined. */
553
+ PaymentDeclined = "PaymentDeclined",
554
+ /** Card declined permanently — do not retry the same card. */
555
+ PaymentDeclinedPermanent = "PaymentDeclinedPermanent",
556
+ /** Card PIN is locked. */
557
+ PaymentPinLocked = "PaymentPinLocked",
558
+ /** Insufficient funds on the card. */
559
+ PaymentInsufficientFunds = "PaymentInsufficientFunds",
560
+ /** Processor-side error while charging the card. */
561
+ PaymentProcessingError = "PaymentProcessingError",
562
+ /** Charge blocked as suspected fraud. */
563
+ PaymentSuspectedFraud = "PaymentSuspectedFraud",
564
+ /** Card is expired. */
565
+ PaymentCardExpired = "PaymentCardExpired",
566
+ /** Card data supplied in the iframe was invalid. */
567
+ PaymentInvalidCardData = "PaymentInvalidCardData",
568
+ /** Generic card error. */
569
+ PaymentCardError = "PaymentCardError",
570
+ /** Issuer requires the applicant to contact their bank. */
571
+ PaymentContactBank = "PaymentContactBank",
572
+ /** Generic payment-related failure at final submit. */
573
+ PaymentRelatedError = "PaymentRelatedError",
485
574
  /** Generic Secure Sign failure. */
486
575
  SecureSignRelatedError = "SecureSignRelatedError",
487
576
  /** Signing package missing — call `prepareDocsAndGetDeliveryChannels()` first. */
@@ -498,8 +587,28 @@ export declare enum APIErrorCode {
498
587
  EmailDeliveryFailed = "EmailDeliveryFailed",
499
588
  /** SMS delivery failed on Send PIN / Resend PIN. */
500
589
  MessageNotDelivered = "MessageNotDelivered",
501
- /** EFT payment not saved — call `saveEftPayment()` before `finalSubmit()`. */
590
+ /** Secure signing has not been completed for the opportunity — finish the PIN flow (or confirm `isSignCompleted`) before `finalSubmit()`. */
591
+ SecureSignNotCompleted = "SecureSignNotCompleted",
592
+ /**
593
+ * No payment has been completed for the opportunity. Covers **two** cases:
594
+ * no payment was ever started (neither `saveEftPayment()` nor
595
+ * `getCcPaymentIframeUrl()`), **or** a credit card capture is still pending
596
+ * (iframe issued, `cc-payment-status` is `'pending'`).
597
+ *
598
+ * Recovery: complete the payment — finish the iframe and poll to `'approved'`,
599
+ * or save EFT — then retry. While capture is pending, reuse the stored iframe
600
+ * URL; do not request a new one.
601
+ */
502
602
  PaymentNotMade = "paymentNotMade",
603
+ /**
604
+ * A payment was attempted and the most recent attempt finished unsuccessfully
605
+ * (`cc-payment-status` is `'failed'` after a capture or charge decline).
606
+ *
607
+ * Recovery: call `getCcPaymentIframeUrl()` for a new capture, poll to
608
+ * `'approved'`, then retry `finalSubmit()`. Retrying `finalSubmit()` without a
609
+ * new successful capture returns this code again, not a fresh decline code.
610
+ */
611
+ LatestPaymentNotSuccessful = "LatestPaymentNotSuccessful",
503
612
  /** Fidelity carrier rejected or failed to process final submit. */
504
613
  FidelityFinalSubmitError = "FidelityFinalSubmitError",
505
614
  /** Underwriting status polling is not supported for the product (ADB/GIGDB) — Final Expense only. Returned by `pingFinalExpenseUnderwritingStatus()` / `pollFinalExpenseUnderwritingStatus()` for a non-Final-Expense opportunity. */
@@ -487,10 +487,47 @@ var APIErrorCode;
487
487
  // ─── Universal validation envelope ───────────────────────────────────────
488
488
  /** Top-level code for every FluentValidation failure across all products. Inspect `value.fields` for field-level details. */
489
489
  APIErrorCode["InvalidRequestFormat"] = "InvalidRequestFormat";
490
+ // ─── Get Quote — request-validation state cascade (all five products) ────
491
+ // Checked in this order against `stateCode`, stopping at the first failure:
492
+ // 1. required / recognized state → InvalidRequestFormat
493
+ // 2. product available there → ProductNotAvailableForState
494
+ // 3. agent licensed there → AgentNotLicensedForState
495
+ // Both carry HTTP 400 with the message under `value.fields.StateCode`.
496
+ // These fire during REQUEST VALIDATION. Do not confuse either with
497
+ // `NotAvailableForState`, which is a post-validation eligibility failure
498
+ // carrying `value: null` — different stage, different code.
499
+ /**
500
+ * Get Quote — the product has no carrier configuration for the requested
501
+ * state, or its configuration is flagged unavailable there. Field message:
502
+ * "This product is not available for the selected state."
503
+ *
504
+ * Previously surfaced as a plain `InvalidRequestFormat` field message; it is
505
+ * now its own top-level code. Not returned by start-application, update
506
+ * quote, or get-existing-quote.
507
+ */
508
+ APIErrorCode["ProductNotAvailableForState"] = "ProductNotAvailableForState";
509
+ /**
510
+ * Get Quote — the authenticated agent is not licensed in the requested
511
+ * state, or the agent could not be resolved from the token. Field message:
512
+ * "Agent is not licensed for the selected state."
513
+ *
514
+ * Distinct from `ProductNotApprovedForHierarchy`, which is a
515
+ * start-application product-hierarchy check, not state licensing. Because
516
+ * the cascade stops at the first failure, this is only reachable once
517
+ * product availability has passed.
518
+ */
519
+ APIErrorCode["AgentNotLicensedForState"] = "AgentNotLicensedForState";
490
520
  // ─── Quote business errors (ADB / GIGDB / IB Term, value: null) ──────────
491
521
  /** State code missing or not recognized for the product. */
492
522
  APIErrorCode["StateNotFound"] = "stateNotFound";
493
- /** Product not offered for the selected state. */
523
+ /**
524
+ * Post-validation eligibility — the product is not offered for the selected
525
+ * state, determined after request validation passed. Carries `value: null`.
526
+ *
527
+ * NOT the same as `ProductNotAvailableForState`, which is a request-validation
528
+ * failure carrying `value.fields.StateCode`. Both can occur for the same
529
+ * state; they are raised at different stages and must stay separate.
530
+ */
494
531
  APIErrorCode["NotAvailableForState"] = "NotAvailableForState";
495
532
  /** Quote not eligible for the given combination of state, age, and smoker status. */
496
533
  APIErrorCode["QuoteNotEligibleForGivenConditions"] = "QuoteNotEligibleForGivenConditions";
@@ -507,6 +544,16 @@ var APIErrorCode;
507
544
  APIErrorCode["BenefitPeriodNotAvailable"] = "BenefitPeriodNotAvailable";
508
545
  /** IB Term Quote only — height + weight fall outside the carrier's acceptable build chart. */
509
546
  APIErrorCode["OutsideBuildChart"] = "outsideBuildChart";
547
+ // ─── Pivot (Final Expense → GIGDB alternative offer) ─────────────────────
548
+ /**
549
+ * The opportunity cannot be pivoted to an alternative product — not eligible,
550
+ * pricing could not produce a quote, or it has already been converted once.
551
+ * Top-level with `value: null`.
552
+ *
553
+ * A business state, not a malformed request — do not lump it in with
554
+ * `InvalidRequestFormat` handling.
555
+ */
556
+ APIErrorCode["PivotNotAvailable"] = "PivotNotAvailable";
510
557
  // ─── Start Application — duplicate-detection limit ───────────────────────
511
558
  /** 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. */
512
559
  APIErrorCode["ApplicationLimitReached"] = "ApplicationLimitReached";
@@ -517,9 +564,67 @@ var APIErrorCode;
517
564
  APIErrorCode["AgentNotFound"] = "agentNotFound";
518
565
  /** Unexpected backend failure while processing a Start Application request. */
519
566
  APIErrorCode["InternalServerError"] = "internalServerError";
567
+ /**
568
+ * IB Term / Pure Term Start Application — the quote response referenced by
569
+ * `quoteResponseId` could not be found. HTTP 400 with `value: null`.
570
+ *
571
+ * Note: this code was removed in the 2.3.0 cleanup as "not returned by the
572
+ * API". That was true for the products checked at the time; it **is** returned
573
+ * by the IB Term and Pure Term start-application endpoints, so it is back and
574
+ * scoped. Do not delete it again without checking those two products.
575
+ */
576
+ APIErrorCode["DataNotFound"] = "dataNotFound";
520
577
  // ─── Payment & quote update (after Start Application) ─────────────────────
521
- /** Update quote or save EFT when payment is already recorded for the opportunity. */
578
+ /**
579
+ * Update quote or `saveEftPayment()` when a **successful** payment already
580
+ * exists for the opportunity — a prior EFT save, or a credit card that has
581
+ * already been charged.
582
+ *
583
+ * A credit card that was only captured and not yet charged does not trigger
584
+ * this on request validation. Do not rely on that edge case: treat EFT and
585
+ * credit card as mutually exclusive per `opportunityId`.
586
+ */
522
587
  APIErrorCode["PaymentAlreadyMade"] = "PaymentAlreadyMade";
588
+ // ─── Credit card payment — iframe gates (ADB / GIGDB / Final Expense) ─────
589
+ /** `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. */
590
+ APIErrorCode["TcIframeLinkAlreadyGenerated"] = "TcIframeLinkAlreadyGenerated";
591
+ /** `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. */
592
+ APIErrorCode["CcPaymentIframeNotSupportedForProduct"] = "CcPaymentIframeNotSupportedForProduct";
593
+ /** `getCcPaymentIframeUrl()` / `prepareDocsAndGetDeliveryChannels()` — Start Application has not completed successfully yet. */
594
+ APIErrorCode["ApplicationNotReady"] = "ApplicationNotReady";
595
+ /** `getCcPaymentIframeUrl()` — a successful EFT payment already exists. EFT and credit card are mutually exclusive per opportunity. */
596
+ APIErrorCode["EftPaymentAlreadyCompleted"] = "EftPaymentAlreadyCompleted";
597
+ // ─── Credit card decline codes — `finalSubmit()`, ADB / GIGDB only ────────
598
+ // Returned when the stored card is charged at final submit and the charge is
599
+ // declined. The application is NOT submitted. Recovery is always: request a
600
+ // new iframe URL → poll to `approved` → retry `finalSubmit()`.
601
+ // Final Expense never produces these — the carrier charges after underwriting.
602
+ /** Card CVV was rejected. */
603
+ APIErrorCode["PaymentCvvInvalid"] = "PaymentCvvInvalid";
604
+ /** Declined — the applicant must contact their bank. */
605
+ APIErrorCode["PaymentDeclinedContactBank"] = "PaymentDeclinedContactBank";
606
+ /** Card declined. */
607
+ APIErrorCode["PaymentDeclined"] = "PaymentDeclined";
608
+ /** Card declined permanently — do not retry the same card. */
609
+ APIErrorCode["PaymentDeclinedPermanent"] = "PaymentDeclinedPermanent";
610
+ /** Card PIN is locked. */
611
+ APIErrorCode["PaymentPinLocked"] = "PaymentPinLocked";
612
+ /** Insufficient funds on the card. */
613
+ APIErrorCode["PaymentInsufficientFunds"] = "PaymentInsufficientFunds";
614
+ /** Processor-side error while charging the card. */
615
+ APIErrorCode["PaymentProcessingError"] = "PaymentProcessingError";
616
+ /** Charge blocked as suspected fraud. */
617
+ APIErrorCode["PaymentSuspectedFraud"] = "PaymentSuspectedFraud";
618
+ /** Card is expired. */
619
+ APIErrorCode["PaymentCardExpired"] = "PaymentCardExpired";
620
+ /** Card data supplied in the iframe was invalid. */
621
+ APIErrorCode["PaymentInvalidCardData"] = "PaymentInvalidCardData";
622
+ /** Generic card error. */
623
+ APIErrorCode["PaymentCardError"] = "PaymentCardError";
624
+ /** Issuer requires the applicant to contact their bank. */
625
+ APIErrorCode["PaymentContactBank"] = "PaymentContactBank";
626
+ /** Generic payment-related failure at final submit. */
627
+ APIErrorCode["PaymentRelatedError"] = "PaymentRelatedError";
523
628
  // ─── Secure Sign ───────────────────────────────────────────────────────────
524
629
  /** Generic Secure Sign failure. */
525
630
  APIErrorCode["SecureSignRelatedError"] = "SecureSignRelatedError";
@@ -537,9 +642,34 @@ var APIErrorCode;
537
642
  APIErrorCode["EmailDeliveryFailed"] = "EmailDeliveryFailed";
538
643
  /** SMS delivery failed on Send PIN / Resend PIN. */
539
644
  APIErrorCode["MessageNotDelivered"] = "MessageNotDelivered";
540
- // ─── Final Submit ──────────────────────────────────────────────────────────
541
- /** EFT payment not saved — call `saveEftPayment()` before `finalSubmit()`. */
645
+ // ─── Final Submit — pre-submit gates, checked in this order ────────────────
646
+ // 1. SecureSignNotCompleted → 2. PaymentNotMade → 3. LatestPaymentNotSuccessful
647
+ // These are three distinct, separately actionable states. Do NOT collapse
648
+ // PaymentNotMade and LatestPaymentNotSuccessful into one client-side case:
649
+ // the first means "nothing to submit yet", the second means "a payment was
650
+ // tried and failed, start a new capture".
651
+ /** Secure signing has not been completed for the opportunity — finish the PIN flow (or confirm `isSignCompleted`) before `finalSubmit()`. */
652
+ APIErrorCode["SecureSignNotCompleted"] = "SecureSignNotCompleted";
653
+ /**
654
+ * No payment has been completed for the opportunity. Covers **two** cases:
655
+ * no payment was ever started (neither `saveEftPayment()` nor
656
+ * `getCcPaymentIframeUrl()`), **or** a credit card capture is still pending
657
+ * (iframe issued, `cc-payment-status` is `'pending'`).
658
+ *
659
+ * Recovery: complete the payment — finish the iframe and poll to `'approved'`,
660
+ * or save EFT — then retry. While capture is pending, reuse the stored iframe
661
+ * URL; do not request a new one.
662
+ */
542
663
  APIErrorCode["PaymentNotMade"] = "paymentNotMade";
664
+ /**
665
+ * A payment was attempted and the most recent attempt finished unsuccessfully
666
+ * (`cc-payment-status` is `'failed'` after a capture or charge decline).
667
+ *
668
+ * Recovery: call `getCcPaymentIframeUrl()` for a new capture, poll to
669
+ * `'approved'`, then retry `finalSubmit()`. Retrying `finalSubmit()` without a
670
+ * new successful capture returns this code again, not a fresh decline code.
671
+ */
672
+ APIErrorCode["LatestPaymentNotSuccessful"] = "LatestPaymentNotSuccessful";
543
673
  /** Fidelity carrier rejected or failed to process final submit. */
544
674
  APIErrorCode["FidelityFinalSubmitError"] = "FidelityFinalSubmitError";
545
675
  /** Underwriting status polling is not supported for the product (ADB/GIGDB) — Final Expense only. Returned by `pingFinalExpenseUnderwritingStatus()` / `pollFinalExpenseUnderwritingStatus()` for a non-Final-Expense opportunity. */