aeremmiddleware 1.0.48 → 1.0.50

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.
@@ -1,15 +1,64 @@
1
1
  import axios, { AxiosResponse } from "axios";
2
2
  import FormData from "form-data";
3
-
3
+
4
+ export interface Address {
5
+ city: string | null;
6
+ country: any;
7
+ full: any;
8
+ line_1: string | null;
9
+ line_2: string | null;
10
+ state: string | null;
11
+ street_name: string | null;
12
+ zip: string | null;
13
+ }
14
+
15
+ export interface SourceOutput {
16
+ aadhaar_linked: any;
17
+ address: Address;
18
+ age: any;
19
+ category: any;
20
+ dob: any;
21
+ dob_check: string | null;
22
+ dob_verified: string | null;
23
+ email: any;
24
+ father_name: string | null;
25
+ full_name: any;
26
+ full_name_split: any;
27
+ gender: any;
28
+ input_dob: string | null;
29
+ is_minor: any;
30
+ less_info: string | null;
31
+ masked_aadhaar: any;
32
+ pan_alloted_date: string | null;
33
+ pan_number: any;
34
+ phone_number: any;
35
+ status: string;
36
+ }
37
+
38
+ export interface Result {
39
+ source_output: SourceOutput;
40
+ }
41
+
42
+ export interface PANInfo {
43
+ action: string;
44
+ completed_at: string;
45
+ created_at: string;
46
+ group_id: string;
47
+ request_id: string;
48
+ result: Result;
49
+ status: string;
50
+ task_id: string;
51
+ type: string;
52
+ }
4
53
  export default class KycCartAPIWrapper {
5
54
  private apiKey: string;
6
55
  private baseUrl: string;
7
-
56
+
8
57
  constructor(apiKey: string) {
9
58
  this.apiKey = apiKey;
10
59
  this.baseUrl = "https://api.kyckart.com/api";
11
60
  }
12
-
61
+
13
62
  public async accountTransfer({
14
63
  accountNumber,
15
64
  ifsc,
@@ -26,7 +75,7 @@ export default class KycCartAPIWrapper {
26
75
  form.append("ifsc", ifsc);
27
76
  form.append("name", name);
28
77
  form.append("checkId", checkId);
29
-
78
+
30
79
  try {
31
80
  const response = await axios.post(
32
81
  `${this.baseUrl}/bank/account-transfer`,
@@ -48,4 +97,170 @@ export default class KycCartAPIWrapper {
48
97
  };
49
98
  }
50
99
  }
51
- }
100
+
101
+ public async getIndividualPANInfo({
102
+ panNo,
103
+ }: {
104
+ panNo: string;
105
+ }): Promise<PANInfo[]> {
106
+ const form = new FormData();
107
+ form.append("panNumber", panNo);
108
+
109
+ try {
110
+ const response = await axios.post(
111
+ `${this.baseUrl}/panCard/panDetailedContactV4`,
112
+ form,
113
+ {
114
+ headers: {
115
+ "x-api-key": this.apiKey,
116
+ ...form.getHeaders(),
117
+ },
118
+ }
119
+ );
120
+ const data = response?.data?.response;
121
+ const panInfo: PANInfo = {
122
+ action: "verify_with_source",
123
+ completed_at: response?.data?.status?.timestamp,
124
+ created_at: response?.data?.status?.timestamp,
125
+ group_id: response?.data?.status?.transactionId,
126
+ request_id: response?.data?.status?.transactionId,
127
+ result: {
128
+ source_output: {
129
+ aadhaar_linked: data.aadhaarSeedingStatus ?? false,
130
+ address: {
131
+ city: data?.city || null,
132
+ country: data?.country || "India",
133
+ full: data?.country || "India",
134
+ line_1: data?.address || null,
135
+ line_2: data?.address || null,
136
+ state: data?.state || null,
137
+ street_name: null,
138
+ zip: data?.pincode || null,
139
+ },
140
+ age: 30,
141
+ category: data?.typeOfHolder || "person",
142
+ dob: data?.dob || "",
143
+ dob_check: null,
144
+ dob_verified: null,
145
+ email: data?.email || "",
146
+ father_name: data?.middleName || null,
147
+ full_name: data?.name || "",
148
+ full_name_split: [
149
+ data?.firstName,
150
+ data?.middleName,
151
+ data?.lastName,
152
+ ],
153
+ gender: data?.gender || "M",
154
+ input_dob: null,
155
+ is_minor: false,
156
+ less_info: null,
157
+ masked_aadhaar: data?.maskedAadhaar || "XXXXXXXXXXXX",
158
+ pan_alloted_date: null,
159
+ pan_number: data?.pan_number || "",
160
+ phone_number: "",
161
+ status: "id_found",
162
+ },
163
+ },
164
+ status: "completed",
165
+ task_id: response?.data?.status?.transactionId,
166
+ type: "ind_pan_plus",
167
+ };
168
+
169
+ const errorPAN = {
170
+ action: "verify_with_source",
171
+ completed_at: response?.data?.status?.timestamp,
172
+ created_at: response?.data?.status?.timestamp,
173
+ group_id: response?.data?.status?.transactionId,
174
+ request_id: response?.data?.status?.transactionId,
175
+ result: {
176
+ source_output: {
177
+ aadhaar_linked: null,
178
+ address: {
179
+ city: null,
180
+ country: null,
181
+ full: null,
182
+ line_1: null,
183
+ line_2: null,
184
+ state: null,
185
+ street_name: null,
186
+ zip: null,
187
+ },
188
+ age: null,
189
+ category: null,
190
+ dob: null,
191
+ dob_check: null,
192
+ dob_verified: null,
193
+ email: null,
194
+ father_name: null,
195
+ full_name: null,
196
+ full_name_split: null,
197
+ gender: null,
198
+ input_dob: null,
199
+ is_minor: null,
200
+ less_info: null,
201
+ masked_aadhaar: null,
202
+ pan_alloted_date: null,
203
+ pan_number: null,
204
+ phone_number: null,
205
+ status: "id_not_found",
206
+ },
207
+ },
208
+ status: "completed",
209
+ task_id: response?.data?.status?.transactionId,
210
+ type: "ind_pan_plus",
211
+ };
212
+
213
+ if (response?.data?.response?.code == 200) {
214
+ return [panInfo];
215
+ } else {
216
+ return [errorPAN];
217
+ }
218
+ } catch (error: any) {
219
+ return [
220
+ {
221
+ action: "verify_with_source",
222
+ completed_at: error?.data?.status?.timestamp,
223
+ created_at: error?.data?.status?.timestamp,
224
+ group_id: error?.data?.status?.transactionId,
225
+ request_id: error?.data?.status?.transactionId,
226
+ result: {
227
+ source_output: {
228
+ aadhaar_linked: null,
229
+ address: {
230
+ city: null,
231
+ country: null,
232
+ full: null,
233
+ line_1: null,
234
+ line_2: null,
235
+ state: null,
236
+ street_name: null,
237
+ zip: null,
238
+ },
239
+ age: null,
240
+ category: null,
241
+ dob: null,
242
+ dob_check: null,
243
+ dob_verified: null,
244
+ email: null,
245
+ father_name: null,
246
+ full_name: null,
247
+ full_name_split: null,
248
+ gender: null,
249
+ input_dob: null,
250
+ is_minor: null,
251
+ less_info: null,
252
+ masked_aadhaar: null,
253
+ pan_alloted_date: null,
254
+ pan_number: null,
255
+ phone_number: null,
256
+ status: "id_not_found",
257
+ },
258
+ },
259
+ status: "failed",
260
+ task_id: "null",
261
+ type: "ind_pan_plus",
262
+ },
263
+ ];
264
+ }
265
+ }
266
+ }
@@ -0,0 +1,45 @@
1
+ export const convertToCamelCase = (value: string | any): any => {
2
+ let res = value;
3
+ if (value === null) return null;
4
+ if (typeof value === "object") {
5
+ if (Array.isArray(value)) {
6
+ let arr: any = [];
7
+ for (let item of value) {
8
+ const convertedObject = convertToCamelCase(item);
9
+ arr.push(convertedObject);
10
+ }
11
+ res = arr;
12
+ } else if (Object.keys(value).length > 0) {
13
+ let convertedRes = {};
14
+ for (let item of Object.keys(value)) {
15
+ const updatedKey = item
16
+ .toLowerCase()
17
+ .replace(/([-_][a-z0-9])/g, (group) =>
18
+ group.toUpperCase().replace("-", "").replace("_", "")
19
+ );
20
+ //check to not convert primitive value of key to camelCase
21
+ if (typeof value[item] === "object") {
22
+ const convertedObject = convertToCamelCase(value[item]);
23
+ convertedRes = {
24
+ ...convertedRes,
25
+ [updatedKey]: convertedObject,
26
+ };
27
+ } else {
28
+ convertedRes = {
29
+ ...convertedRes,
30
+ [updatedKey]: value[item],
31
+ };
32
+ }
33
+ }
34
+ res = convertedRes;
35
+ }
36
+ } else if (typeof value === "string") {
37
+ return value
38
+ .toLowerCase()
39
+ .replace(/([-_][a-z0-9])/g, (group) =>
40
+ group.toUpperCase().replace("-", "").replace("_", "")
41
+ );
42
+ }
43
+
44
+ return res;
45
+ };