ggez-banking-sdk 0.1.106 → 0.1.107

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 (89) hide show
  1. package/dist/api/clients/account.d.ts +8 -8
  2. package/dist/api/clients/account.js +26 -19
  3. package/dist/api/clients/auth.d.ts +22 -17
  4. package/dist/api/clients/auth.js +57 -42
  5. package/dist/api/clients/blockchain.d.ts +16 -16
  6. package/dist/api/clients/blockchain.js +52 -42
  7. package/dist/api/clients/ipAddressAndLocation.js +15 -13
  8. package/dist/api/clients/limited.d.ts +42 -32
  9. package/dist/api/clients/limited.js +100 -82
  10. package/dist/api/clients/order.d.ts +4 -4
  11. package/dist/api/clients/order.js +16 -12
  12. package/dist/api/clients/organization.d.ts +23 -18
  13. package/dist/api/clients/organization.js +57 -45
  14. package/dist/api/clients/promotion.d.ts +28 -13
  15. package/dist/api/clients/promotion.js +32 -30
  16. package/dist/api/clients/transaction.d.ts +9 -9
  17. package/dist/api/clients/transaction.js +30 -24
  18. package/dist/api/clients/user.d.ts +387 -301
  19. package/dist/api/clients/user.js +886 -735
  20. package/dist/api/data/account.d.ts +3 -0
  21. package/dist/api/data/account.js +8 -0
  22. package/dist/api/data/blockchain.d.ts +2 -1
  23. package/dist/api/data/blockchain.js +11 -1
  24. package/dist/api/data/index.d.ts +2 -0
  25. package/dist/api/data/index.js +2 -0
  26. package/dist/api/data/order.d.ts +2 -1
  27. package/dist/api/data/order.js +15 -1
  28. package/dist/api/data/organization.d.ts +2 -1
  29. package/dist/api/data/organization.js +26 -1
  30. package/dist/api/data/result.d.ts +9 -0
  31. package/dist/api/data/result.js +48 -0
  32. package/dist/api/data/transaction.d.ts +4 -2
  33. package/dist/api/data/transaction.js +24 -1
  34. package/dist/api/data/user/confirmUserSecurity.d.ts +3 -0
  35. package/dist/api/data/user/confirmUserSecurity.js +12 -0
  36. package/dist/api/data/user/forgetSecurityData.d.ts +3 -0
  37. package/dist/api/data/user/forgetSecurityData.js +10 -0
  38. package/dist/api/data/user/index.d.ts +8 -8
  39. package/dist/api/data/user/index.js +8 -161
  40. package/dist/api/data/user/user.d.ts +6 -0
  41. package/dist/api/data/user/user.js +159 -0
  42. package/dist/api/data/user/validateLimitedSecurity.d.ts +3 -0
  43. package/dist/api/data/user/validateLimitedSecurity.js +10 -0
  44. package/dist/api/data/user/validateSecurityData.d.ts +3 -0
  45. package/dist/api/data/user/validateSecurityData.js +11 -0
  46. package/dist/api/data/user/verifyUserSecurity.d.ts +3 -0
  47. package/dist/api/data/user/verifyUserSecurity.js +11 -0
  48. package/dist/api/services/account.js +1 -1
  49. package/dist/api/services/auth.js +4 -5
  50. package/dist/api/services/base.d.ts +1 -1
  51. package/dist/api/services/base.js +1 -0
  52. package/dist/api/services/blockchain.js +5 -9
  53. package/dist/api/services/ipAddressAndLocation.js +10 -10
  54. package/dist/api/services/limited.js +2 -1
  55. package/dist/api/services/order.js +2 -3
  56. package/dist/api/services/organization.d.ts +2 -2
  57. package/dist/api/services/organization.js +7 -10
  58. package/dist/api/services/promotion.js +1 -1
  59. package/dist/api/services/transaction.d.ts +2 -2
  60. package/dist/api/services/transaction.js +3 -5
  61. package/dist/api/services/user.js +65 -127
  62. package/dist/constants/structure.d.ts +1 -0
  63. package/dist/constants/structure.js +1 -0
  64. package/dist/helper/api/axiosHelper.js +71 -71
  65. package/dist/helper/api/responseHelper.d.ts +12 -11
  66. package/dist/helper/api/responseHelper.js +24 -25
  67. package/dist/helper/cipherHelper.js +95 -97
  68. package/dist/helper/clientHelper.js +1 -0
  69. package/dist/helper/cookiesHelper.d.ts +5 -0
  70. package/dist/helper/cookiesHelper.js +169 -126
  71. package/dist/helper/deviceHelper.js +31 -31
  72. package/dist/helper/userHelper.d.ts +12 -2
  73. package/dist/helper/userHelper.js +69 -2
  74. package/dist/index.d.ts +1 -1
  75. package/dist/index.js +1 -1
  76. package/dist/tsconfig.tsbuildinfo +1 -1
  77. package/dist/types/banking/common/ResultSet.d.ts +10 -0
  78. package/dist/types/banking/common/ResultSet.js +1 -0
  79. package/dist/types/banking/common/index.d.ts +1 -0
  80. package/dist/types/banking/entities/address.d.ts +1 -0
  81. package/dist/types/banking/oauth/tokenData.d.ts +3 -1
  82. package/dist/types/banking/transaction/index.d.ts +1 -0
  83. package/dist/types/banking/transaction/transactionResultInquiry.d.ts +9 -0
  84. package/dist/types/banking/transaction/transactionResultInquiry.js +1 -0
  85. package/dist/types/helper/index.d.ts +4 -3
  86. package/dist/types/helper/index.js +1 -3
  87. package/dist/types/helper/userHelper.d.ts +17 -0
  88. package/dist/types/helper/userHelper.js +2 -0
  89. package/package.json +2 -2
