aeremmiddleware 1.0.25 → 1.0.26

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.
@@ -67,9 +67,7 @@ class IngenicoApiWrapper {
67
67
  },
68
68
  });
69
69
 
70
- const responseData = response.data;
71
-
72
- console.log(responseData);
70
+ return response.data;
73
71
  } catch (error) {
74
72
  console.error("Error:", error);
75
73
  }
@@ -83,9 +81,7 @@ class IngenicoApiWrapper {
83
81
  },
84
82
  });
85
83
 
86
- const responseData = response.data;
87
-
88
- console.log(responseData);
84
+ return response.data;
89
85
  } catch (error) {
90
86
  console.error("Error:", error);
91
87
  }
@@ -98,9 +94,7 @@ class IngenicoApiWrapper {
98
94
  },
99
95
  });
100
96
 
101
- const responseData = response.data;
102
-
103
- console.log(responseData);
97
+ return response.data;
104
98
  } catch (error) {
105
99
  console.error("Error:", error);
106
100
  }
@@ -9,16 +9,23 @@ import {
9
9
 
10
10
  class NovelApiWrapper {
11
11
  private authToken: string;
12
-
13
- constructor() {
14
- this.authToken = "API://cJCwpFvaLS/qd7W8APrJt3tObcKQqZubh2/yoMHXsa4=";
15
- }
16
- private baseApiUrl = "https://cartbi.com/api/";
12
+ private isStaging: boolean;
13
+ private baseApiUrl: string;
17
14
  private uploadEndpoint = "upload";
18
15
  private downloadExcelEndpoint = "downloadFileAsExcel";
19
16
  private downloadJsonEndpoint = "downloadFile";
20
17
  private autoFetchEndpoint = "generateNetBankingRequest";
21
18
 
19
+ constructor(isStaging: boolean) {
20
+ this.isStaging = isStaging;
21
+ this.baseApiUrl = this.isStaging
22
+ ? "https://cartuat.com/api/"
23
+ : "https://cartbi.com/api/";
24
+ this.authToken = this.isStaging
25
+ ? "API://ET3S5WMo+L3d4lmRF6mOTOM1cPj/TKzuq3JCAyJO2BWPtoVJZ9trpECeSxrzEk05"
26
+ : "API://cJCwpFvaLS/qd7W8APrJt3tObcKQqZubh2/yoMHXsa4=";
27
+ }
28
+
22
29
  async uploadDocument(
23
30
  file: Buffer,
24
31
  filename: string,
@@ -48,15 +55,12 @@ class NovelApiWrapper {
48
55
  );
49
56
  if (response.status === 200) {
50
57
  console.log(response.data.docId, "Document uploaded successfully");
51
- console.log("Response:", response.data);
52
58
  } else {
53
59
  console.error("Failed to upload document");
54
- console.error("Response:", response.data);
55
60
  }
56
61
 
57
62
  return response.data;
58
63
  } catch (error: any) {
59
- console.error("Error:", error.message);
60
64
  return error.message;
61
65
  }
62
66
  }
@@ -101,7 +105,6 @@ class NovelApiWrapper {
101
105
 
102
106
  if (response.data.error == false) {
103
107
  console.log("File downloaded successfully");
104
- console.log(response.data);
105
108
  return response.data;
106
109
  } else {
107
110
  console.error("Failed to download file");
@@ -127,7 +130,6 @@ class NovelApiWrapper {
127
130
 
128
131
  if (response.status == 200) {
129
132
  console.log("File downloaded successfully");
130
- console.log(response.data);
131
133
  return response.data;
132
134
  } else {
133
135
  console.error("Failed to download file");
@@ -0,0 +1,560 @@
1
+ import axios from "axios";
2
+ import {
3
+ ConsentBodyType,
4
+ DigiData,
5
+ FiDataFetchBodyType,
6
+ MultiConsentBodyType,
7
+ PanVerificationBodyType,
8
+ TokenApiBodyType,
9
+ } from "./setu.types";
10
+ class SetuApiWrapper {
11
+ private baseUrl = "https://dg-sandbox.setu.co";
12
+ private aaBaseUrl = "https://fiu-sandbox.setu.co";
13
+ private aaTokenApiUrl = "https://orgservice-prod.setu.co/v1/users/login";
14
+ private panVerificationEndpoint = "/api/verify/pan";
15
+ private createOkycRequestEndpoint = "/api/okyc";
16
+ private createDigilockerRequestendpoint = "/api/digilocker";
17
+ private getListOfAllDocumentEndpoint = "/api/digilocker/documents";
18
+ private bavVerifyBanEndpoint = "/api/verify/ban";
19
+ private bavVerifyBanAsyncEndpoint = "/api/verify/ban/async";
20
+ private reverseBavCreateRpdEndpoint = "/api/verify/ban/reverse";
21
+ private pennylessBavEndpoint = "/api/verify/ban/pennyless";
22
+ private aaCreateConsentEndpoint = "/v2/consents";
23
+ private fiDataFetchEndpoint = "/v2/sessions";
24
+ private createMultiConsentEndpoint = "/v2/consents/consents/collection";
25
+ private getActiveFipEndpoint = "/v2/fips";
26
+ private kycClientId = "b62ace35-122c-4a18-9b5c-f60b2a6a2f9c";
27
+ private aaClientId = "56be0bb1-bd5b-4c4b-8d4f-95a74575eaf9";
28
+ private kycClientSecret = "UoZYWrl8NVc10XysYLPCY61sD6JQfGxg";
29
+ private aaClientSecret = "u51raAVQoB4mUEcCtdaZVunJu1uMDYiz";
30
+ private pennylessClientId = "3f2c2078-9d7e-45d2-bba5-3e5351f8208f";
31
+ private pennylessClientSecret = "LxDx1puj82rUZXJhzKj0vFVixTraNRVc";
32
+ private okycProductInstanceId = "03e72dac-2d3e-49fa-9f11-6e61146211ea";
33
+ private digiLockerProductInstanceId = "e733678e-ad25-4286-af23-0ef738b564d9";
34
+ private panVerificationProductInstanceId =
35
+ "b0b1114a-c48e-468f-bd6b-982b0e9a8c39";
36
+ private bavPennyDropProductInstanceId =
37
+ "48bb0235-db7b-4217-b802-451dd7c8a5fc";
38
+ private reversePennyDropProductInstanceId =
39
+ "239aa0bf-9652-4106-b4f8-f28a0f8f5ca6";
40
+ private pennylessBavProductInstanceId =
41
+ "a74baf19-de93-4564-8d89-6911fa805385";
42
+ private aaProductInstanceId = "eb20144b-5567-46c2-90f6-e900487e85e6";
43
+
44
+ async panVerification({
45
+ verificationData,
46
+ }: {
47
+ verificationData: PanVerificationBodyType;
48
+ }) {
49
+ try {
50
+ const headers = {
51
+ "x-client-id": this.kycClientId,
52
+ "x-client-secret": this.kycClientSecret,
53
+ "x-product-instance-id": this.panVerificationProductInstanceId,
54
+ "Content-Type": "application/json",
55
+ };
56
+ const verificationJson = {
57
+ pan: verificationData.pan,
58
+ consent: verificationData.consent,
59
+ reason: verificationData.reason,
60
+ };
61
+ const response = await axios.post(
62
+ `${this.baseUrl}${this.panVerificationEndpoint}`,
63
+ verificationJson,
64
+ { headers }
65
+ );
66
+ return response.data;
67
+ } catch (error: any) {
68
+ return error;
69
+ }
70
+ }
71
+
72
+ async createAadhaarKycRequest({ redirectUrl }: { redirectUrl: string }) {
73
+ try {
74
+ const headers = {
75
+ "x-client-id": this.kycClientId,
76
+ "x-client-secret": this.kycClientSecret,
77
+ "x-product-instance-id": this.okycProductInstanceId,
78
+ "Content-Type": "application/json",
79
+ };
80
+ const webhook = {
81
+ redirectURL: redirectUrl,
82
+ };
83
+ const response = await axios.post(
84
+ `${this.baseUrl}${this.createOkycRequestEndpoint}`,
85
+ webhook,
86
+ { headers }
87
+ );
88
+ return response.data;
89
+ } catch (error: any) {
90
+ return error;
91
+ }
92
+ }
93
+
94
+ async getAadhaarKycDetails({
95
+ reqId,
96
+ shareCode,
97
+ }: {
98
+ reqId: string;
99
+ shareCode: string;
100
+ }) {
101
+ try {
102
+ const headers = {
103
+ "x-client-id": this.kycClientId,
104
+ "x-client-secret": this.kycClientSecret,
105
+ "x-product-instance-id": this.okycProductInstanceId,
106
+ };
107
+ const response = await axios.get(
108
+ `${this.baseUrl}${this.createOkycRequestEndpoint}/${reqId}/${shareCode}`,
109
+ { headers }
110
+ );
111
+ return response.data;
112
+ } catch (error: any) {
113
+ return error;
114
+ }
115
+ }
116
+
117
+ async createDigilockerRequest({ redirectUrl }: { redirectUrl: string }) {
118
+ try {
119
+ const headers = {
120
+ "x-client-id": this.kycClientId,
121
+ "x-client-secret": this.kycClientSecret,
122
+ "x-product-instance-id": this.digiLockerProductInstanceId,
123
+ };
124
+ const webhook = {
125
+ redirectUrl: redirectUrl,
126
+ };
127
+ const response = await axios.post(
128
+ `${this.baseUrl}${this.createDigilockerRequestendpoint}`,
129
+ webhook,
130
+ { headers }
131
+ );
132
+ return response.data;
133
+ } catch (error: any) {
134
+ return error;
135
+ }
136
+ }
137
+
138
+ async fetchDigilockerDocument({
139
+ reqId,
140
+ digiData,
141
+ }: {
142
+ reqId: string;
143
+ digiData: DigiData;
144
+ }) {
145
+ try {
146
+ const headers = {
147
+ "x-client-id": this.kycClientId,
148
+ "x-client-secret": this.kycClientSecret,
149
+ "x-product-instance-id": this.digiLockerProductInstanceId,
150
+ "Content-Type": "application/json",
151
+ };
152
+ const jsonData = {
153
+ docType: digiData.docType,
154
+ format: digiData.format,
155
+ consent: digiData.consent,
156
+ };
157
+ const response = await axios.post(
158
+ `${this.baseUrl}/api/digilocker/${reqId}/document`,
159
+ jsonData,
160
+ { headers }
161
+ );
162
+ return response.data;
163
+ } catch (error: any) {
164
+ return error;
165
+ }
166
+ }
167
+
168
+ async getAadhaarXml({ reqId }: { reqId: String }) {
169
+ try {
170
+ const headers = {
171
+ "x-client-id": this.kycClientId,
172
+ "x-client-secret": this.kycClientSecret,
173
+ "x-product-instance-id": this.digiLockerProductInstanceId,
174
+ };
175
+ const response = await axios.get(
176
+ `${this.baseUrl}/api/digilocker/${reqId}/aadhaar`,
177
+ { headers }
178
+ );
179
+ return response.data;
180
+ } catch (error: any) {
181
+ return error;
182
+ }
183
+ }
184
+
185
+ async getListOfDocsAvailable() {
186
+ try {
187
+ const headers = {
188
+ "x-client-id": this.kycClientId,
189
+ "x-client-secret": this.kycClientSecret,
190
+ "x-product-instance-id": this.digiLockerProductInstanceId,
191
+ };
192
+ const response = await axios.get(
193
+ `${this.baseUrl}${this.getListOfAllDocumentEndpoint}`,
194
+ { headers }
195
+ );
196
+ return response.data;
197
+ } catch (error: any) {
198
+ return error;
199
+ }
200
+ }
201
+
202
+ async revokeAccessToken({ reqId }: { reqId: String }) {
203
+ try {
204
+ const headers = {
205
+ "x-client-id": this.kycClientId,
206
+ "x-client-secret": this.kycClientSecret,
207
+ "x-product-instance-id": this.digiLockerProductInstanceId,
208
+ };
209
+ const response = await axios.get(
210
+ `${this.baseUrl}/api/digilocker/${reqId}/revoke`,
211
+ { headers }
212
+ );
213
+ return response.data;
214
+ } catch (error: any) {
215
+ return error;
216
+ }
217
+ }
218
+
219
+ async getApiStatus({ reqId }: { reqId: String }) {
220
+ try {
221
+ const headers = {
222
+ "x-client-id": this.kycClientId,
223
+ "x-client-secret": this.kycClientSecret,
224
+ "x-product-instance-id": this.digiLockerProductInstanceId,
225
+ };
226
+ const response = await axios.get(
227
+ `${this.baseUrl}/api/digilocker/${reqId}/status`,
228
+ { headers }
229
+ );
230
+ return response.data;
231
+ } catch (error: any) {
232
+ return error;
233
+ }
234
+ }
235
+
236
+ async verifyBan({ ifsc, accNo }: { ifsc: string; accNo: DigiData }) {
237
+ try {
238
+ const headers = {
239
+ "x-client-id": this.kycClientId,
240
+ "x-client-secret": this.kycClientSecret,
241
+ "x-product-instance-id": this.bavPennyDropProductInstanceId,
242
+ "Content-Type": "application/json",
243
+ };
244
+ const jsonData = {
245
+ ifsc: ifsc,
246
+ accountNumber: accNo,
247
+ };
248
+ const response = await axios.post(
249
+ `${this.baseUrl}${this.bavVerifyBanEndpoint}`,
250
+ jsonData,
251
+ { headers }
252
+ );
253
+ return response.data;
254
+ } catch (error: any) {
255
+ return error;
256
+ }
257
+ }
258
+
259
+ async verifyBanAsync({
260
+ ifsc,
261
+ accNo,
262
+ narration,
263
+ }: {
264
+ ifsc: string;
265
+ accNo: DigiData;
266
+ narration: string;
267
+ }) {
268
+ try {
269
+ const headers = {
270
+ "x-client-id": this.kycClientId,
271
+ "x-client-secret": this.kycClientSecret,
272
+ "x-product-instance-id": this.bavPennyDropProductInstanceId,
273
+ "Content-Type": "application/json",
274
+ };
275
+ const jsonData = {
276
+ ifsc: ifsc,
277
+ accountNumber: accNo,
278
+ narration: narration,
279
+ };
280
+ const response = await axios.post(
281
+ `${this.baseUrl}${this.bavVerifyBanAsyncEndpoint}`,
282
+ jsonData,
283
+ { headers }
284
+ );
285
+ return response.data;
286
+ } catch (error: any) {
287
+ return error;
288
+ }
289
+ }
290
+
291
+ async getBavRequestDetails({ reqId }: { reqId: String }) {
292
+ try {
293
+ const headers = {
294
+ "x-client-id": this.kycClientId,
295
+ "x-client-secret": this.kycClientSecret,
296
+ "x-product-instance-id": this.digiLockerProductInstanceId,
297
+ };
298
+ const response = await axios.get(
299
+ `${this.baseUrl}/api/verify/ban/async/${reqId}`,
300
+ { headers }
301
+ );
302
+ return response.data;
303
+ } catch (error: any) {
304
+ return error;
305
+ }
306
+ }
307
+
308
+ async createPRD(
309
+ reqId: string,
310
+ { value1, value2 }: { value1?: string; value2?: string } = {}
311
+ ) {
312
+ try {
313
+ const headers = {
314
+ "x-client-id": this.kycClientId,
315
+ "x-client-secret": this.kycClientSecret,
316
+ "x-product-instance-id": this.reversePennyDropProductInstanceId,
317
+ "Content-Type": "application/json",
318
+ };
319
+ const jsonData = {
320
+ additionalData: {
321
+ key1: value1,
322
+ key2: value2,
323
+ },
324
+ };
325
+ const response = await axios.post(
326
+ `${this.baseUrl}${this.reverseBavCreateRpdEndpoint}/${reqId}`,
327
+ jsonData,
328
+ { headers }
329
+ );
330
+ return response.data;
331
+ } catch (error: any) {
332
+ return error;
333
+ }
334
+ }
335
+
336
+ async getReversePennyDetails({ reqId }: { reqId: String }) {
337
+ try {
338
+ const headers = {
339
+ "x-client-id": this.kycClientId,
340
+ "x-client-secret": this.kycClientSecret,
341
+ "x-product-instance-id": this.reversePennyDropProductInstanceId,
342
+ };
343
+ const response = await axios.get(
344
+ `${this.baseUrl}/api/verify/ban/reverse/${reqId}`,
345
+ { headers }
346
+ );
347
+ return response.data;
348
+ } catch (error: any) {
349
+ return error;
350
+ }
351
+ }
352
+
353
+ async pennylessBankAccVerification({
354
+ accountNumber,
355
+ ifsc,
356
+ }: {
357
+ accountNumber: string;
358
+ ifsc: string;
359
+ }) {
360
+ try {
361
+ const headers = {
362
+ "x-client-id": this.pennylessClientId,
363
+ "x-client-secret": this.pennylessClientSecret,
364
+ "x-product-instance-id": this.pennylessBavProductInstanceId,
365
+ "Content-Type": "application/json",
366
+ };
367
+ const jsonData = {
368
+ accountNumber: accountNumber,
369
+ ifsc: ifsc,
370
+ };
371
+ const response = await axios.post(
372
+ `${this.baseUrl}${this.pennylessBavEndpoint}`,
373
+ jsonData,
374
+ {
375
+ headers,
376
+ }
377
+ );
378
+ return response.data;
379
+ } catch (error: any) {
380
+ return error;
381
+ }
382
+ }
383
+
384
+ async createNewConsent({ consentBody }: { consentBody: ConsentBodyType }) {
385
+ try {
386
+ const headers = {
387
+ "x-client-id": this.aaClientId,
388
+ "x-client-secret": this.aaClientSecret,
389
+ "x-product-instance-id": this.aaProductInstanceId,
390
+ "Content-Type": "application/json",
391
+ };
392
+ const response = await axios.post(
393
+ `${this.aaBaseUrl}${this.aaCreateConsentEndpoint}`,
394
+ consentBody,
395
+ {
396
+ headers,
397
+ }
398
+ );
399
+ return response.data;
400
+ } catch (error: any) {
401
+ return error;
402
+ }
403
+ }
404
+
405
+ async getConsent({ id }: { id: String }) {
406
+ try {
407
+ const headers = {
408
+ "x-client-id": this.aaClientId,
409
+ "x-client-secret": this.aaClientSecret,
410
+ "x-product-instance-id": this.aaProductInstanceId,
411
+ };
412
+ const response = await axios.get(`${this.aaBaseUrl}/v2/consents/${id}`, {
413
+ headers,
414
+ });
415
+ return response.data;
416
+ } catch (error: any) {
417
+ return error;
418
+ }
419
+ }
420
+
421
+ async getLastFetchStatus({ id }: { id: String }) {
422
+ try {
423
+ const headers = {
424
+ "x-client-id": this.aaClientId,
425
+ "x-client-secret": this.aaClientSecret,
426
+ "x-product-instance-id": this.aaProductInstanceId,
427
+ };
428
+ const response = await axios.get(
429
+ `${this.aaBaseUrl}/v2/consents/${id}/fetch/status`,
430
+ {
431
+ headers,
432
+ }
433
+ );
434
+ return response.data;
435
+ } catch (error: any) {
436
+ return error;
437
+ }
438
+ }
439
+
440
+ async refreshDataPull({ id }: { id: String }) {
441
+ try {
442
+ const headers = {
443
+ "x-client-id": this.aaClientId,
444
+ "x-client-secret": this.aaClientSecret,
445
+ "x-product-instance-id": this.aaProductInstanceId,
446
+ };
447
+ const response = await axios.get(
448
+ `${this.aaBaseUrl}/v2/sessions/refresh/${id}`,
449
+ {
450
+ headers,
451
+ }
452
+ );
453
+ return response.data;
454
+ } catch (error: any) {
455
+ return error;
456
+ }
457
+ }
458
+
459
+ async createFiDataFetch({ fiDataBody }: { fiDataBody: FiDataFetchBodyType }) {
460
+ try {
461
+ const headers = {
462
+ "x-client-id": this.aaClientId,
463
+ "x-client-secret": this.aaClientSecret,
464
+ "x-product-instance-id": this.aaProductInstanceId,
465
+ "Content-Type": "application/json",
466
+ };
467
+ const response = await axios.post(
468
+ `${this.aaBaseUrl}${this.fiDataFetchEndpoint}`,
469
+ fiDataBody,
470
+ {
471
+ headers,
472
+ }
473
+ );
474
+ return response.data;
475
+ } catch (error: any) {
476
+ return error;
477
+ }
478
+ }
479
+
480
+ async getFiData({ id }: { id: String }) {
481
+ try {
482
+ const headers = {
483
+ "x-client-id": this.aaClientId,
484
+ "x-client-secret": this.aaClientSecret,
485
+ "x-product-instance-id": this.aaProductInstanceId,
486
+ };
487
+ const response = await axios.get(
488
+ `${this.aaBaseUrl}${this.fiDataFetchEndpoint}/${id}`,
489
+ {
490
+ headers,
491
+ }
492
+ );
493
+ return response.data;
494
+ } catch (error: any) {
495
+ return error;
496
+ }
497
+ }
498
+
499
+ async createMultiConsent({
500
+ consentBody,
501
+ }: {
502
+ consentBody: MultiConsentBodyType;
503
+ }) {
504
+ try {
505
+ const headers = {
506
+ "x-client-id": this.aaClientId,
507
+ "x-client-secret": this.aaClientSecret,
508
+ "x-product-instance-id": this.aaProductInstanceId,
509
+ "Content-Type": "application/json",
510
+ };
511
+ const response = await axios.post(
512
+ `${this.aaBaseUrl}${this.createMultiConsentEndpoint}`,
513
+ consentBody,
514
+ {
515
+ headers,
516
+ }
517
+ );
518
+ return response.data;
519
+ } catch (error: any) {
520
+ return error;
521
+ }
522
+ }
523
+
524
+ async createTokenApi({ tokenBody }: { tokenBody: TokenApiBodyType }) {
525
+ try {
526
+ const headers = {
527
+ "x-client-id": this.aaClientId,
528
+ "x-client-secret": this.aaClientSecret,
529
+ "x-product-instance-id": this.aaProductInstanceId,
530
+ "Content-Type": "application/json",
531
+ };
532
+ const response = await axios.post(`${this.aaTokenApiUrl}`, tokenBody, {
533
+ headers,
534
+ });
535
+ return response.data;
536
+ } catch (error: any) {
537
+ return error;
538
+ }
539
+ }
540
+
541
+ async getActiveFipList() {
542
+ try {
543
+ const headers = {
544
+ "x-client-id": this.aaClientId,
545
+ "x-client-secret": this.aaClientSecret,
546
+ "x-product-instance-id": this.aaProductInstanceId,
547
+ };
548
+ const response = await axios.get(
549
+ `${this.aaBaseUrl}${this.getActiveFipEndpoint}`,
550
+ {
551
+ headers,
552
+ }
553
+ );
554
+ return response.data;
555
+ } catch (error: any) {
556
+ return error;
557
+ }
558
+ }
559
+ }
560
+ export default SetuApiWrapper;
@@ -0,0 +1,44 @@
1
+ export interface DigiData {
2
+ docType: string;
3
+ format: string;
4
+ consent: string;
5
+ }
6
+
7
+ export interface ConsentBodyType {
8
+ consentDuration: {
9
+ unit: string;
10
+ value: string;
11
+ };
12
+ vua: string;
13
+ dataRange: {
14
+ from: string;
15
+ to: string;
16
+ };
17
+ context?: string[];
18
+ }
19
+
20
+ export interface FiDataFetchBodyType {
21
+ consentId: string;
22
+ dataRange: {
23
+ from: string;
24
+ to: string;
25
+ };
26
+ format: string;
27
+ }
28
+
29
+ export interface MultiConsentBodyType {
30
+ optionalConsents: string[];
31
+ mandatoryConsents: string[];
32
+ }
33
+
34
+ export interface TokenApiBodyType {
35
+ clientID: string;
36
+ grant_type: string;
37
+ secret: string;
38
+ }
39
+
40
+ export interface PanVerificationBodyType {
41
+ pan: string;
42
+ consent: string;
43
+ reason: string;
44
+ }