@instabrain-sdks/api-client 1.0.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 (62) hide show
  1. package/README.md +318 -0
  2. package/dist/client/instabrain-client.d.ts +83 -0
  3. package/dist/client/instabrain-client.d.ts.map +1 -0
  4. package/dist/client/instabrain-client.js +117 -0
  5. package/dist/client/instabrain-client.js.map +1 -0
  6. package/dist/index.d.ts +8 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +36 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/services/application.service.d.ts +16 -0
  11. package/dist/services/application.service.d.ts.map +1 -0
  12. package/dist/services/application.service.js +42 -0
  13. package/dist/services/application.service.js.map +1 -0
  14. package/dist/services/auth.service.d.ts +35 -0
  15. package/dist/services/auth.service.d.ts.map +1 -0
  16. package/dist/services/auth.service.js +74 -0
  17. package/dist/services/auth.service.js.map +1 -0
  18. package/dist/services/quote.service.d.ts +32 -0
  19. package/dist/services/quote.service.d.ts.map +1 -0
  20. package/dist/services/quote.service.js +93 -0
  21. package/dist/services/quote.service.js.map +1 -0
  22. package/dist/services/reports.service.d.ts +64 -0
  23. package/dist/services/reports.service.d.ts.map +1 -0
  24. package/dist/services/reports.service.js +184 -0
  25. package/dist/services/reports.service.js.map +1 -0
  26. package/dist/types/application.types.d.ts +14 -0
  27. package/dist/types/application.types.d.ts.map +1 -0
  28. package/dist/types/application.types.js +3 -0
  29. package/dist/types/application.types.js.map +1 -0
  30. package/dist/types/auth.types.d.ts +8 -0
  31. package/dist/types/auth.types.d.ts.map +1 -0
  32. package/dist/types/auth.types.js +3 -0
  33. package/dist/types/auth.types.js.map +1 -0
  34. package/dist/types/constants.d.ts +66 -0
  35. package/dist/types/constants.d.ts.map +1 -0
  36. package/dist/types/constants.js +55 -0
  37. package/dist/types/constants.js.map +1 -0
  38. package/dist/types/enums.d.ts +40 -0
  39. package/dist/types/enums.d.ts.map +1 -0
  40. package/dist/types/enums.js +55 -0
  41. package/dist/types/enums.js.map +1 -0
  42. package/dist/types/errors.d.ts +30 -0
  43. package/dist/types/errors.d.ts.map +1 -0
  44. package/dist/types/errors.js +69 -0
  45. package/dist/types/errors.js.map +1 -0
  46. package/dist/types/index.d.ts +43 -0
  47. package/dist/types/index.d.ts.map +1 -0
  48. package/dist/types/index.js +25 -0
  49. package/dist/types/index.js.map +1 -0
  50. package/dist/types/quote.types.d.ts +187 -0
  51. package/dist/types/quote.types.d.ts.map +1 -0
  52. package/dist/types/quote.types.js +3 -0
  53. package/dist/types/quote.types.js.map +1 -0
  54. package/dist/types/reports.types.d.ts +194 -0
  55. package/dist/types/reports.types.d.ts.map +1 -0
  56. package/dist/types/reports.types.js +22 -0
  57. package/dist/types/reports.types.js.map +1 -0
  58. package/dist/utils/http-client.d.ts +62 -0
  59. package/dist/utils/http-client.d.ts.map +1 -0
  60. package/dist/utils/http-client.js +176 -0
  61. package/dist/utils/http-client.js.map +1 -0
  62. package/package.json +51 -0
