aeremmiddleware 1.0.3 → 1.0.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/Finance/idfy.ts +491 -255
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aeremmiddleware",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "type": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -1,292 +1,528 @@
1
1
  import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
2
2
 
3
-
4
3
  export default class IdfyAPIWrapper {
4
+ private bodyTaskIdGroupId = {
5
+ task_id: "",
6
+ group_id: "",
7
+ };
8
+ private defaultHeaderIdfyApi = {
9
+ "account-id": "",
10
+ "api-key": "",
11
+ };
12
+ private standardErrorThrowFormat = {
13
+ statusCode: 400,
14
+ message: ["bad request"],
15
+ };
16
+ private baseUrl: string = "https://eve.idfy.com/";
17
+ private gstVerificationEndPoint =
18
+ "v3/tasks/sync/verify_with_source/ind_gst_certificate";
19
+ private panIndividualVerificationEndPoint =
20
+ "v3/tasks/async/verify_with_source/ind_pan_plus";
21
+ private cinCompanyVerificationEndPoint =
22
+ "v3/tasks/async/verify_with_source/ind_mca";
23
+ private taskUrl = "v3/tasks?request_id=";
24
+ private asyncIndividualAadhaarLiteInfoEndPoint =
25
+ "v3/tasks/async/verify_with_source/aadhaar_lite";
26
+ private syncIndividualAadharScanInfoEndpoint =
27
+ "v3/tasks/sync/extract/ind_aadhaar_plus";
28
+ private syncIndividualPANScanInfoEndpoint = "v3/tasks/sync/extract/ind_pan";
29
+ private syncIndividualGSTScanInfoEndpoint =
30
+ "v3/tasks/sync/extract/ind_gst_certificate";
31
+ private syncIndividualLiveFaceLivenessEndpoint =
32
+ "v3/tasks/sync/check_photo_liveness/face";
5
33
 
6
- private bodyTaskIdGroupId = {
7
- task_id: '74f4c926-250c-43ca-9c53-453e87ceacd1',
8
- group_id: '8e16424a-58fc-4ba4-ab20-5bc8e7c3c41e',
9
- }
10
- private defaultHeaderIdfyApi = {
11
- "account-id": "e0d2add9d3c1/86e1d197-adb5-4f8f-af82-2728599a3615",
12
- "api-key": "7fad350f-5519-4ec7-b977-d8c8b131b8e4"
13
- }
14
- private standardErrorThrowFormat = {
15
- statusCode: 400,
16
- message: ["bad request"]
17
- }
18
- private baseUrl: string = "https://eve.idfy.com/";
19
- private gstVerificationEndPoint = 'v3/tasks/sync/verify_with_source/ind_gst_certificate'
20
- private panIndividualVerificationEndPoint = 'v3/tasks/async/verify_with_source/ind_pan_plus'
21
- private cinCompanyVerificationEndPoint = 'v3/tasks/async/verify_with_source/ind_mca'
22
- private taskUrl = 'v3/tasks?request_id='
23
- private asyncIndividualAadhaarLiteInfoEndPoint='v3/tasks/async/verify_with_source/aadhaar_lite'
24
- private syncIndividualAadharScanInfoEndpoint = 'v3/tasks/sync/extract/ind_aadhaar_plus'
25
- private syncIndividualPANScanInfoEndpoint = 'v3/tasks/sync/extract/ind_pan'
26
- private syncIndividualGSTScanInfoEndpoint = 'v3/tasks/sync/extract/ind_gst_certificate'
27
- private syncIndividualLiveFaceLivenessEndpoint = 'v3/tasks/sync/check_photo_liveness/face'
34
+ private idfyCompanySearch = {
35
+ defaultHeader: {
36
+ "api-key": "",
37
+ "Content-Type": "application/json",
38
+ },
39
+ version: "v1",
40
+ companySearchUrl: "https://riskai.idfystaging.com/api/v1/company/search",
41
+ taskBaseUrl: "https://riskai.idfystaging.com/api/v1/task/",
42
+ cinllpinUrl: "https://riskai.idfystaging.com/api/v1/company/basic",
43
+ };
28
44
 
29
- private idfyError = {
30
- "INVALID_IMAGE":{
31
- idfyErrorCode :"IDFY_ERR_100" ,
32
- message:"Please scan correct document"
33
- },
34
- "INSUFFICIENT_CREDITS":{
35
- idfyErrorCode :"IDFY_ERR_101" ,
36
- message:"Please renew credit"
37
- }
38
- }
45
+ private idfyError = {
46
+ INVALID_IMAGE: {
47
+ idfyErrorCode: "IDFY_ERR_100",
48
+ message: "Please scan correct document",
49
+ },
50
+ INSUFFICIENT_CREDITS: {
51
+ idfyErrorCode: "IDFY_ERR_101",
52
+ message: "Please renew credit",
53
+ },
54
+ };
39
55
 
40
-
56
+ constructor({
57
+ IDFY_TASK_ID,
58
+ IDFY_GROUP_ID,
59
+ IDFY_ACCOUNT_ID,
60
+ IDFY_API_KEY,
61
+ IDFY_COMPANY_SEARCH_API_KEY,
62
+ }) {
63
+ this.bodyTaskIdGroupId.task_id = IDFY_TASK_ID;
64
+ this.bodyTaskIdGroupId.group_id = IDFY_GROUP_ID;
65
+ this.defaultHeaderIdfyApi["account-id"] = IDFY_ACCOUNT_ID;
66
+ this.defaultHeaderIdfyApi["api-key"] = IDFY_API_KEY;
67
+ this.idfyCompanySearch.defaultHeader["api-key"] =
68
+ IDFY_COMPANY_SEARCH_API_KEY;
69
+ }
41
70
 
71
+ private async makeRequest<T>(
72
+ method: string,
73
+ endpoint: string,
74
+ data?: any
75
+ ): Promise<T> {
76
+ const requestConfig: AxiosRequestConfig = {
77
+ method,
78
+ url: this.baseUrl + endpoint,
79
+ headers: this.defaultHeaderIdfyApi,
80
+ data,
81
+ };
42
82
 
43
- constructor() { }
83
+ try {
84
+ const response: AxiosResponse<T> = await axios(requestConfig);
85
+ return response.data;
86
+ } catch (error) {
87
+ console.error("Error while making Idfy Axios API request:", error);
88
+ throw error;
89
+ }
90
+ }
44
91
 
45
- private async makeRequest<T>(
46
- method: string,
47
- endpoint: string,
48
- data?: any
49
- ): Promise<T> {
50
- const requestConfig: AxiosRequestConfig = {
51
- method,
52
- url: this.baseUrl + endpoint,
53
- headers: this.defaultHeaderIdfyApi,
54
- data,
55
- };
92
+ private async makeAxiosRequest<T>({
93
+ method,
94
+ url,
95
+ data,
96
+ headers,
97
+ }: {
98
+ method: string;
99
+ url: string;
100
+ data?: any;
101
+ headers: any;
102
+ }): Promise<T> {
103
+ const requestConfig: AxiosRequestConfig = {
104
+ method,
105
+ url,
106
+ headers,
107
+ data,
108
+ };
56
109
 
57
- try {
58
- const response: AxiosResponse<T> = await axios(requestConfig);
59
- return response.data;
60
- } catch (error) {
61
- console.error("Error while making Idfy Axios API request:", error);
62
- throw error;
63
- }
110
+ try {
111
+ const response: AxiosResponse<T> = await axios(requestConfig);
112
+ return response.data;
113
+ } catch (error) {
114
+ console.error(
115
+ "Error while making Idfy makeAxiosRequest API request:",
116
+ error
117
+ );
118
+ throw error;
64
119
  }
120
+ }
65
121
 
66
- private async getTask(requestId: string): Promise<any> {
67
- try {
68
- // const data = {}
69
- const urlEndPoint = this.taskUrl + requestId
70
- const response = await this.makeRequest<any>("get", urlEndPoint);
71
- return response;
72
- } catch (error) {
73
- console.error("Error while fetching Idfy getTask API data:", error);
74
- throw error;
75
- }
122
+ private async getTask(requestId: string): Promise<any> {
123
+ try {
124
+ // const data = {}
125
+ const urlEndPoint = this.taskUrl + requestId;
126
+ const response = await this.makeRequest<any>("get", urlEndPoint);
127
+ return response;
128
+ } catch (error) {
129
+ console.error("Error while fetching Idfy getTask API data:", error);
130
+ throw error;
76
131
  }
132
+ }
77
133
 
78
- private async pingTaskUntilSuccess(requestId: string): Promise<any> {
79
- try {
134
+ private async getCompanySearchTask({
135
+ requestId,
136
+ }: {
137
+ requestId: string;
138
+ }): Promise<any> {
139
+ try {
140
+ const taskBaseUrl = this.idfyCompanySearch.taskBaseUrl + requestId;
141
+ const response = await this.makeAxiosRequest({
142
+ method: "get",
143
+ url: taskBaseUrl,
144
+ headers: this.idfyCompanySearch.defaultHeader,
145
+ });
146
+ return response;
147
+ } catch (error) {
148
+ console.error(
149
+ "Error while fetching Idfy getCompanySearchTask API data:",
150
+ error
151
+ );
152
+ throw error;
153
+ }
154
+ }
80
155
 
81
- let res: any = null
82
- const checkTaskAfter1sec = (requestId:string) => {
83
- return new Promise<any>((resolve, reject) => {
84
- try{
85
- setTimeout(async () => {
86
- const data = await this.getTask(requestId)
87
- if(res?.[0].status == 'failed'){
88
- reject(res)
89
- }
90
- resolve(data)
91
- }, 1000)
92
-
93
- }catch(e){
94
- reject(e)
95
- }
96
- })
97
- }
98
- do {
99
- res = await checkTaskAfter1sec(requestId)
100
-
101
- console.log( "### res ",res) ;
102
- } while (res?.[0].status !== 'completed')
156
+ private async pingTaskUntilSuccess(requestId: string): Promise<any> {
157
+ try {
158
+ let res: any = null;
159
+ const checkTaskAfter1sec = (requestId) => {
160
+ return new Promise<any>((resolve, reject) => {
161
+ try {
162
+ setTimeout(async () => {
163
+ const data = await this.getTask(requestId);
164
+ if (res?.[0].status == "failed") {
165
+ reject(res);
166
+ }
167
+ resolve(data);
168
+ }, 1000);
169
+ } catch (e) {
170
+ reject(e);
171
+ }
172
+ });
173
+ };
174
+ do {
175
+ res = await checkTaskAfter1sec(requestId);
103
176
 
104
- return res;
177
+ console.log("### res ", res);
178
+ } while (res?.[0].status !== "completed");
105
179
 
106
- } catch (error) {
107
- console.error("Error while fetching Idfy getTask API data:", error);
108
- throw error;
109
- }
180
+ return res;
181
+ } catch (error) {
182
+ console.error("Error while fetching Idfy getTask API data:", error);
183
+ throw error;
110
184
  }
111
- async getCompanyGstInfo({ gstNo }: { gstNo: string }): Promise<any> {
112
- try {
113
- const data = {
114
- ...(this.bodyTaskIdGroupId),
115
- data: {
116
- gstin: gstNo,
117
- }
118
- }
119
- const response = await this.makeRequest<any>("post", this.gstVerificationEndPoint, data);
120
- return response;
121
- } catch (error) {
122
-
123
- // if(error?.response?.data?.error){
124
- // const errorObj = this.idfyError[error?.response?.data?.error]
125
- // if(errorObj)
126
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
127
- // }
185
+ }
128
186
 
129
- throw error;
130
- }
187
+ private async pingCompanySearchTaskUntilSuccess(
188
+ requestId: string
189
+ ): Promise<any> {
190
+ try {
191
+ console.log(" ## requestId ", requestId);
192
+ let res: any = null;
193
+ const checkTaskAfter1sec = (requestId) => {
194
+ return new Promise<any>((resolve, reject) => {
195
+ try {
196
+ setTimeout(async () => {
197
+ const data = await this.getCompanySearchTask({ requestId });
198
+ if (data.status != "failed") {
199
+ resolve(data);
200
+ } else {
201
+ reject(res);
202
+ }
203
+ }, 1000);
204
+ } catch (e) {
205
+ reject(e);
206
+ }
207
+ });
208
+ };
209
+ do {
210
+ res = await checkTaskAfter1sec(requestId);
211
+ console.log("### res ", res);
212
+ } while (res?.status !== "completed");
213
+
214
+ return res;
215
+ } catch (error) {
216
+ console.error("Error while fetching Idfy getTask API data:", error);
217
+ throw error;
131
218
  }
132
- async getCompanyCINInfo({ cinNo }: { cinNo: string }): Promise<any> {
133
- try {
134
- const data = {
135
- ...(this.bodyTaskIdGroupId),
136
- data: {
137
- "cin": cinNo,
138
- }
139
- }
140
- const response = await this.makeRequest<any>("post", this.cinCompanyVerificationEndPoint, data);
141
- const successData = await this.pingTaskUntilSuccess(response.request_id)
219
+ }
220
+ async getCompanyGstInfo({ gstNo }: { gstNo: string }): Promise<any> {
221
+ try {
222
+ const data = {
223
+ ...this.bodyTaskIdGroupId,
224
+ data: {
225
+ gstin: gstNo,
226
+ },
227
+ };
228
+ const response = await this.makeRequest<any>(
229
+ "post",
230
+ this.gstVerificationEndPoint,
231
+ data
232
+ );
233
+ return response;
234
+ } catch (error) {
235
+ if (error?.response?.data?.error) {
236
+ const errorObj = this.idfyError[error?.response?.data?.error];
237
+ if (errorObj)
238
+ throw {
239
+ ...this.standardErrorThrowFormat,
240
+ message: [errorObj.message],
241
+ };
242
+ }
142
243
 
143
- return successData?.[0]?.result?.source_output;
144
- } catch (error) {
145
- // if(error?.response?.data?.error){
146
- // const errorObj = this.idfyError[error?.response?.data?.error]
147
- // if(errorObj)
148
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
149
- // }
150
- throw error;
151
- }
244
+ throw error;
152
245
  }
153
- async getIndividualPANInfo({ panNo }: { panNo: string }): Promise<any> {
154
- try {
155
- const data = {
156
- ...(this.bodyTaskIdGroupId),
157
- data: {
158
- "id_number": panNo,
159
- }
160
- }
161
- const response = await this.makeRequest<any>("post", this.panIndividualVerificationEndPoint, data);
162
- const successData = await this.pingTaskUntilSuccess(response.request_id)
246
+ }
247
+ async getCompanyCINInfo({ cinNo }: { cinNo: string }): Promise<any> {
248
+ try {
249
+ const data = {
250
+ ...this.bodyTaskIdGroupId,
251
+ data: {
252
+ cin: cinNo,
253
+ },
254
+ };
255
+ const response = await this.makeRequest<any>(
256
+ "post",
257
+ this.cinCompanyVerificationEndPoint,
258
+ data
259
+ );
260
+ const successData = await this.pingTaskUntilSuccess(response.request_id);
163
261
 
164
- return successData;
165
- } catch (error) {
166
- // if(error?.response?.data?.error){
167
- // const errorObj = this.idfyError[error?.response?.data?.error]
168
- // if(errorObj)
169
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
170
- // }
171
- throw error;
172
- }
262
+ return successData?.[0]?.result?.source_output;
263
+ } catch (error) {
264
+ if (error?.response?.data?.error) {
265
+ const errorObj = this.idfyError[error?.response?.data?.error];
266
+ if (errorObj)
267
+ throw {
268
+ ...this.standardErrorThrowFormat,
269
+ message: [errorObj.message],
270
+ };
271
+ }
272
+ throw error;
173
273
  }
274
+ }
275
+ async getIndividualPANInfo({ panNo }: { panNo: string }): Promise<any> {
276
+ try {
277
+ const data = {
278
+ ...this.bodyTaskIdGroupId,
279
+ data: {
280
+ id_number: panNo,
281
+ },
282
+ };
283
+ const response = await this.makeRequest<any>(
284
+ "post",
285
+ this.panIndividualVerificationEndPoint,
286
+ data
287
+ );
288
+ const successData = await this.pingTaskUntilSuccess(response.request_id);
174
289
 
175
- async getSyncIndividualAadharScanInfo({ frontScanBase64,backScanBase64 }: { frontScanBase64: string,backScanBase64:string }): Promise<any> {
176
- try {
177
- const data = {
178
- ...(this.bodyTaskIdGroupId),
179
- data: {
180
- "document1":frontScanBase64,
181
- "document2":backScanBase64,
182
- "consent":"yes",
183
- "advanced_details": {
184
- "extract_qr_info": true,
185
- "extract_last_4_digit":false
186
- }
187
- }
188
- }
189
- const response = await this.makeRequest<any>("post", this.syncIndividualAadharScanInfoEndpoint, data);
190
-
191
- return response?.result;
192
- } catch (error) {
193
- // if(error?.response?.data?.error){
194
- // const errorObj = this.idfyError[error?.response?.data?.error]
195
- // if(errorObj)
196
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
197
- // }
198
- throw error;
199
- }
290
+ return successData;
291
+ } catch (error) {
292
+ if (error?.response?.data?.error) {
293
+ const errorObj = this.idfyError[error?.response?.data?.error];
294
+ if (errorObj)
295
+ throw {
296
+ ...this.standardErrorThrowFormat,
297
+ message: [errorObj.message],
298
+ };
299
+ }
300
+ throw error;
200
301
  }
302
+ }
201
303
 
202
- async getSyncIndividualPANScanInfo({ frontScanBase64 }: { frontScanBase64: string }): Promise<any> {
203
- try {
204
- const data = {
205
- ...(this.bodyTaskIdGroupId),
206
- data: {
207
- "document1":frontScanBase64,
208
- "consent":"yes",
209
- }
210
- }
211
- const response = await this.makeRequest<any>("post", this.syncIndividualPANScanInfoEndpoint, data);
212
-
213
- return response?.result;
214
- } catch (error) {
215
- // if(error?.response?.data?.error){
216
- // const errorObj = this.idfyError[error?.response?.data?.error]
217
- // if(errorObj)
218
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
219
- // }
220
- throw error;
221
- }
304
+ async getSyncIndividualAadharScanInfo({
305
+ frontScanBase64,
306
+ backScanBase64,
307
+ }: {
308
+ frontScanBase64: string;
309
+ backScanBase64: string;
310
+ }): Promise<any> {
311
+ try {
312
+ const data = {
313
+ ...this.bodyTaskIdGroupId,
314
+ data: {
315
+ document1: frontScanBase64,
316
+ document2: backScanBase64,
317
+ consent: "yes",
318
+ advanced_details: {
319
+ extract_qr_info: true,
320
+ extract_last_4_digit: false,
321
+ },
322
+ },
323
+ };
324
+ const response = await this.makeRequest<any>(
325
+ "post",
326
+ this.syncIndividualAadharScanInfoEndpoint,
327
+ data
328
+ );
329
+
330
+ return response?.result;
331
+ } catch (error) {
332
+ if (error?.response?.data?.error) {
333
+ const errorObj = this.idfyError[error?.response?.data?.error];
334
+ if (errorObj)
335
+ throw {
336
+ ...this.standardErrorThrowFormat,
337
+ message: [errorObj.message],
338
+ };
339
+ }
340
+ throw error;
222
341
  }
342
+ }
223
343
 
344
+ async getSyncIndividualPANScanInfo({
345
+ frontScanBase64,
346
+ }: {
347
+ frontScanBase64: string;
348
+ }): Promise<any> {
349
+ try {
350
+ const data = {
351
+ ...this.bodyTaskIdGroupId,
352
+ data: {
353
+ document1: frontScanBase64,
354
+ consent: "yes",
355
+ },
356
+ };
357
+ const response = await this.makeRequest<any>(
358
+ "post",
359
+ this.syncIndividualPANScanInfoEndpoint,
360
+ data
361
+ );
224
362
 
225
- async getSyncCompanyGSTScanInfo({ frontScanBase64 }: { frontScanBase64: string }): Promise<any> {
226
- try {
227
- const data = {
228
- ...(this.bodyTaskIdGroupId),
229
- data: {
230
- "document1":frontScanBase64
231
- }
232
- }
233
- const response = await this.makeRequest<any>("post", this.syncIndividualGSTScanInfoEndpoint, data);
234
-
235
- return response?.result;
236
- } catch (error) {
237
- // if(error?.response?.data?.error){
238
- // const errorObj = this.idfyError[error?.response?.data?.error]
239
- // if(errorObj)
240
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
241
- // }
242
- throw error;
243
- }
363
+ return response?.result;
364
+ } catch (error) {
365
+ if (error?.response?.data?.error) {
366
+ const errorObj = this.idfyError[error?.response?.data?.error];
367
+ if (errorObj)
368
+ throw {
369
+ ...this.standardErrorThrowFormat,
370
+ message: [errorObj.message],
371
+ };
372
+ }
373
+ throw error;
244
374
  }
375
+ }
245
376
 
377
+ async getSyncCompanyGSTScanInfo({
378
+ frontScanBase64,
379
+ }: {
380
+ frontScanBase64: string;
381
+ }): Promise<any> {
382
+ try {
383
+ const data = {
384
+ ...this.bodyTaskIdGroupId,
385
+ data: {
386
+ document1: frontScanBase64,
387
+ },
388
+ };
389
+ const response = await this.makeRequest<any>(
390
+ "post",
391
+ this.syncIndividualGSTScanInfoEndpoint,
392
+ data
393
+ );
246
394
 
247
- async getSyncIndividualLivenessSelfyScanInfo({ faceScanBase64 }: { faceScanBase64: string }): Promise<any> {
248
- try {
249
- const data = {
250
- ...(this.bodyTaskIdGroupId),
251
- data: {
252
- "document1":faceScanBase64,
253
- "consent":"yes",
254
- }
255
- }
256
- const response = await this.makeRequest<any>("post", this.syncIndividualLiveFaceLivenessEndpoint, data);
257
-
258
- return response?.result;
259
- } catch (error) {
260
- // if(error?.response?.data?.error){
261
- // const errorObj = this.idfyError[error?.response?.data?.error]
262
- // if(errorObj)
263
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
264
- // }
265
- throw error;
266
- }
395
+ return response?.result;
396
+ } catch (error) {
397
+ if (error?.response?.data?.error) {
398
+ const errorObj = this.idfyError[error?.response?.data?.error];
399
+ if (errorObj)
400
+ throw {
401
+ ...this.standardErrorThrowFormat,
402
+ message: [errorObj.message],
403
+ };
404
+ }
405
+ throw error;
267
406
  }
407
+ }
408
+
409
+ async getSyncIndividualLivenessSelfyScanInfo({
410
+ faceScanBase64,
411
+ }: {
412
+ faceScanBase64: string;
413
+ }): Promise<any> {
414
+ try {
415
+ const data = {
416
+ ...this.bodyTaskIdGroupId,
417
+ data: {
418
+ document1: faceScanBase64,
419
+ consent: "yes",
420
+ },
421
+ };
422
+ const response = await this.makeRequest<any>(
423
+ "post",
424
+ this.syncIndividualLiveFaceLivenessEndpoint,
425
+ data
426
+ );
427
+
428
+ return response?.result;
429
+ } catch (error) {
430
+ if (error?.response?.data?.error) {
431
+ const errorObj = this.idfyError[error?.response?.data?.error];
432
+ if (errorObj)
433
+ throw {
434
+ ...this.standardErrorThrowFormat,
435
+ message: [errorObj.message],
436
+ };
437
+ }
438
+ throw error;
439
+ }
440
+ }
441
+
442
+ async getAsyncAadhaarLiteInfo({
443
+ aadhaarNo,
444
+ }: {
445
+ aadhaarNo: string;
446
+ }): Promise<any> {
447
+ try {
448
+ const data = {
449
+ ...this.bodyTaskIdGroupId,
450
+ data: {
451
+ aadhaar_number: aadhaarNo,
452
+ },
453
+ };
454
+ const response = await this.makeRequest<any>(
455
+ "post",
456
+ this.asyncIndividualAadhaarLiteInfoEndPoint,
457
+ data
458
+ );
459
+ const successData = await this.pingTaskUntilSuccess(response.request_id);
268
460
 
269
-
270
- async getAsyncAadhaarLiteInfo({ aadhaarNo }: { aadhaarNo: string }): Promise<any> {
271
- try {
272
- const data = {
273
- ...(this.bodyTaskIdGroupId),
274
- data: {
275
- "aadhaar_number": aadhaarNo
276
- }
277
- }
278
- const response = await this.makeRequest<any>("post", this.asyncIndividualAadhaarLiteInfoEndPoint, data);
279
- const successData = await this.pingTaskUntilSuccess(response.request_id)
280
-
281
- return successData;
282
- } catch (error) {
283
- // if(error?.response?.data?.error){
284
- // const errorObj = this.idfyError[error?.response?.data?.error]
285
- // if(errorObj)
286
- // throw ({ ...this.standardErrorThrowFormat, message: [errorObj.message] })
287
- // }
288
- throw error;
289
- }
461
+ return successData;
462
+ } catch (error) {
463
+ if (error?.response?.data?.error) {
464
+ const errorObj = this.idfyError[error?.response?.data?.error];
465
+ if (errorObj)
466
+ throw {
467
+ ...this.standardErrorThrowFormat,
468
+ message: [errorObj.message],
469
+ };
470
+ }
471
+ throw error;
290
472
  }
473
+ }
291
474
 
292
- }
475
+ async getCompanyDetailsByName({
476
+ legalName,
477
+ }: {
478
+ legalName: string;
479
+ }): Promise<any> {
480
+ try {
481
+ const data = {
482
+ version: this.idfyCompanySearch.version,
483
+ ...this.bodyTaskIdGroupId,
484
+ data: {
485
+ name: legalName,
486
+ },
487
+ };
488
+ const response = await this.makeAxiosRequest<any>({
489
+ method: "post",
490
+ url: this.idfyCompanySearch.companySearchUrl,
491
+ data,
492
+ headers: this.idfyCompanySearch.defaultHeader,
493
+ });
494
+ const successData = await this.pingCompanySearchTaskUntilSuccess(
495
+ response.request_id
496
+ );
497
+
498
+ return { request_id: response, successData: successData };
499
+ } catch (error) {
500
+ throw error;
501
+ }
502
+ }
503
+
504
+ async getCompanyDetailsByLlpinOrCin({
505
+ cinOrLlpin,
506
+ }: {
507
+ cinOrLlpin: string;
508
+ }): Promise<any> {
509
+ try {
510
+ const data = {
511
+ version: this.idfyCompanySearch.version,
512
+ ...this.bodyTaskIdGroupId,
513
+ data: {
514
+ cin_llpin: cinOrLlpin,
515
+ },
516
+ };
517
+ const response = await this.makeAxiosRequest<any>({
518
+ method: "post",
519
+ url: this.idfyCompanySearch.cinllpinUrl,
520
+ data,
521
+ headers: this.idfyCompanySearch.defaultHeader,
522
+ });
523
+ return { response: response };
524
+ } catch (error) {
525
+ throw error;
526
+ }
527
+ }
528
+ }