@@ -3,9 +3,10 @@ import { BaseService } from "./base";
3
3
  import { IPAddressAndLocationService } from "./ipAddressAndLocation";
4
4
  import { AxiosHelper, GeoHelper } from "../../helper";
5
5
  class UserService extends BaseService {
6
+ url;
7
+ endpoint = Endpoints.User;
6
8
  constructor(config) {
7
9
  super(config);
8
- this.endpoint = Endpoints.User;
9
10
  this.axiosInstance.interceptors.request.use(async (req) => {
10
11
  const locationService = new IPAddressAndLocationService(config);
11
12
  const geoCoordinates = await GeoHelper.GetGeoCoordinates(locationService);
@@ -16,326 +17,263 @@ class UserService extends BaseService {
16
17
  // #region "GET"
17
18
  async getUser(userId, token) {
18
19
  const url = this.resolveURL(`/${userId}`);
19
- const response = await this.GET(url, undefined, {
20
+ return this.GET(url, undefined, {
20
21
  headers: { Authorization: `Bearer ${token}` },
21
22
  });
22
- return response;
23
23
  }
24
24
  async getTermsAndConditions(userId) {
25
25
  const url = this.resolveURL(`${UserEndpoints.TermsAndConditions}/${userId}`);
26
- const response = await this.GET(url);
27
- return response;
26
+ return this.GET(url);
28
27
  }
29
28
  async getSecurity(userId) {
30
29
  const url = this.resolveURL(`${UserEndpoints.Security}/${userId}`);
31
- const response = await this.GET(url);
32
- return response;
30
+ return this.GET(url);
33
31
  }
34
32
  async getPhone(userId) {
35
33
  const url = this.resolveURL(`${UserEndpoints.Phone}/${userId}`);
36
- const response = await this.GET(url);
37
- return response;
34
+ return this.GET(url);
38
35
  }
39
36
  async getPreferences(userId) {
40
37
  const url = this.resolveURL(`${UserEndpoints.Preferences}/${userId}`);
41
- const response = await this.GET(url);
42
- return response;
38
+ return this.GET(url);
43
39
  }
44
40
  async getPersonalInfo(userId) {
45
41
  const url = this.resolveURL(`${UserEndpoints.PersonalInfo}/${userId}`);
46
- const response = await this.GET(url);
47
- return response;
42
+ return this.GET(url);
48
43
  }
49
44
  async getLatestHistory(userId) {
50
45
  const url = this.resolveURL(`${UserEndpoints.HistoryLatest}/${userId}`);
51
- const response = await this.GET(url);
52
- return response;
46
+ return this.GET(url);
53
47
  }
54
48
  async getIdentification(userId) {
55
49
  const url = this.resolveURL(`${UserEndpoints.Identification}/${userId}`);
56
- const response = await this.GET(url);
57
- return response;
50
+ return this.GET(url);
58
51
  }
59
52
  async getHistory(userId) {
60
53
  const url = this.resolveURL(`${UserEndpoints.HistoryLatest}/${userId}`);
61
- const response = await this.GET(url);
62
- return response;
54
+ return this.GET(url);
63
55
  }
64
56
  async getGroup(userId) {
65
57
  const url = this.resolveURL(`${UserEndpoints.Group}/${userId}`);
66
- const response = await this.GET(url);
67
- return response;
58
+ return this.GET(url);
68
59
  }
69
60
  async getExternalAuth(userId) {
70
61
  const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${userId}`);
71
- const response = await this.GET(url);
72
- return response;
62
+ return this.GET(url);
73
63
  }
74
64
  async getEmail(userId) {
75
65
  const url = this.resolveURL(`${UserEndpoints.Email}/${userId}`);
76
- const response = await this.GET(url);
77
- return response;
66
+ return this.GET(url);
78
67
  }
79
68
  async getDocuments(userId) {
80
69
  const url = this.resolveURL(`${UserEndpoints.Documents}/${userId}`);
81
- const response = await this.GET(url);
82
- return response;
70
+ return this.GET(url);
83
71
  }
84
72
  async getCurrency(userId) {
85
73
  const url = this.resolveURL(`${UserEndpoints.Currency}/${userId}`);
86
- const response = await this.GET(url);
87
- return response;
74
+ return this.GET(url);
88
75
  }
89
76
  async getCreditCard(userId) {
90
77
  const url = this.resolveURL(`${UserEndpoints.CreditCard}/${userId}`);
91
- const response = await this.GET(url);
92
- return response;
78
+ return this.GET(url);
93
79
  }
94
80
  async getBankAccount(userId) {
95
81
  const url = this.resolveURL(`${UserEndpoints.BankAccount}/${userId}`);
96
- const response = await this.GET(url);
97
- return response;
82
+ return this.GET(url);
98
83
  }
99
84
  async getAddress(userId) {
100
85
  const url = this.resolveURL(`${UserEndpoints.Address}/${userId}`);
101
- const response = await this.GET(url);
102
- return response;
86
+ return this.GET(url);
103
87
  }
104
88
  async getAccount(userId) {
105
89
  const url = this.resolveURL(`${UserEndpoints.Account}/${userId}`);
106
- const response = await this.GET(url);
107
- return response;
90
+ return this.GET(url);
108
91
  }
109
92
  async getDeviceHistory(userId) {
110
93
  const url = this.resolveURL(`${UserEndpoints.DeviceHistory}/${userId}`);
111
- const response = await this.GET(url);
112
- return response;
94
+ return this.GET(url);
113
95
  }
114
96
  async getActivity(userId) {
115
97
  const url = this.resolveURL(`${UserEndpoints.Activity}/${userId}`);
116
- const response = await this.GET(url);
117
- return response;
98
+ return this.GET(url);
118
99
  }
119
100
  // #endregion
120
101
  // #region "POST"
121
102
  async createUser(payload, config) {
122
103
  const url = this.resolveURL();
123
- const response = await this.POST(url, payload, config);
124
- return response;
104
+ return this.POST(url, payload, config);
125
105
  }
126
106
  async createPhone(userId, payload) {
127
107
  const url = this.resolveURL(`${UserEndpoints.Phone}/${userId}`);
128
- const response = await this.POST(url, payload);
129
- return response;
108
+ return this.POST(url, payload);
130
109
  }
131
110
  async createDevice(userId, payload) {
132
111
  const url = this.resolveURL(`${UserEndpoints.Device}/${userId}`);
133
- const response = await this.POST(url, payload);
134
- return response;
112
+ return this.POST(url, payload);
135
113
  }
136
114
  async createIdentification(userId, payload) {
137
115
  const url = this.resolveURL(`${UserEndpoints.Identification}/${userId}`);
138
- const response = await this.POST(url, payload);
139
- return response;
116
+ return this.POST(url, payload);
140
117
  }
141
118
  async createExternalAuth(userId, payload) {
142
119
  const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${userId}`);
143
- const response = await this.POST(url, payload);
144
- return response;
120
+ return this.POST(url, payload);
145
121
  }
146
122
  async createEmail(userId, payload) {
147
123
  const url = this.resolveURL(`${UserEndpoints.Email}/${userId}`);
148
- const response = await this.POST(url, payload);
149
- return response;
124
+ return this.POST(url, payload);
150
125
  }
151
126
  async createCurrency(userId, payload) {
152
127
  const url = this.resolveURL(`${UserEndpoints.Currency}/${userId}`);
153
- const response = await this.POST(url, payload);
154
- return response;
128
+ return this.POST(url, payload);
155
129
  }
156
130
  async createCreditCard(userId, payload) {
157
131
  const url = this.resolveURL(`${UserEndpoints.CreditCard}/${userId}`);
158
- const response = await this.POST(url, payload);
159
- return response;
132
+ return this.POST(url, payload);
160
133
  }
161
134
  async createBankAccount(userId, payload) {
162
135
  const url = this.resolveURL(`${UserEndpoints.BankAccount}/${userId}`);
163
- const response = await this.POST(url, payload);
164
- return response;
136
+ return this.POST(url, payload);
165
137
  }
166
138
  async createAddress(userId, payload) {
167
139
  const url = this.resolveURL(`${UserEndpoints.Address}/${userId}`);
168
- const response = await this.POST(url, payload);
169
- return response;
140
+ return this.POST(url, payload);
170
141
  }
171
142
  async createTicket(userId, payload) {
172
143
  const url = this.resolveURL(`${UserEndpoints.Ticket}/${userId}`);
173
- const response = await this.POST(url, payload);
174
- return response;
144
+ return this.POST(url, payload);
175
145
  }
176
146
  async securityAccess(userId, payload) {
177
147
  const url = this.resolveURL(`${UserEndpoints.SecurityAccess}/${userId}`);
178
- const response = await this.POST(url, payload);
179
- return response;
148
+ return this.POST(url, payload);
180
149
  }
181
150
  async uploadDocument(userId, payload) {
182
151
  const url = this.resolveURL(`${UserEndpoints.Document}/${userId}`);
183
- const response = await this.POST(url, payload);
184
- return response;
152
+ return this.POST(url, payload);
185
153
  }
186
154
  async confirmSecurityData(userId, payload) {
187
155
  const url = this.resolveURL(`${UserEndpoints.SecurityConfirm}/${userId}`);
188
- const response = await this.POST(url, payload);
189
- return response;
156
+ return this.POST(url, payload);
190
157
  }
191
158
  async validateSecurityData(userId, payload) {
192
159
  const url = this.resolveURL(`${UserEndpoints.SecurityValidate}/${userId}`);
193
- const response = await this.POST(url, payload);
194
- return response;
160
+ return this.POST(url, payload);
195
161
  }
196
162
  async verifySecurityData(userId, payload) {
197
163
  const url = this.resolveURL(`${UserEndpoints.SecurityVerify}/${userId}`);
198
- const response = await this.POST(url, payload);
199
- return response;
164
+ return this.POST(url, payload);
200
165
  }
201
166
  async resetSecurityData(userId, payload) {
202
167
  const url = this.resolveURL(`${UserEndpoints.SecurityReset}/${userId}`);
203
- const response = await this.POST(url, payload);
204
- return response;
168
+ return this.POST(url, payload);
205
169
  }
206
170
  async enrollGoogleAuth(userId, payload) {
207
171
  const url = this.resolveURL(`${UserEndpoints.AuthEnroll}/${userId}`);
208
- const response = await this.POST(url, payload);
209
- return response;
172
+ return this.POST(url, payload);
210
173
  }
211
174
  async activateGoogleAuth(userId, payload) {
212
175
  const url = this.resolveURL(`${UserEndpoints.AuthActivate}/${userId}`);
213
- const response = await this.POST(url, payload);
214
- return response;
176
+ return this.POST(url, payload);
215
177
  }
216
178
  async deactivateGoogleAuth(userId, payload) {
217
179
  const url = this.resolveURL(`${UserEndpoints.AuthDeactivate}/${userId}`);
218
- const response = await this.POST(url, payload);
219
- return response;
180
+ return this.POST(url, payload);
220
181
  }
221
182
  async deleteGoogleAuth(userId, payload) {
222
183
  const url = this.resolveURL(`${UserEndpoints.AuthDelete}/${userId}`);
223
- const response = await this.POST(url, payload);
224
- return response;
184
+ return this.POST(url, payload);
225
185
  }
226
186
  // #endregion
227
187
  // #region "PUT"
228
188
  async updateUser(userId, payload) {
229
189
  const url = this.resolveURL(`/${userId}`);
230
- const response = await this.PUT(url, payload);
231
- return response;
190
+ return this.PUT(url, payload);
232
191
  }
233
192
  async updateSecurity(userId, payload) {
234
193
  const url = this.resolveURL(`${UserEndpoints.Security}/${userId}`);
235
- const response = await this.PUT(url, payload);
236
- return response;
194
+ return this.PUT(url, payload);
237
195
  }
238
196
  async updatePreferences(userId, payload) {
239
197
  const url = this.resolveURL(`${UserEndpoints.Preferences}/${userId}`);
240
- const response = await this.PUT(url, payload);
241
- return response;
198
+ return this.PUT(url, payload);
242
199
  }
243
200
  async updateDevice(userId, payload) {
244
201
  const url = this.resolveURL(`${UserEndpoints.Device}/${userId}`);
245
- const response = await this.PUT(url, payload);
246
- return response;
202
+ return this.PUT(url, payload);
247
203
  }
248
204
  async logoutDevice(userId, payload) {
249
205
  const url = this.resolveURL(`${UserEndpoints.DeviceLogout}/${userId}`);
250
- const response = await this.PUT(url, payload);
251
- return response;
206
+ return this.PUT(url, payload);
252
207
  }
253
208
  async updatePhone(userId, payload) {
254
209
  const url = this.resolveURL(`${UserEndpoints.Phone}/${userId}`);
255
- const response = await this.PUT(url, payload);
256
- return response;
210
+ return this.PUT(url, payload);
257
211
  }
258
212
  async updatePersonalInfo(userId, payload) {
259
213
  const url = this.resolveURL(`${UserEndpoints.PersonalInfo}/${userId}`);
260
- const response = await this.PUT(url, payload);
261
- return response;
214
+ return this.PUT(url, payload);
262
215
  }
263
216
  async updateIdentification(userId, payload) {
264
217
  const url = this.resolveURL(`${UserEndpoints.Identification}/${userId}`);
265
- const response = await this.PUT(url, payload);
266
- return response;
218
+ return this.PUT(url, payload);
267
219
  }
268
220
  async updateExternalAuth(userId, payload) {
269
221
  const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${userId}`);
270
- const response = await this.PUT(url, payload);
271
- return response;
222
+ return this.PUT(url, payload);
272
223
  }
273
224
  async updateEmail(userId, payload) {
274
225
  const url = this.resolveURL(`${UserEndpoints.Email}/${userId}`);
275
- const response = await this.PUT(url, payload);
276
- return response;
226
+ return this.PUT(url, payload);
277
227
  }
278
228
  async updateCreditCard(userId, payload) {
279
229
  const url = this.resolveURL(`${UserEndpoints.CreditCard}/${userId}`);
280
- const response = await this.PUT(url, payload);
281
- return response;
230
+ return this.PUT(url, payload);
282
231
  }
283
232
  async updateBankAccount(userId, payload) {
284
233
  const url = this.resolveURL(`${UserEndpoints.BankAccount}/${userId}`);
285
- const response = await this.PUT(url, payload);
286
- return response;
234
+ return this.PUT(url, payload);
287
235
  }
288
236
  async updateAddress(userId, payload) {
289
237
  const url = this.resolveURL(`${UserEndpoints.Address}/${userId}`);
290
- const response = await this.PUT(url, payload);
291
- return response;
238
+ return this.PUT(url, payload);
292
239
  }
293
240
  // #endregion
294
241
  // #region "DELETE"
295
242
  async deleteUser(userId) {
296
243
  const url = this.resolveURL(`/${userId}`);
297
- const response = await this.DELETE(url);
298
- return response;
244
+ return this.DELETE(url);
299
245
  }
300
246
  async deleteCreditCard(userId) {
301
247
  const url = this.resolveURL(`${UserEndpoints.CreditCard}/${userId}`);
302
- const response = await this.DELETE(url);
303
- return response;
248
+ return this.DELETE(url);
304
249
  }
305
250
  async deleteAddress(userId, payload) {
306
251
  const url = this.resolveURL(`${UserEndpoints.Address}/${userId}`);
307
- const response = await this.DELETE(url, payload);
308
- return response;
252
+ return this.DELETE(url, payload);
309
253
  }
310
254
  async deleteDevice(userId, payload) {
311
255
  const url = this.resolveURL(`${UserEndpoints.Device}/${userId}`);
312
- const response = await this.DELETE(url, payload);
313
- return response;
256
+ return this.DELETE(url, payload);
314
257
  }
315
258
  async deleteBankAccount(userId, payload) {
316
259
  const url = this.resolveURL(`${UserEndpoints.BankAccount}/${userId}`);
317
- const response = await this.DELETE(url, payload);
318
- return response;
260
+ return this.DELETE(url, payload);
319
261
  }
320
262
  async deleteIdentification(userId, payload) {
321
263
  const url = this.resolveURL(`${UserEndpoints.Identification}/${userId}`);
322
- const response = await this.DELETE(url, payload);
323
- return response;
264
+ return this.DELETE(url, payload);
324
265
  }
325
266
  async deleteEmail(userId, payload) {
326
267
  const url = this.resolveURL(`${UserEndpoints.Email}/${userId}`);
327
- const response = await this.DELETE(url, payload);
328
- return response;
268
+ return this.DELETE(url, payload);
329
269
  }
330
270
  async deletePhone(userId, payload) {
331
271
  const url = this.resolveURL(`${UserEndpoints.Phone}/${userId}`);
332
- const response = await this.DELETE(url, payload);
333
- return response;
272
+ return this.DELETE(url, payload);
334
273
  }
335
274
  async deleteExternalAuth(userId) {
336
275
  const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${userId}`);
337
- const response = await this.DELETE(url);
338
- return response;
276
+ return this.DELETE(url);
339
277
  }
340
278
  }
341
279
  export { UserService };
@@ -75,5 +75,6 @@ declare const SystemResponses: {
75
75
  readonly Invalid_Token: "5025";
76
76
  readonly Token_Is_Not_Active: "5035";
77
77
  readonly Invalid_Authentication_Code: "6049";
78
+ readonly Internal_Server_Error: "7001";
78
79
  };
79
80
  export { BlockchainActions, StructTicketMessageDescriptionCodes, SystemResponses, };
@@ -75,5 +75,6 @@ const SystemResponses = {
75
75
  Invalid_Token: "5025",
76
76
  Token_Is_Not_Active: "5035",
77
77
  Invalid_Authentication_Code: "6049",
78
+ Internal_Server_Error: "7001",
78
79
  };
79
80
  export { BlockchainActions, StructTicketMessageDescriptionCodes, SystemResponses, };
@@ -2,80 +2,80 @@ import { HeaderKeys } from "../../constants";
2
2
  import { GenerateSourceID } from "../../utils";
3
3
  import { DateTimeHelper } from "../dateTimeHelper";
4
4
  class AxiosHelper {
5
- }
6
- AxiosHelper.GetAxiosConfig = (token, baseURL, lang, installationId) => {
7
- const config = {
8
- headers: {
9
- [HeaderKeys.ContentType]: "application/json",
10
- [HeaderKeys.Language]: lang,
11
- [HeaderKeys.InstallationID]: installationId,
12
- [HeaderKeys.ShowSensitiveData]: "1",
13
- [HeaderKeys.ShowCustomField]: "1",
14
- [HeaderKeys.ShowTicket]: "1",
15
- [HeaderKeys.GenerateJwt]: "true",
16
- },
17
- baseURL: baseURL,
18
- withCredentials: true,
5
+ static GetAxiosConfig = (token, baseURL, lang, installationId) => {
6
+ const config = {
7
+ headers: {
8
+ [HeaderKeys.ContentType]: "application/json",
9
+ [HeaderKeys.Language]: lang,
10
+ [HeaderKeys.InstallationID]: installationId,
11
+ [HeaderKeys.ShowSensitiveData]: "1",
12
+ [HeaderKeys.ShowCustomField]: "1",
13
+ [HeaderKeys.ShowTicket]: "1",
14
+ [HeaderKeys.GenerateJwt]: "true",
15
+ },
16
+ baseURL: baseURL,
17
+ withCredentials: true,
18
+ };
19
+ if (token) {
20
+ config.headers.Authorization = `Bearer ${token}`;
21
+ }
22
+ return config;
19
23
  };
20
- if (token) {
21
- config.headers.Authorization = `Bearer ${token}`;
22
- }
23
- return config;
24
- };
25
- AxiosHelper.GetAuthAxiosConfig = (baseURL, lang, installationId) => {
26
- const config = {
27
- headers: {
28
- [HeaderKeys.ContentType]: "application/x-www-form-urlencoded",
29
- [HeaderKeys.Language]: lang,
30
- [HeaderKeys.InstallationID]: installationId,
31
- [HeaderKeys.ShowSensitiveData]: "1",
32
- [HeaderKeys.ShowCustomField]: "1",
33
- [HeaderKeys.ShowTicket]: "1",
34
- [HeaderKeys.GenerateJwt]: "true",
35
- },
36
- baseURL: baseURL,
37
- withCredentials: true,
24
+ static GetAuthAxiosConfig = (baseURL, lang, installationId) => {
25
+ const config = {
26
+ headers: {
27
+ [HeaderKeys.ContentType]: "application/x-www-form-urlencoded",
28
+ [HeaderKeys.Language]: lang,
29
+ [HeaderKeys.InstallationID]: installationId,
30
+ [HeaderKeys.ShowSensitiveData]: "1",
31
+ [HeaderKeys.ShowCustomField]: "1",
32
+ [HeaderKeys.ShowTicket]: "1",
33
+ [HeaderKeys.GenerateJwt]: "true",
34
+ },
35
+ baseURL: baseURL,
36
+ withCredentials: true,
37
+ };
38
+ return config;
38
39
  };
39
- return config;
40
- };
41
- AxiosHelper.AddAxiosConfigHeader = (config, key, value) => {
42
- if (!config.headers)
43
- config.headers = {};
44
- config.headers[key] = value;
45
- };
46
- AxiosHelper.InjectRequiredHeaders = (req) => {
47
- req.headers.set(HeaderKeys.SourceID, GenerateSourceID());
48
- req.headers.set(HeaderKeys.TimeZone, DateTimeHelper.GetClientTimeZone());
49
- return req;
50
- };
51
- AxiosHelper.InjectBaseBodyProperties = (req) => {
52
- try {
53
- if (req.data) {
54
- if (typeof req.data == "string") {
55
- const baseResult = JSON.parse(req.data);
56
- baseResult.time_zone = DateTimeHelper.GetClientTimeZone();
57
- baseResult.time_zone_name = DateTimeHelper.GetClientTimeZoneName();
58
- req.data = JSON.stringify(baseResult);
59
- }
60
- else if (typeof req.data == "object") {
61
- const baseResult = req.data;
62
- baseResult.time_zone = DateTimeHelper.GetClientTimeZone();
63
- baseResult.time_zone_name = DateTimeHelper.GetClientTimeZoneName();
40
+ static AddAxiosConfigHeader = (config, key, value) => {
41
+ if (!config.headers)
42
+ config.headers = {};
43
+ config.headers[key] = value;
44
+ };
45
+ static InjectRequiredHeaders = (req) => {
46
+ req.headers.set(HeaderKeys.SourceID, GenerateSourceID());
47
+ req.headers.set(HeaderKeys.TimeZone, DateTimeHelper.GetClientTimeZone());
48
+ return req;
49
+ };
50
+ static InjectBaseBodyProperties = (req) => {
51
+ try {
52
+ if (req.data) {
53
+ if (typeof req.data == "string") {
54
+ const baseResult = JSON.parse(req.data);
55
+ baseResult.time_zone = DateTimeHelper.GetClientTimeZone();
56
+ baseResult.time_zone_name = DateTimeHelper.GetClientTimeZoneName();
57
+ req.data = JSON.stringify(baseResult);
58
+ }
59
+ else if (typeof req.data == "object") {
60
+ const baseResult = req.data;
61
+ baseResult.time_zone = DateTimeHelper.GetClientTimeZone();
62
+ baseResult.time_zone_name = DateTimeHelper.GetClientTimeZoneName();
63
+ }
64
64
  }
65
65
  }
66
- }
67
- catch (error) {
68
- console.error("Error parsing request data:", error);
69
- }
70
- finally {
66
+ catch (error) {
67
+ console.error("Error parsing request data:", error);
68
+ }
69
+ finally {
70
+ return req;
71
+ }
72
+ };
73
+ static InjectGeoCoordinates = (req, geoCoordinates) => {
74
+ if (req.data && typeof req.data === "object") {
75
+ const data = req.data;
76
+ data.geo_coordinates = geoCoordinates;
77
+ }
71
78
  return req;
72
- }
73
- };
74
- AxiosHelper.InjectGeoCoordinates = (req, geoCoordinates) => {
75
- if (req.data && typeof req.data === "object") {
76
- const data = req.data;
77
- data.geo_coordinates = geoCoordinates;
78
- }
79
- return req;
80
- };
79
+ };
80
+ }
81
81
  export { AxiosHelper };
@@ -1,16 +1,17 @@
1
- import { AxiosResponse } from "axios";
1
+ import { BaseResult, Result } from "../../types";
2
2
  declare class ResponseHelper {
3
- static GetSuccessResponse: (response: AxiosResponse, userInfo: any, key: string, functionName: string, action?: string) => {
4
- response: any;
5
- status: string;
6
- newUser: any;
7
- message: any;
3
+ static GetResponse: <T extends BaseResult>(data: T) => {
4
+ data: T;
5
+ success: boolean;
6
+ message: string;
7
+ error: any;
8
8
  };
9
- static GetErrorResponse: (error: any) => {
10
- response: any;
11
- status: string;
12
- newUser: any;
13
- message: any;
9
+ static GetErrorResponse: <T extends BaseResult>(data: T, functionName: string) => {
10
+ data: T;
11
+ success: boolean;
12
+ message: string;
13
+ error: string;
14
14
  };
15
+ static IsApproved: (result: Result) => boolean;
15
16
  }
16
17
  export { ResponseHelper };
@@ -1,30 +1,29 @@
1
- var _a;
2
- import UserHelper from "../userHelper";
1
+ import { SystemResponses } from "../../constants";
3
2
  class ResponseHelper {
4
- }
5
- _a = ResponseHelper;
6
- ResponseHelper.GetSuccessResponse = (response, userInfo, key, functionName, action) => {
7
- try {
8
- const { checkResponse } = UserHelper(userInfo);
9
- const { checkGlobalResponse } = checkResponse();
10
- const { newUserInfo } = checkGlobalResponse(key, response, functionName, action);
3
+ static GetResponse = (data) => {
4
+ return {
5
+ data: data,
6
+ success: this.IsApproved(data?.result),
7
+ message: data?.result?.message,
8
+ error: null,
9
+ };
10
+ };
11
+ static GetErrorResponse = (data, functionName) => {
12
+ // should log to sentry
11
13
  return {
12
- response: response,
13
- newUser: newUserInfo,
14
- message: response?.data?.result?.message,
15
- status: "success",
14
+ data: data,
15
+ success: false,
16
+ message: data.result.message,
17
+ error: data.result.message,
16
18
  };
17
- }
18
- catch (error) {
19
- return _a.GetErrorResponse(error);
20
- }
21
- };
22
- ResponseHelper.GetErrorResponse = (error) => {
23
- return {
24
- response: error.response,
25
- status: "failed",
26
- newUser: null,
27
- message: error.message,
28
19
  };
29
- };
20
+ static IsApproved = (result) => {
21
+ const { code } = result;
22
+ if (code == SystemResponses.Approved ||
23
+ code == SystemResponses.Create_User_Completed_Partially) {
24
+ return true;
25
+ }
26
+ return false;
27
+ };
28
+ }
30
29
  export { ResponseHelper };