aeremmiddleware 1.0.61 → 1.0.62

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.
@@ -40,8 +40,10 @@ export default class IdfyAPIWrapper {
40
40
  "v3/tasks/sync/check_photo_liveness/face";
41
41
  private getDigilockerDetailsEndpoint =
42
42
  "v3/tasks/async/verify_with_source/ind_digilocker_fetch_documents";
43
- private getUdhyamEndpoint =
44
- "v3/tasks/async/verify_with_source/udyam_aadhaar";
43
+ private getUdhyamEndpoint = "v3/tasks/async/verify_with_source/udyam_aadhaar";
44
+ private syncIndividualNamesCompareEndpoint =
45
+ "v3/tasks/sync/compare/ind_names";
46
+
45
47
  private doc_type = ["ADHAR", "PANCR"];
46
48
  private file_format = "xml";
47
49
  private callbackUrl: string;
@@ -52,8 +54,7 @@ export default class IdfyAPIWrapper {
52
54
  "Content-Type": "application/json",
53
55
  },
54
56
  version: "v1",
55
- companySearchUrl:
56
- "https://riskai.idfystaging.com/api/v1/company/search",
57
+ companySearchUrl: "https://riskai.idfystaging.com/api/v1/company/search",
57
58
  taskBaseUrl: "https://riskai.idfystaging.com/api/v1/task/",
58
59
  cinllpinUrl: "https://riskai.idfystaging.com/api/v1/company/basic",
59
60
  };