package/README.md ADDED
@@ -0,0 +1,318 @@
1
+ # InstaBrain Node.js SDK
2
+
3
+ [![npm version](https://badge.fury.io/js/instabrain.svg)](https://badge.fury.io/js/instabrain)
4
+ [![License: Commercial](https://img.shields.io/badge/License-Commercial-red.svg)]()
5
+
6
+ Official Node.js SDK for the InstaBrain API - Insurance quotes and application processing made simple.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @instabrain-sdks/api-client
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ```typescript
17
+ import { InstaBrainClient,
18
+ Gender,
19
+ PaymentFrequency,
20
+ RateClass,
21
+ HealthClass,
22
+ ThirdPartyQuoteReq,
23
+ ThirdPartyStartApplicationReq,
24
+ AgentPortalReq }
25
+ from '@instabrain-sdks/api-client';
26
+
27
+ // Create a client instance
28
+ const client = InstaBrainClient.forEnvironment('production');
29
+
30
+ // Authenticate
31
+ await client.authenticate(12345, 'your-access-token-uuid');
32
+
33
+ // Get a quote
34
+ const quote = await client.getQuote(quoteReq);
35
+
36
+ // Start an application
37
+ const application = await client.startApplication(startApplicationReq);
38
+
39
+ // Get reporting data
40
+ const reportingReq : AgentPortalReq = {
41
+ "startDate": null,
42
+ "endDate": null,
43
+ "dayCount": 10,
44
+ "pageSize": 10,
45
+ "pageIndex": 1
46
+ };
47
+ const prospects = await client.getProspects(reportingReq);
48
+ const sales = await client.getSales(reportingReq);
49
+ const applications = await client.getApplications(reportingReq);
50
+
51
+ console.log(`Dashboard Summary:`);
52
+ console.log(`- Prospects: ${prospects.prospectCount}`);
53
+ console.log(`- Sales: ${sales.applicationCount} ($${sales.totalPremiumAmount})`);
54
+ console.log(`- Applications: ${applications.applicationCount}`);
55
+ ```
56
+
57
+ ## Features
58
+
59
+ - ✅ **TypeScript Support** - Full type safety with TypeScript definitions
60
+ - ✅ **Environment Management** - Easy switching between production and sandbox
61
+ - ✅ **Automatic JWT Management** - Handles authentication tokens automatically
62
+ - ✅ **Error Handling** - Comprehensive error handling with custom error types
63
+ - ✅ **Request Validation** - Built-in validation for API requests
64
+ - ✅ **Comprehensive Testing** - Well-tested with Jest
65
+ - ✅ **Modern Promise API** - Uses async/await patterns
66
+
67
+ ## API Reference
68
+
69
+ ### Authentication
70
+
71
+ #### `authenticate(userId: number, accessToken: string): Promise<string>`
72
+
73
+ Authenticate with the InstaBrain API and obtain a JWT token.
74
+
75
+ ```typescript
76
+ const jwtToken = await client.authenticate(12345, 'uuid-access-token');
77
+ ```
78
+
79
+ ### Quotes
80
+
81
+ #### `getQuote(request: ThirdPartyQuoteReq): Promise<ThirdPartyQuoteResp>`
82
+
83
+ Get an insurance quote based on the provided parameters.
84
+
85
+ ```typescript
86
+ const quoteReq : ThirdPartyQuoteReq = {
87
+ faceAmount: 500000,
88
+ benefitPeriod: 20,
89
+ flagTobaccoUse: false,
90
+ gender: Gender.Female,
91
+ stateCode: 'NY',
92
+ zipCode: '10001',
93
+ rateClass: RateClass.Preferred,
94
+ healthClass: HealthClass.Preferred,
95
+ height: { feet: 5, inches: 6 },
96
+ weightInLbs: 140,
97
+ age: 30,
98
+ paymentFreq: PaymentFrequency.Annual,
99
+ firstName: 'Jane',
100
+ lastName: 'Smith',
101
+ email: 'jane.smith@example.com',
102
+ phoneNum: '555-0123'
103
+ };
104
+ const quote = await client.getQuote(quoteReq);
105
+ ```
106
+
107
+ ### Applications
108
+
109
+ #### `startApplication(request: ThirdPartyStartApplicationReq): Promise<ThirdPartyStartAppResp>`
110
+
111
+ Start an insurance application from a quote.
112
+
113
+ ```typescript
114
+ const startApplicationReq : ThirdPartyStartApplicationReq = {
115
+ quoteResponseId: quote.selectedQuote.quoteResponseId,
116
+ firstName: 'John',
117
+ lastName: 'Doe',
118
+ email: 'john.doe@example.com',
119
+ phoneNumber: '555-1234'
120
+ };
121
+ const application = await client.startApplication(startApplicationReq);
122
+
123
+ // Access the generated links
124
+ console.log('Agent Link:', application.agentLink);
125
+ console.log('Applicant Link:', application.applicantLink);
126
+ ```
127
+
128
+ ### Reports
129
+
130
+ #### `getProspects(request?: AgentPortalReq): Promise<ThirdPartyProspectsResp>`
131
+
132
+ Get prospects data - quotes that haven't been converted to applications yet.
133
+
134
+ ```typescript
135
+ const portalReq : AgentPortalReq = {
136
+ "startDate": null,
137
+ "endDate": null,
138
+ "dayCount": 10,
139
+ "pageSize": 10,
140
+ "pageIndex": 1
141
+ };
142
+ const prospects = await client.getProspects(portalReq);
143
+
144
+ console.log(`Found ${prospects.prospectCount} prospects`);
145
+ ```
146
+
147
+ #### `getSales(request?: AgentPortalReq): Promise<ThirdPartySalesReportRes>`
148
+
149
+ Get sales data - completed/sold policies.
150
+
151
+ ```typescript
152
+ const salesReq : AgentPortalReq = {
153
+ "startDate": null,
154
+ "endDate": null,
155
+ "dayCount": 10,
156
+ "pageSize": 10,
157
+ "pageIndex": 1
158
+ };
159
+ const sales = await client.getSales(salesReq);
160
+
161
+ console.log(`Total sales: ${sales.applicationCount}`);
162
+ console.log(`Total premium: $${sales.totalPremiumAmount}`);
163
+ ```
164
+
165
+ #### `getApplications(request?: AgentPortalReq): Promise<ThirdPartyApplicationReportRes>`
166
+
167
+ Get applications data - applications in progress.
168
+
169
+ ```typescript
170
+ const applicationsReq : AgentPortalReq = {
171
+ "startDate": null,
172
+ "endDate": null,
173
+ "dayCount": 10,
174
+ "pageSize": 10,
175
+ "pageIndex": 1
176
+ };
177
+ const applications = await client.getApplications(applicationsReq);
178
+
179
+ console.log(`Applications needing attention: ${applications.applicationCount}`);
180
+ ```
181
+
182
+ ## Environment Configuration
183
+
184
+ The SDK supports production and sandbox environments:
185
+
186
+ ```typescript
187
+ // Production environment (default)
188
+ const prodClient = InstaBrainClient.forEnvironment('production');
189
+
190
+ // Sandbox environment for testing
191
+ const sandboxClient = InstaBrainClient.forEnvironment('sandbox');
192
+ ```
193
+
194
+ ## Error Handling
195
+
196
+ The SDK provides specific error types for different scenarios:
197
+
198
+ ```typescript
199
+ import {
200
+ InstaBrainError,
201
+ AuthenticationError,
202
+ ValidationError
203
+ } from 'instabrain';
204
+
205
+ try {
206
+ await client.authenticate(userId, accessToken);
207
+ } catch (error) {
208
+ if (error instanceof AuthenticationError) {
209
+ console.error('Authentication failed:', error.message);
210
+ } else if (error instanceof ValidationError) {
211
+ console.error('Validation error:', error.message);
212
+ } else if (error instanceof InstaBrainError) {
213
+ console.error('API error:', error.message, error.statusCode);
214
+ } else {
215
+ console.error('Unexpected error:', error);
216
+ }
217
+ }
218
+ ```
219
+
220
+ ## Types and Enums
221
+
222
+ ### Gender
223
+
224
+ ```typescript
225
+ enum Gender {
226
+ Male = 1,
227
+ Female = 2
228
+ }
229
+ ```
230
+
231
+ ### Payment Frequency
232
+
233
+ ```typescript
234
+ enum PaymentFrequency {
235
+ Annual = 1,
236
+ Monthly = 12
237
+ }
238
+ ```
239
+
240
+ ### Rate Class
241
+
242
+ ```typescript
243
+ enum RateClass {
244
+ Standard = 'Standard',
245
+ Preferred = 'Preferred',
246
+ PreferredPlus = 'Preferred Plus',
247
+ SuperPreferred = 'Super Preferred'
248
+ }
249
+ ```
250
+
251
+ ### Health Class
252
+
253
+ ```typescript
254
+ enum HealthClass {
255
+ Standard = 'Standard',
256
+ Preferred = 'Preferred',
257
+ Excellent = 'Excellent',
258
+ PreferredPlus = 'Preferred Plus',
259
+ SuperPreferred = 'Super Preferred'
260
+ }
261
+ ```
262
+
263
+ ## Advanced Usage
264
+
265
+ ### Manual Token Management
266
+
267
+ ```typescript
268
+ // Set a token manually (if you have one from elsewhere)
269
+ client.setToken('your-jwt-token');
270
+
271
+ // Check authentication status
272
+ if (client.isAuthenticated()) {
273
+ // Make API calls
274
+ }
275
+
276
+ // Get current token
277
+ const currentToken = client.getCurrentToken();
278
+
279
+ // Logout (clear token)
280
+ client.logout();
281
+ ```
282
+
283
+ ### Base URL Management
284
+
285
+ ```typescript
286
+ // Update base URL dynamically
287
+ client.updateBaseUrl('https://api-staging.instabrain.io');
288
+
289
+ // Get current base URL
290
+ const currentUrl = client.getBaseUrl();
291
+ ```
292
+
293
+ ## Examples
294
+
295
+ Check out the [examples](./examples) directory for more detailed usage examples:
296
+
297
+ - [Basic Usage](./examples/basic-usage.ts) - Complete workflow from authentication to application
298
+ - [Error Handling](./examples/error-handling.ts) - Comprehensive error handling patterns
299
+ - [Environment Switching](./examples/environment-switching.ts) - Working with different environments
300
+
301
+ ## Requirements
302
+
303
+ - Node.js 14.0.0 or higher
304
+ - TypeScript 4.0 or higher (for TypeScript projects)
305
+
306
+ ## License
307
+ This software is proprietary and confidential. Unauthorized copying, distribution, or modification is strictly prohibited.
308
+
309
+ ## Support
310
+
311
+ For technical support and questions:
312
+
313
+ - **Email**: helpdesk@instabrain.io
314
+ - **Website**: https://www.instabrain.io
315
+
316
+ ## Changelog
317
+
318
+ See [CHANGELOG.md](CHANGELOG.md) for a list of changes in each version.
@@ -0,0 +1,83 @@
1
+ import { AuthService } from '../services/auth.service';
2
+ import { QuoteService } from '../services/quote.service';
3
+ import { ApplicationService } from '../services/application.service';
4
+ import { ReportsService } from '../services/reports.service';
5
+ import { InstaBrainConfig, Environment, ThirdPartyQuoteReq, ThirdPartyQuoteResp, ThirdPartyStartApplicationReq, ThirdPartyStartAppResp, AgentPortalReq, ThirdPartyProspectsResp, ThirdPartySalesReportRes, ThirdPartyApplicationReportRes } from '../types';
6
+ /**
7
+ * Main InstaBrain SDK client
8
+ */
9
+ export declare class InstaBrainClient {
10
+ private httpClient;
11
+ readonly auth: AuthService;
12
+ readonly quote: QuoteService;
13
+ readonly application: ApplicationService;
14
+ readonly reports: ReportsService;
15
+ constructor(config?: InstaBrainConfig);
16
+ /**
17
+ * Configure the client for different environments
18
+ * @param environment - The environment to configure for
19
+ */
20
+ static forEnvironment(environment: Environment): InstaBrainClient;
21
+ /**
22
+ * Authenticate with the InstaBrain API
23
+ * @param userId - The user ID for authentication
24
+ * @param accessToken - The access token for authentication
25
+ * @returns Promise with the JWT token
26
+ */
27
+ authenticate(userId: number, accessToken: string): Promise<string>;
28
+ /**
29
+ * Get an insurance quote
30
+ * @param quoteRequest - The quote request parameters
31
+ * @returns Promise with the quote response
32
+ */
33
+ getQuote(quoteRequest: ThirdPartyQuoteReq): Promise<ThirdPartyQuoteResp>;
34
+ /**
35
+ * Start an insurance application from a quote
36
+ * @param applicationRequest - The application request parameters
37
+ * @returns Promise with the application response containing links
38
+ */
39
+ startApplication(applicationRequest: ThirdPartyStartApplicationReq): Promise<ThirdPartyStartAppResp>;
40
+ /**
41
+ * Get prospects data - quotes that haven't been converted to applications yet
42
+ * @param request - The agent portal request with filters, pagination, etc.
43
+ * @returns Promise with prospects data including count and details
44
+ */
45
+ getProspects(request: AgentPortalReq): Promise<ThirdPartyProspectsResp>;
46
+ /**
47
+ * Get sales data - completed/sold policies
48
+ * @param request - The agent portal request with filters, pagination, etc.
49
+ * @returns Promise with sales data including total premium amount
50
+ */
51
+ getSales(request: AgentPortalReq): Promise<ThirdPartySalesReportRes>;
52
+ /**
53
+ * Get applications data - applications in progress
54
+ * @param request - The agent portal request with filters, pagination, etc.
55
+ * @returns Promise with applications data including status and completion info
56
+ */
57
+ getApplications(request: AgentPortalReq): Promise<ThirdPartyApplicationReportRes>;
58
+ /**
59
+ * Check if the client is authenticated
60
+ * @returns boolean indicating authentication status
61
+ */
62
+ isAuthenticated(): boolean;
63
+ /**
64
+ * Get the current JWT token
65
+ * @returns the current JWT token or null if not authenticated
66
+ */
67
+ getCurrentToken(): string | null;
68
+ /**
69
+ * Logout by clearing the JWT token
70
+ */
71
+ logout(): void;
72
+ /**
73
+ * Set a JWT token manually
74
+ * @param token - The JWT token to set
75
+ */
76
+ setToken(token: string): void;
77
+ /**
78
+ * Get the current base URL (for debugging purposes only)
79
+ * @returns the current base URL
80
+ */
81
+ getBaseUrl(): string;
82
+ }
83
+ //# sourceMappingURL=instabrain-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instabrain-client.d.ts","sourceRoot":"","sources":["../../src/client/instabrain-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,6BAA6B,EAC7B,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC/B,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAAa;IAC/B,SAAgB,IAAI,EAAE,WAAW,CAAC;IAClC,SAAgB,KAAK,EAAE,YAAY,CAAC;IACpC,SAAgB,WAAW,EAAE,kBAAkB,CAAC;IAChD,SAAgB,OAAO,EAAE,cAAc,CAAC;gBAE5B,MAAM,GAAE,gBAAqB;IAQzC;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB;IAUjE;;;;;OAKG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxE;;;;OAIG;IACG,QAAQ,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI9E;;;;OAIG;IACG,gBAAgB,CAAC,kBAAkB,EAAE,6BAA6B,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAI1G;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAI7E;;;;OAIG;IACG,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAI1E;;;;OAIG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAIvF;;;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;IAI7B;;;OAGG;IACH,UAAU,IAAI,MAAM;CAGrB"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstaBrainClient = void 0;
4
+ const http_client_1 = require("../utils/http-client");
5
+ const auth_service_1 = require("../services/auth.service");
6
+ const quote_service_1 = require("../services/quote.service");
7
+ const application_service_1 = require("../services/application.service");
8
+ const reports_service_1 = require("../services/reports.service");
9
+ /**
10
+ * Main InstaBrain SDK client
11
+ */
12
+ class InstaBrainClient {
13
+ constructor(config = {}) {
14
+ this.httpClient = new http_client_1.HttpClient(config);
15
+ this.auth = new auth_service_1.AuthService(this.httpClient);
16
+ this.quote = new quote_service_1.QuoteService(this.httpClient);
17
+ this.application = new application_service_1.ApplicationService(this.httpClient);
18
+ this.reports = new reports_service_1.ReportsService(this.httpClient);
19
+ }
20
+ /**
21
+ * Configure the client for different environments
22
+ * @param environment - The environment to configure for
23
+ */
24
+ static forEnvironment(environment) {
25
+ const envConfigs = {
26
+ production: { baseUrl: 'https://api.instabrain.io' },
27
+ sandbox: { baseUrl: 'https://api.instabrainsandbox.io' },
28
+ };
29
+ const config = envConfigs[environment];
30
+ return new InstaBrainClient(config);
31
+ }
32
+ /**
33
+ * Authenticate with the InstaBrain API
34
+ * @param userId - The user ID for authentication
35
+ * @param accessToken - The access token for authentication
36
+ * @returns Promise with the JWT token
37
+ */
38
+ async authenticate(userId, accessToken) {
39
+ return this.auth.authenticate(userId, accessToken);
40
+ }
41
+ /**
42
+ * Get an insurance quote
43
+ * @param quoteRequest - The quote request parameters
44
+ * @returns Promise with the quote response
45
+ */
46
+ async getQuote(quoteRequest) {
47
+ return this.quote.getQuote(quoteRequest);
48
+ }
49
+ /**
50
+ * Start an insurance application from a quote
51
+ * @param applicationRequest - The application request parameters
52
+ * @returns Promise with the application response containing links
53
+ */
54
+ async startApplication(applicationRequest) {
55
+ return this.application.startApplication(applicationRequest);
56
+ }
57
+ /**
58
+ * Get prospects data - quotes that haven't been converted to applications yet
59
+ * @param request - The agent portal request with filters, pagination, etc.
60
+ * @returns Promise with prospects data including count and details
61
+ */
62
+ async getProspects(request) {
63
+ return this.reports.getProspects(request);
64
+ }
65
+ /**
66
+ * Get sales data - completed/sold policies
67
+ * @param request - The agent portal request with filters, pagination, etc.
68
+ * @returns Promise with sales data including total premium amount
69
+ */
70
+ async getSales(request) {
71
+ return this.reports.getSales(request);
72
+ }
73
+ /**
74
+ * Get applications data - applications in progress
75
+ * @param request - The agent portal request with filters, pagination, etc.
76
+ * @returns Promise with applications data including status and completion info
77
+ */
78
+ async getApplications(request) {
79
+ return this.reports.getApplications(request);
80
+ }
81
+ /**
82
+ * Check if the client is authenticated
83
+ * @returns boolean indicating authentication status
84
+ */
85
+ isAuthenticated() {
86
+ return this.auth.isAuthenticated();
87
+ }
88
+ /**
89
+ * Get the current JWT token
90
+ * @returns the current JWT token or null if not authenticated
91
+ */
92
+ getCurrentToken() {
93
+ return this.auth.getCurrentToken();
94
+ }
95
+ /**
96
+ * Logout by clearing the JWT token
97
+ */
98
+ logout() {
99
+ this.auth.logout();
100
+ }
101
+ /**
102
+ * Set a JWT token manually
103
+ * @param token - The JWT token to set
104
+ */
105
+ setToken(token) {
106
+ this.auth.setToken(token);
107
+ }
108
+ /**
109
+ * Get the current base URL (for debugging purposes only)
110
+ * @returns the current base URL
111
+ */
112
+ getBaseUrl() {
113
+ return this.httpClient.getBaseUrl();
114
+ }
115
+ }
116
+ exports.InstaBrainClient = InstaBrainClient;
117
+ //# sourceMappingURL=instabrain-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instabrain-client.js","sourceRoot":"","sources":["../../src/client/instabrain-client.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAClD,2DAAuD;AACvD,6DAAyD;AACzD,yEAAqE;AACrE,iEAA6D;AAc7D;;GAEG;AACH,MAAa,gBAAgB;IAO3B,YAAY,SAA2B,EAAE;QACvC,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,0BAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,IAAI,wCAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,gCAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,WAAwB;QAC5C,MAAM,UAAU,GAAG;YACjB,UAAU,EAAE,EAAE,OAAO,EAAE,2BAA2B,EAAE;YACpD,OAAO,EAAE,EAAE,OAAO,EAAE,kCAAkC,EAAE;SACzD,CAAC;QAEF,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QACvC,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,WAAmB;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,YAAgC;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAAC,kBAAiD;QACtE,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,OAAuB;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAuB;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAC,OAAuB;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACtC,CAAC;CACF;AA1HD,4CA0HC"}
@@ -0,0 +1,8 @@
1
+ export { InstaBrainClient } from './client/instabrain-client';
2
+ export { AuthService } from './services/auth.service';
3
+ export { QuoteService } from './services/quote.service';
4
+ export { ApplicationService } from './services/application.service';
5
+ export * from './types';
6
+ export { HttpClient } from './utils/http-client';
7
+ export { InstaBrainClient as default } from './client/instabrain-client';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.default = exports.HttpClient = exports.ApplicationService = exports.QuoteService = exports.AuthService = exports.InstaBrainClient = void 0;
18
+ // Main exports
19
+ var instabrain_client_1 = require("./client/instabrain-client");
20
+ Object.defineProperty(exports, "InstaBrainClient", { enumerable: true, get: function () { return instabrain_client_1.InstaBrainClient; } });
21
+ // Service exports
22
+ var auth_service_1 = require("./services/auth.service");
23
+ Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return auth_service_1.AuthService; } });
24
+ var quote_service_1 = require("./services/quote.service");
25
+ Object.defineProperty(exports, "QuoteService", { enumerable: true, get: function () { return quote_service_1.QuoteService; } });
26
+ var application_service_1 = require("./services/application.service");
27
+ Object.defineProperty(exports, "ApplicationService", { enumerable: true, get: function () { return application_service_1.ApplicationService; } });
28
+ // Type exports
29
+ __exportStar(require("./types"), exports);
30
+ // Utility exports
31
+ var http_client_1 = require("./utils/http-client");
32
+ Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_client_1.HttpClient; } });
33
+ // Default export
34
+ var instabrain_client_2 = require("./client/instabrain-client");
35
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return instabrain_client_2.InstaBrainClient; } });
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,eAAe;AACf,gEAA8D;AAArD,qHAAA,gBAAgB,OAAA;AAEzB,kBAAkB;AAClB,wDAAsD;AAA7C,2GAAA,WAAW,OAAA;AACpB,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,sEAAoE;AAA3D,yHAAA,kBAAkB,OAAA;AAE3B,eAAe;AACf,0CAAwB;AAExB,kBAAkB;AAClB,mDAAiD;AAAxC,yGAAA,UAAU,OAAA;AAEnB,iBAAiB;AACjB,gEAAyE;AAAhE,4GAAA,gBAAgB,OAAW"}
@@ -0,0 +1,16 @@
1
+ import { HttpClient } from '../utils/http-client';
2
+ import { ThirdPartyStartApplicationReq, ThirdPartyStartAppResp } from '../types';
3
+ /**
4
+ * Application service for starting insurance applications from quotes
5
+ */
6
+ export declare class ApplicationService {
7
+ private httpClient;
8
+ constructor(httpClient: HttpClient);
9
+ /**
10
+ * Start an insurance application based on a quote response ID
11
+ * @param applicationRequest - The application request parameters
12
+ * @returns Promise with the application response containing links
13
+ */
14
+ startApplication(applicationRequest: ThirdPartyStartApplicationReq): Promise<ThirdPartyStartAppResp>;
15
+ }
16
+ //# sourceMappingURL=application.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.service.d.ts","sourceRoot":"","sources":["../../src/services/application.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EAIvB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAE1C;;;;OAIG;IACG,gBAAgB,CAAC,kBAAkB,EAAE,6BAA6B,GAAG,OAAO,CAAC,sBAAsB,CAAC;CA6B3G"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApplicationService = void 0;
4
+ const types_1 = require("../types");
5
+ /**
6
+ * Application service for starting insurance applications from quotes
7
+ */
8
+ class ApplicationService {
9
+ constructor(httpClient) {
10
+ this.httpClient = httpClient;
11
+ }
12
+ /**
13
+ * Start an insurance application based on a quote response ID
14
+ * @param applicationRequest - The application request parameters
15
+ * @returns Promise with the application response containing links
16
+ */
17
+ async startApplication(applicationRequest) {
18
+ // Check if authenticated
19
+ if (!this.httpClient.isAuthenticated()) {
20
+ throw new types_1.AuthenticationError('Must be authenticated to start applications. Call authenticate() first.');
21
+ }
22
+ try {
23
+ const response = await this.httpClient.post('/api/ThirdPartyIbTermStartApp/start-application', applicationRequest);
24
+ // Check if the response was successful
25
+ if (!response.flagStatus) {
26
+ throw new types_1.InstaBrainError(response.error || 'Failed to start application');
27
+ }
28
+ if (!response.value) {
29
+ throw new types_1.InstaBrainError('No application data received from server');
30
+ }
31
+ return response.value;
32
+ }
33
+ catch (error) {
34
+ if (error instanceof types_1.InstaBrainError) {
35
+ throw error;
36
+ }
37
+ throw new types_1.InstaBrainError('Failed to start application: ' + error.message);
38
+ }
39
+ }
40
+ }
41
+ exports.ApplicationService = ApplicationService;
42
+ //# sourceMappingURL=application.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.service.js","sourceRoot":"","sources":["../../src/services/application.service.ts"],"names":[],"mappings":";;;AACA,oCAMkB;AAElB;;GAEG;AACH,MAAa,kBAAkB;IAC7B,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAE9C;;;;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,CAAC,UAAU,CAAC,IAAI,CACzC,iDAAiD,EACjD,kBAAkB,CACnB,CAAC;YAEF,uCAAuC;YACvC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACzB,MAAM,IAAI,uBAAe,CAAC,QAAQ,CAAC,KAAK,IAAI,6BAA6B,CAAC,CAAC;YAC7E,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,+BAA+B,GAAI,KAAe,CAAC,OAAO,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;CACF;AArCD,gDAqCC"}