@@ -89,7 +90,7 @@ export default class IdfyAPIWrapper {
89
90
  private async makeRequest<T>(
90
91
  method: string,
91
92
  endpoint: string,
92
- data?: any
93
+ data?: any,
93
94
  ): Promise<T> {
94
95
  const requestConfig: AxiosRequestConfig = {
95
96
  method,
@@ -131,7 +132,7 @@ export default class IdfyAPIWrapper {
131
132
  } catch (error) {
132
133
  console.error(
133
134
  "Error while making Idfy makeAxiosRequest API request:",
134
- error
135
+ error,
135
136
  );
136
137
  throw error;
137
138
  }
@@ -165,7 +166,7 @@ export default class IdfyAPIWrapper {
165
166
  } catch (error) {
166
167
  console.error(
167
168
  "Error while fetching Idfy getCompanySearchTask API data:",
168
- error
169
+ error,
169
170
  );
170
171
  throw error;
171
172
  }
@@ -203,7 +204,7 @@ export default class IdfyAPIWrapper {
203
204
  }
204
205
 
205
206
  private async pingCompanySearchTaskUntilSuccess(
206
- requestId: string
207
+ requestId: string,
207
208
  ): Promise<any> {
208
209
  try {
209
210
  console.log(" ## requestId ", requestId);
@@ -248,14 +249,13 @@ export default class IdfyAPIWrapper {
248
249
  const response = await this.makeRequest<any>(
249
250
  "post",
250
251
  this.gstVerificationEndPoint,
251
- data
252
+ data,
252
253
  );
253
254
  return response;
254
255
  } catch (error: any) {
255
256
  if (error?.response?.data?.error) {
256
257
  let obj = this.idfyError;
257
- const errorObj =
258
- obj[error?.response?.data?.error as keyof typeof obj];
258
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
259
259
  if (errorObj)
260
260
  throw {
261
261
  ...this.standardErrorThrowFormat,
@@ -277,18 +277,15 @@ export default class IdfyAPIWrapper {
277
277
  const response = await this.makeRequest<any>(
278
278
  "post",
279
279
  this.cinCompanyVerificationEndPoint,
280
- data
281
- );
282
- const successData = await this.pingTaskUntilSuccess(
283
- response.request_id
280
+ data,
284
281
  );
282
+ const successData = await this.pingTaskUntilSuccess(response.request_id);
285
283
 
286
284
  return successData?.[0]?.result?.source_output;
287
285
  } catch (error: any) {
288
286
  if (error?.response?.data?.error) {
289
287
  let obj = this.idfyError;
290
- const errorObj =
291
- obj[error?.response?.data?.error as keyof typeof obj];
288
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
292
289
  if (errorObj)
293
290
  throw {
294
291
  ...this.standardErrorThrowFormat,
@@ -309,18 +306,15 @@ export default class IdfyAPIWrapper {
309
306
  const response = await this.makeRequest<any>(
310
307
  "post",
311
308
  this.panIndividualVerificationEndPoint,
312
- data
313
- );
314
- const successData = await this.pingTaskUntilSuccess(
315
- response.request_id
309
+ data,
316
310
  );
311
+ const successData = await this.pingTaskUntilSuccess(response.request_id);
317
312
 
318
313
  return successData;
319
314
  } catch (error: any) {
320
315
  if (error?.response?.data?.error) {
321
316
  let obj = this.idfyError;
322
- const errorObj =
323
- obj[error?.response?.data?.error as keyof typeof obj];
317
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
324
318
  if (errorObj)
325
319
  throw {
326
320
  ...this.standardErrorThrowFormat,
@@ -354,15 +348,14 @@ export default class IdfyAPIWrapper {
354
348
  const response = await this.makeRequest<any>(
355
349
  "post",
356
350
  this.syncIndividualAadharScanInfoEndpoint,
357
- data
351
+ data,
358
352
  );
359
353
 
360
354
  return response?.result;
361
355
  } catch (error: any) {
362
356
  if (error?.response?.data?.error) {
363
357
  let obj = this.idfyError;
364
- const errorObj =
365
- obj[error?.response?.data?.error as keyof typeof obj];
358
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
366
359
  if (errorObj)
367
360
  throw {
368
361
  ...this.standardErrorThrowFormat,
@@ -389,15 +382,14 @@ export default class IdfyAPIWrapper {
389
382
  const response = await this.makeRequest<any>(
390
383
  "post",
391
384
  this.syncIndividualPANScanInfoEndpoint,
392
- data
385
+ data,
393
386
  );
394
387
 
395
388
  return response?.result;
396
389
  } catch (error: any) {
397
390
  if (error?.response?.data?.error) {
398
391
  let obj = this.idfyError;
399
- const errorObj =
400
- obj[error?.response?.data?.error as keyof typeof obj];
392
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
401
393
  if (errorObj)
402
394
  throw {
403
395
  ...this.standardErrorThrowFormat,
@@ -423,15 +415,14 @@ export default class IdfyAPIWrapper {
423
415
  const response = await this.makeRequest<any>(
424
416
  "post",
425
417
  this.syncIndividualGSTScanInfoEndpoint,
426
- data
418
+ data,
427
419
  );
428
420
 
429
421
  return response?.result;
430
422
  } catch (error: any) {
431
423
  if (error?.response?.data?.error) {
432
424
  let obj = this.idfyError;
433
- const errorObj =
434
- obj[error?.response?.data?.error as keyof typeof obj];
425
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
435
426
  if (errorObj)
436
427
  throw {
437
428
  ...this.standardErrorThrowFormat,
@@ -458,15 +449,14 @@ export default class IdfyAPIWrapper {
458
449
  const response = await this.makeRequest<any>(
459
450
  "post",
460
451
  this.syncIndividualLiveFaceLivenessEndpoint,
461
- data
452
+ data,
462
453
  );
463
454
 
464
455
  return response?.result;
465
456
  } catch (error: any) {
466
457
  if (error?.response?.data?.error) {
467
458
  let obj = this.idfyError;
468
- const errorObj =
469
- obj[error?.response?.data?.error as keyof typeof obj];
459
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
470
460
  if (errorObj)
471
461
  throw {
472
462
  ...this.standardErrorThrowFormat,
@@ -492,18 +482,15 @@ export default class IdfyAPIWrapper {
492
482
  const response = await this.makeRequest<any>(
493
483
  "post",
494
484
  this.asyncIndividualAadhaarLiteInfoEndPoint,
495
- data
496
- );
497
- const successData = await this.pingTaskUntilSuccess(
498
- response.request_id
485
+ data,
499
486
  );
487
+ const successData = await this.pingTaskUntilSuccess(response.request_id);
500
488
 
501
489
  return successData;
502
490
  } catch (error: any) {
503
491
  if (error?.response?.data?.error) {
504
492
  let obj = this.idfyError;
505
- const errorObj =
506
- obj[error?.response?.data?.error as keyof typeof obj];
493
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
507
494
  if (errorObj)
508
495
  throw {
509
496
  ...this.standardErrorThrowFormat,
@@ -534,7 +521,7 @@ export default class IdfyAPIWrapper {
534
521
  headers: this.idfyCompanySearch.defaultHeader,
535
522
  });
536
523
  const successData = await this.pingCompanySearchTaskUntilSuccess(
537
- response.request_id
524
+ response.request_id,
538
525
  );
539
526
 
540
527
  return { request_id: response, successData: successData };
@@ -588,7 +575,7 @@ export default class IdfyAPIWrapper {
588
575
  const res = await this.makeRequest<any>(
589
576
  "post",
590
577
  "v3/tasks/async/compare/face",
591
- data
578
+ data,
592
579
  );
593
580
  const requestId = res.request_id;
594
581
  const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
@@ -603,8 +590,7 @@ export default class IdfyAPIWrapper {
603
590
  } catch (error: any) {
604
591
  if (error?.response?.data?.error) {
605
592
  let obj = this.idfyError;
606
- const errorObj =
607
- obj[error?.response?.data?.error as keyof typeof obj];
593
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
608
594
  if (errorObj)
609
595
  throw {
610
596
  ...this.standardErrorThrowFormat,
@@ -652,7 +638,7 @@ export default class IdfyAPIWrapper {
652
638
  const res = await this.makeRequest<any>(
653
639
  "post",
654
640
  this.getDigilockerDetailsEndpoint,
655
- datas
641
+ datas,
656
642
  );
657
643
  const requestId = res.request_id;
658
644
  const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
@@ -669,8 +655,7 @@ export default class IdfyAPIWrapper {
669
655
  } catch (error: any) {
670
656
  if (error?.response?.data?.error) {
671
657
  let obj = this.idfyError;
672
- const errorObj =
673
- obj[error?.response?.data?.error as keyof typeof obj];
658
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
674
659
  if (errorObj)
675
660
  throw {
676
661
  ...this.standardErrorThrowFormat,
@@ -693,7 +678,7 @@ export default class IdfyAPIWrapper {
693
678
  const res = await this.makeRequest<any>(
694
679
  "post",
695
680
  this.getUdhyamEndpoint,
696
- data
681
+ data,
697
682
  );
698
683
  const requestId = res.request_id;
699
684
  const response = (await this.pingTaskUntilSuccess(requestId))?.[0];
@@ -701,8 +686,7 @@ export default class IdfyAPIWrapper {
701
686
  } catch (error: any) {
702
687
  if (error?.response?.data?.error) {
703
688
  let obj = this.idfyError;
704
- const errorObj =
705
- obj[error?.response?.data?.error as keyof typeof obj];
689
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
706
690
  if (errorObj)
707
691
  throw {
708
692
  ...this.standardErrorThrowFormat,
@@ -712,4 +696,41 @@ export default class IdfyAPIWrapper {
712
696
  throw convertToCamelCase(error);
713
697
  }
714
698
  }
699
+
700
+ async getSyncIndividualNamesCompare({
701
+ name1,
702
+ name2,
703
+ }: {
704
+ name1: string;
705
+ name2: string;
706
+ }): Promise<any> {
707
+ try {
708
+ const data = {
709
+ ...this.bodyTaskIdGroupId,
710
+ data: {
711
+ name1,
712
+ name2,
713
+ percentage: true,
714
+ },
715
+ };
716
+ const response = await this.makeRequest<any>(
717
+ "post",
718
+ this.syncIndividualNamesCompareEndpoint,
719
+ data,
720
+ );
721
+
722
+ return response?.result;
723
+ } catch (error: any) {
724
+ if (error?.response?.data?.error) {
725
+ let obj = this.idfyError;
726
+ const errorObj = obj[error?.response?.data?.error as keyof typeof obj];
727
+ if (errorObj)
728
+ throw {
729
+ ...this.standardErrorThrowFormat,
730
+ message: [errorObj.message],
731
+ };
732
+ }
733
+ throw error;
734
+ }
735
+ }
715
736
  }