@traxionpay/cbsmiddleware 0.0.1 → 0.0.3

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.
@@ -10,7 +10,7 @@ export declare class AccountTransferDto {
10
10
  destinationAccountType?: string;
11
11
  amount?: number;
12
12
  particulars?: string;
13
- mobile?: number;
13
+ mobile?: string;
14
14
  fullName?: string;
15
15
  birthDate?: string;
16
16
  }
@@ -85,8 +85,8 @@ __decorate([
85
85
  ], AccountTransferDto.prototype, "particulars", void 0);
86
86
  __decorate([
87
87
  (0, class_validator_1.IsOptional)(),
88
- (0, class_validator_1.IsNumber)(),
89
- __metadata("design:type", Number)
88
+ (0, class_validator_1.IsString)(),
89
+ __metadata("design:type", String)
90
90
  ], AccountTransferDto.prototype, "mobile", void 0);
91
91
  __decorate([
92
92
  (0, class_validator_1.IsOptional)(),
@@ -4,7 +4,7 @@ export declare class AccountDto {
4
4
  account?: string;
5
5
  branch?: string;
6
6
  accountType?: string;
7
- mobile?: number;
7
+ mobile?: string;
8
8
  fullName?: string;
9
9
  birthDate?: string;
10
10
  }
@@ -49,8 +49,8 @@ __decorate([
49
49
  ], AccountDto.prototype, "accountType", void 0);
50
50
  __decorate([
51
51
  (0, class_validator_1.IsOptional)(),
52
- (0, class_validator_1.IsNumber)(),
53
- __metadata("design:type", Number)
52
+ (0, class_validator_1.IsString)(),
53
+ __metadata("design:type", String)
54
54
  ], AccountDto.prototype, "mobile", void 0);
55
55
  __decorate([
56
56
  (0, class_validator_1.IsOptional)(),
@@ -5,7 +5,7 @@ export declare class FetchBankBalanceDto {
5
5
  account?: string;
6
6
  branch?: string;
7
7
  accountType?: string;
8
- mobile?: number;
8
+ mobile?: string;
9
9
  fullName?: string;
10
10
  birthDate?: string;
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-bank-balance.dto.d.ts","sourceRoot":"","sources":["../../../src/banking/dto/fetch-bank-balance.dto.ts"],"names":[],"mappings":"AAOA,qBAAa,mBAAmB;IAI5B,MAAM,EAAE,MAAM,CAAA;IAId,KAAK,CAAC,EAAE,MAAM,CAAA;IAId,aAAa,CAAC,EAAE,MAAM,CAAA;IAItB,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,MAAM,CAAC,EAAE,MAAM,CAAA;IAIf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAIlB,SAAS,CAAC,EAAE,MAAM,CAAC;CAEtB"}
1
+ {"version":3,"file":"fetch-bank-balance.dto.d.ts","sourceRoot":"","sources":["../../../src/banking/dto/fetch-bank-balance.dto.ts"],"names":[],"mappings":"AAQA,qBAAa,mBAAmB;IAI5B,MAAM,EAAE,MAAM,CAAA;IAId,KAAK,CAAC,EAAE,MAAM,CAAA;IAId,aAAa,CAAC,EAAE,MAAM,CAAA;IAItB,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,MAAM,CAAC,EAAE,MAAM,CAAA;IAIf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAIlB,SAAS,CAAC,EAAE,MAAM,CAAC;CAEtB"}
@@ -55,8 +55,8 @@ __decorate([
55
55
  ], FetchBankBalanceDto.prototype, "accountType", void 0);
56
56
  __decorate([
57
57
  (0, class_validator_1.IsOptional)(),
58
- (0, class_validator_1.IsNumber)(),
59
- __metadata("design:type", Number)
58
+ (0, class_validator_1.IsString)(),
59
+ __metadata("design:type", String)
60
60
  ], FetchBankBalanceDto.prototype, "mobile", void 0);
61
61
  __decorate([
62
62
  (0, class_validator_1.IsOptional)(),
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-bank-balance.dto.js","sourceRoot":"","sources":["../../../src/banking/dto/fetch-bank-balance.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAKyB;AAEzB,MAA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IAAA,0BAAQ,GAAE;;kDACG;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;0DACW;AAItB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACM;AAIjB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACK;AAIhB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;wDACU;AAIrB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACI;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACO;AAIlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;sDACQ"}
@@ -8,7 +8,7 @@ export declare class TransactionHistoryDto {
8
8
  dateFrom?: string;
9
9
  dateTo?: string;
10
10
  page?: number;
11
- mobile?: number;
11
+ mobile?: string;
12
12
  fullName?: string;
13
13
  birthDate?: string;
14
14
  }
@@ -73,8 +73,8 @@ __decorate([
73
73
  ], TransactionHistoryDto.prototype, "page", void 0);
74
74
  __decorate([
75
75
  (0, class_validator_1.IsOptional)(),
76
- (0, class_validator_1.IsNumber)(),
77
- __metadata("design:type", Number)
76
+ (0, class_validator_1.IsString)(),
77
+ __metadata("design:type", String)
78
78
  ], TransactionHistoryDto.prototype, "mobile", void 0);
79
79
  __decorate([
80
80
  (0, class_validator_1.IsOptional)(),
@@ -9,6 +9,7 @@ export declare class ASPACService implements BankService {
9
9
  private readonly config;
10
10
  private readonly logger;
11
11
  constructor(config: BankingConfig, logger: Logger);
12
+ combineDateTime(date: string, time: string): string;
12
13
  generateToken(): Promise<any>;
13
14
  refreshToken(refreshToken: string): Promise<any>;
14
15
  linkAccount(accountDto: AccountDto): Promise<any>;
@@ -16,7 +17,13 @@ export declare class ASPACService implements BankService {
16
17
  processBalanceTransaction(fetchBalanceDto: FetchBankBalanceDto): Promise<any>;
17
18
  accountCashIn(accountTransferDto: AccountTransferDto): Promise<any>;
18
19
  accountDeposit(accountTransferDto: AccountTransferDto): Promise<any>;
19
- getTransactionHistory(transactionHistoryDto: TransactionHistoryDto): Promise<any>;
20
+ getTransactionHistory(transactionHistoryDto: TransactionHistoryDto): Promise<{
21
+ success: boolean;
22
+ message: any;
23
+ correlationId: any;
24
+ timestamp: any;
25
+ transactions: any;
26
+ }>;
20
27
  findAccountDetailsRaw(token: string, userid: number): Promise<string>;
21
28
  accountTransfer(token: string, useridFrom: string, useridTo: string, amount: number): Promise<string>;
22
29
  generateOtp(mobile: string, acc: string, bankid: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"ASPAC.service.d.ts","sourceRoot":"","sources":["../../../src/banking/services/ASPAC.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAGpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,qBACa,YAAa,YAAW,WAAW;IAI5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM;IAI3B,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC;IAmC7B,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAgDhD,WAAW,CAAC,UAAU,EAAE,UAAU;IA0ElC,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG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e,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAS7C,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC;IAkC7B,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAyDhD,WAAW,CAAC,UAAU,EAAE,UAAU;IAoGlC,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAiFnD,yBAAyB,CAAC,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAuE7E,aAAa,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;IAoGnE,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;IAmGpE,qBAAqB,CAAC,qBAAqB,EAAE,qBAAqB,GACtE,OAAO,CAAC;QACN,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,GAAG,CAAC;QACb,aAAa,EAAE,GAAG,CAAC;QACnB,SAAS,EAAE,GAAG,CAAC;QACf,YAAY,EAAE,GAAG,CAAC;KACnB,CAAC;IAmJE,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAInD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAIzF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAIhE,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAG1C"}
@@ -62,11 +62,16 @@ let ASPACService = class ASPACService {
62
62
  this.config = config;
63
63
  this.logger = logger;
64
64
  }
65
+ combineDateTime(date, time) {
66
+ const isoString = `${date}T${time.padEnd(8, '0')}.000Z`;
67
+ const d = new Date(isoString);
68
+ const isoWithOffset = d.toISOString().replace('Z', '+00:00');
69
+ return isoWithOffset;
70
+ }
65
71
  async generateToken() {
66
72
  this.logger.log("Generating WelcomeBank Token");
67
73
  try {
68
74
  const headers = {
69
- 'Content-Type': 'application/json',
70
75
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
71
76
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
72
77
  };
@@ -91,15 +96,14 @@ let ASPACService = class ASPACService {
91
96
  if (!refreshToken) {
92
97
  throw new common_1.HttpException({
93
98
  statusCode: common_1.HttpStatus.BAD_REQUEST,
94
- code: 4000,
95
- message: 'Bank token should not be empty.',
99
+ code: 400010205,
100
+ message: 'Refresh token is required.',
96
101
  data: { refreshToken }
97
102
  }, common_1.HttpStatus.BAD_REQUEST);
98
103
  }
99
104
  this.logger.log("Welcome Bank refresh token");
100
105
  try {
101
106
  const headers = {
102
- 'Content-Type': 'application/json',
103
107
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
104
108
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
105
109
  };
@@ -120,48 +124,46 @@ let ASPACService = class ASPACService {
120
124
  };
121
125
  }
122
126
  catch (error) {
127
+ if (error.response.data.message === "Invalid refresh token") {
128
+ throw new common_1.HttpException({
129
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
130
+ code: 400010206,
131
+ message: 'Invalid refresh token.',
132
+ data: { refreshToken }
133
+ }, common_1.HttpStatus.BAD_REQUEST);
134
+ }
123
135
  axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
124
136
  }
125
137
  }
126
138
  async linkAccount(accountDto) {
127
- const { token, account, accountType, mobile } = accountDto;
128
- if (!token) {
129
- throw new common_1.HttpException({
130
- statusCode: common_1.HttpStatus.UNAUTHORIZED,
131
- code: 4000,
132
- message: 'Bank token should not be empty.',
133
- data: { accountDto }
134
- }, common_1.HttpStatus.UNAUTHORIZED);
135
- }
139
+ const { account, accountType, mobile } = accountDto;
136
140
  if (!account) {
137
141
  throw new common_1.HttpException({
138
142
  statusCode: common_1.HttpStatus.BAD_REQUEST,
139
- code: 4000,
140
- message: 'Bank account number should not be empty.',
141
- data: { accountDto }
143
+ code: 400010306,
144
+ message: 'Account number is required.',
145
+ data: { ...accountDto }
142
146
  }, common_1.HttpStatus.BAD_REQUEST);
143
147
  }
144
148
  if (!accountType) {
145
149
  throw new common_1.HttpException({
146
150
  statusCode: common_1.HttpStatus.BAD_REQUEST,
147
- code: 4000,
148
- message: 'Bank account type should not be empty.',
149
- data: { accountDto }
151
+ code: 400010308,
152
+ message: 'Account type is required.',
153
+ data: { ...accountDto }
150
154
  }, common_1.HttpStatus.BAD_REQUEST);
151
155
  }
152
156
  if (!mobile) {
153
157
  throw new common_1.HttpException({
154
158
  statusCode: common_1.HttpStatus.BAD_REQUEST,
155
- code: 4000,
156
- message: 'Mobile Number should not be empty.',
157
- data: { accountDto }
159
+ code: 4000103011,
160
+ message: 'Mobile number is required.',
161
+ data: { ...accountDto }
158
162
  }, common_1.HttpStatus.BAD_REQUEST);
159
163
  }
160
164
  this.logger.log("Welcome Bank Link Account");
161
165
  try {
162
166
  const headers = {
163
- 'Authorization': `Bearer ${token}`,
164
- 'Content-Type': 'application/json',
165
167
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
166
168
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
167
169
  };
@@ -179,40 +181,62 @@ let ASPACService = class ASPACService {
179
181
  };
180
182
  }
181
183
  catch (error) {
184
+ if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
185
+ throw new common_1.HttpException({
186
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
187
+ code: 400010305,
188
+ message: 'Account not found',
189
+ data: { ...accountDto }
190
+ }, common_1.HttpStatus.BAD_REQUEST);
191
+ }
192
+ if (error.response.data.message === "Invalid account type. Only deposit accounts (01) allowed") {
193
+ throw new common_1.HttpException({
194
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
195
+ code: 400010307,
196
+ message: 'Account type is not supported.',
197
+ data: { ...accountDto }
198
+ }, common_1.HttpStatus.BAD_REQUEST);
199
+ }
200
+ if (error.response.data.message === "Mobile number does not match registered mobile") {
201
+ throw new common_1.HttpException({
202
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
203
+ code: 400010309,
204
+ message: 'Mobile number is not registered in the account.',
205
+ data: { ...accountDto }
206
+ }, common_1.HttpStatus.BAD_REQUEST);
207
+ }
208
+ if (error.response.data.message === "Mobile number must be 12 digits (63XXXXXXXXXX)") {
209
+ throw new common_1.HttpException({
210
+ statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
211
+ code: 4220103010,
212
+ message: 'Invalid mobile number format.',
213
+ data: { ...accountDto }
214
+ }, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
215
+ }
182
216
  axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
183
217
  }
184
218
  }
185
219
  async validateOtp(validateOtp) {
186
- const { token, account, otp } = validateOtp;
187
- if (!token) {
188
- throw new common_1.HttpException({
189
- statusCode: common_1.HttpStatus.UNAUTHORIZED,
190
- code: 4000,
191
- message: 'Bank token should not be empty.',
192
- data: { validateOtp }
193
- }, common_1.HttpStatus.UNAUTHORIZED);
194
- }
220
+ const { account, otp } = validateOtp;
195
221
  if (!account) {
196
222
  throw new common_1.HttpException({
197
223
  statusCode: common_1.HttpStatus.BAD_REQUEST,
198
- code: 4000,
199
- message: 'Bank account number should not be empty.',
200
- data: { validateOtp }
224
+ code: 400010406,
225
+ message: 'Account number is required.',
226
+ data: { ...validateOtp }
201
227
  }, common_1.HttpStatus.BAD_REQUEST);
202
228
  }
203
229
  if (!otp) {
204
230
  throw new common_1.HttpException({
205
231
  statusCode: common_1.HttpStatus.BAD_REQUEST,
206
- code: 4000,
207
- message: 'Bank account number should not be empty.',
208
- data: { validateOtp }
232
+ code: 400010408,
233
+ message: 'OTP is required.',
234
+ data: { ...validateOtp }
209
235
  }, common_1.HttpStatus.BAD_REQUEST);
210
236
  }
211
237
  this.logger.log("Welcome Bank Validate OTP");
212
238
  try {
213
239
  const headers = {
214
- 'Authorization': `Bearer ${token}`,
215
- 'Content-Type': 'application/json',
216
240
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
217
241
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
218
242
  };
@@ -234,6 +258,22 @@ let ASPACService = class ASPACService {
234
258
  };
235
259
  }
236
260
  catch (error) {
261
+ if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
262
+ throw new common_1.HttpException({
263
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
264
+ code: 400010405,
265
+ message: 'Account not found.',
266
+ data: { ...validateOtp }
267
+ }, common_1.HttpStatus.BAD_REQUEST);
268
+ }
269
+ if (error.response.data.message === "Invalid OTP format. OTP must be exactly 6 digits" || error.response.data.message === "Invalid OTP code") {
270
+ throw new common_1.HttpException({
271
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
272
+ code: 400010407,
273
+ message: 'Invalid or expired OTP.',
274
+ data: { ...validateOtp }
275
+ }, common_1.HttpStatus.BAD_REQUEST);
276
+ }
237
277
  axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
238
278
  }
239
279
  }
@@ -242,24 +282,23 @@ let ASPACService = class ASPACService {
242
282
  if (!token) {
243
283
  throw new common_1.HttpException({
244
284
  statusCode: common_1.HttpStatus.UNAUTHORIZED,
245
- code: 4000,
285
+ code: 401010506,
246
286
  message: 'Bank token should not be empty.',
247
- data: { fetchBalanceDto }
287
+ data: { ...fetchBalanceDto }
248
288
  }, common_1.HttpStatus.UNAUTHORIZED);
249
289
  }
250
290
  if (!account) {
251
291
  throw new common_1.HttpException({
252
292
  statusCode: common_1.HttpStatus.BAD_REQUEST,
253
- code: 4000,
254
- message: 'Bank account number should not be empty.',
255
- data: { fetchBalanceDto }
293
+ code: 400010508,
294
+ message: 'Account number is required.',
295
+ data: { ...fetchBalanceDto }
256
296
  }, common_1.HttpStatus.BAD_REQUEST);
257
297
  }
258
298
  this.logger.log("Welcome Bank Balance Inquiry");
259
299
  try {
260
300
  const headers = {
261
301
  'Authorization': `Bearer ${token}`,
262
- 'Content-Type': 'application/json',
263
302
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
264
303
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
265
304
  };
@@ -280,6 +319,14 @@ let ASPACService = class ASPACService {
280
319
  };
281
320
  }
282
321
  catch (error) {
322
+ if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
323
+ throw new common_1.HttpException({
324
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
325
+ code: 400010507,
326
+ message: 'Account not found.',
327
+ data: { fetchBalanceDto }
328
+ }, common_1.HttpStatus.BAD_REQUEST);
329
+ }
283
330
  axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
284
331
  }
285
332
  }
@@ -288,40 +335,39 @@ let ASPACService = class ASPACService {
288
335
  if (!token) {
289
336
  throw new common_1.HttpException({
290
337
  statusCode: common_1.HttpStatus.UNAUTHORIZED,
291
- code: 4000,
338
+ code: 401010606,
292
339
  message: 'Bank token should not be empty.',
293
- data: { accountTransferDto }
340
+ data: { ...accountTransferDto }
294
341
  }, common_1.HttpStatus.UNAUTHORIZED);
295
342
  }
296
343
  if (!sourceAccount) {
297
344
  throw new common_1.HttpException({
298
345
  statusCode: common_1.HttpStatus.BAD_REQUEST,
299
- code: 4000,
300
- message: 'Bank source account number should not be empty.',
301
- data: { accountTransferDto }
346
+ code: 400010608,
347
+ message: 'Account number is required',
348
+ data: { ...accountTransferDto }
302
349
  }, common_1.HttpStatus.BAD_REQUEST);
303
350
  }
304
351
  if (!amount) {
305
352
  throw new common_1.HttpException({
306
353
  statusCode: common_1.HttpStatus.BAD_REQUEST,
307
- code: 4000,
308
- message: 'Amount should not be empty.',
309
- data: { accountTransferDto }
354
+ code: 400010609,
355
+ message: 'Transaction amount is required.',
356
+ data: { ...accountTransferDto }
310
357
  }, common_1.HttpStatus.BAD_REQUEST);
311
358
  }
312
359
  if (!particulars) {
313
360
  throw new common_1.HttpException({
314
361
  statusCode: common_1.HttpStatus.BAD_REQUEST,
315
- code: 4000,
316
- message: 'Particulars should not be empty.',
317
- data: { accountTransferDto }
362
+ code: 400010611,
363
+ message: 'Transaction particulars is required.',
364
+ data: { ...accountTransferDto }
318
365
  }, common_1.HttpStatus.BAD_REQUEST);
319
366
  }
320
367
  this.logger.log("Welcome Bank cash in");
321
368
  try {
322
369
  const headers = {
323
370
  'Authorization': `Bearer ${token}`,
324
- 'Content-Type': 'application/json',
325
371
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
326
372
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
327
373
  };
@@ -344,6 +390,22 @@ let ASPACService = class ASPACService {
344
390
  };
345
391
  }
346
392
  catch (error) {
393
+ if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
394
+ throw new common_1.HttpException({
395
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
396
+ code: 400010607,
397
+ message: 'Account not found.',
398
+ data: { ...accountTransferDto }
399
+ }, common_1.HttpStatus.UNAUTHORIZED);
400
+ }
401
+ if (error.response.data.message === "Amount must be between 0.01 and 500,000.00" || error.response.data.message === "Invalid amount format") {
402
+ throw new common_1.HttpException({
403
+ statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
404
+ code: 422010610,
405
+ message: 'Invalid transaction amount value.',
406
+ data: { ...accountTransferDto }
407
+ }, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
408
+ }
347
409
  axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
348
410
  }
349
411
  }
@@ -352,40 +414,39 @@ let ASPACService = class ASPACService {
352
414
  if (!token) {
353
415
  throw new common_1.HttpException({
354
416
  statusCode: common_1.HttpStatus.UNAUTHORIZED,
355
- code: 4000,
417
+ code: 401010706,
356
418
  message: 'Bank token should not be empty.',
357
- data: { accountTransferDto }
419
+ data: { ...accountTransferDto }
358
420
  }, common_1.HttpStatus.UNAUTHORIZED);
359
421
  }
360
422
  if (!destinationAccount) {
361
423
  throw new common_1.HttpException({
362
424
  statusCode: common_1.HttpStatus.BAD_REQUEST,
363
- code: 4000,
364
- message: 'Bank destination account number should not be empty.',
365
- data: { accountTransferDto }
425
+ code: 400010708,
426
+ message: 'Account number is required.',
427
+ data: { ...accountTransferDto }
366
428
  }, common_1.HttpStatus.BAD_REQUEST);
367
429
  }
368
430
  if (!amount) {
369
431
  throw new common_1.HttpException({
370
432
  statusCode: common_1.HttpStatus.BAD_REQUEST,
371
- code: 4000,
372
- message: 'amount should not be empty.',
373
- data: { accountTransferDto }
433
+ code: 400010709,
434
+ message: 'Transaction amount is required.',
435
+ data: { ...accountTransferDto }
374
436
  }, common_1.HttpStatus.BAD_REQUEST);
375
437
  }
376
438
  if (!particulars) {
377
439
  throw new common_1.HttpException({
378
440
  statusCode: common_1.HttpStatus.BAD_REQUEST,
379
- code: 4000,
380
- message: 'Particulars should not be empty.',
381
- data: { accountTransferDto }
441
+ code: 400010711,
442
+ message: 'Transaction particulars is required.',
443
+ data: { ...accountTransferDto }
382
444
  }, common_1.HttpStatus.BAD_REQUEST);
383
445
  }
384
446
  this.logger.log("Welcome Bank deposit");
385
447
  try {
386
448
  const headers = {
387
449
  'Authorization': `Bearer ${token}`,
388
- 'Content-Type': 'application/json',
389
450
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
390
451
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
391
452
  };
@@ -408,48 +469,81 @@ let ASPACService = class ASPACService {
408
469
  };
409
470
  }
410
471
  catch (error) {
472
+ if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
473
+ throw new common_1.HttpException({
474
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
475
+ code: 400010707,
476
+ message: 'Account not found.',
477
+ data: { ...accountTransferDto }
478
+ }, common_1.HttpStatus.BAD_REQUEST);
479
+ }
480
+ if (error.response.data.message === "Amount must be between 0.01 and 500,000.00" || error.response.data.message === "Invalid amount format") {
481
+ throw new common_1.HttpException({
482
+ statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
483
+ code: 422010710,
484
+ message: 'Invalid transaction amount value.',
485
+ data: { ...accountTransferDto }
486
+ }, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
487
+ }
411
488
  axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
412
489
  }
413
490
  }
414
491
  async getTransactionHistory(transactionHistoryDto) {
415
492
  const { token, account, dateFrom, dateTo, page } = transactionHistoryDto;
493
+ const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
494
+ const reformattedTransactions = {};
416
495
  if (!token) {
417
496
  throw new common_1.HttpException({
418
497
  statusCode: common_1.HttpStatus.UNAUTHORIZED,
419
- code: 4000,
498
+ code: 401010806,
420
499
  message: 'Bank token should not be empty.',
421
- data: { transactionHistoryDto }
500
+ data: { ...transactionHistoryDto }
422
501
  }, common_1.HttpStatus.UNAUTHORIZED);
423
502
  }
424
503
  if (!account) {
425
504
  throw new common_1.HttpException({
426
505
  statusCode: common_1.HttpStatus.BAD_REQUEST,
427
- code: 4000,
428
- message: 'Bank account number should not be empty.',
429
- data: { transactionHistoryDto }
506
+ code: 400010808,
507
+ message: 'Account number is required.',
508
+ data: { ...transactionHistoryDto }
430
509
  }, common_1.HttpStatus.BAD_REQUEST);
431
510
  }
432
511
  if (!dateFrom) {
433
512
  throw new common_1.HttpException({
434
513
  statusCode: common_1.HttpStatus.BAD_REQUEST,
435
- code: 4000,
436
- message: 'Date From should not be empty.',
437
- data: { transactionHistoryDto }
514
+ code: 400010810,
515
+ message: 'Starting date is required.',
516
+ data: { ...transactionHistoryDto }
438
517
  }, common_1.HttpStatus.BAD_REQUEST);
439
518
  }
519
+ if (!dateRegex.test(dateFrom)) {
520
+ throw new common_1.HttpException({
521
+ statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
522
+ code: 422010809,
523
+ message: 'Invalid starting date format. Format should be in YYYY-MM-DD.',
524
+ data: { ...transactionHistoryDto }
525
+ }, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
526
+ }
440
527
  if (!dateTo) {
441
528
  throw new common_1.HttpException({
442
529
  statusCode: common_1.HttpStatus.BAD_REQUEST,
443
- code: 4000,
444
- message: 'Date From should not be empty.',
445
- data: { transactionHistoryDto }
530
+ code: 400010812,
531
+ message: 'Ending date is required.',
532
+ data: { ...transactionHistoryDto }
446
533
  }, common_1.HttpStatus.BAD_REQUEST);
447
534
  }
535
+ if (!dateRegex.test(dateTo)) {
536
+ throw new common_1.HttpException({
537
+ statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
538
+ code: 422010811,
539
+ message: 'Invalid starting date format. Format should be in YYYY-MM-DD.',
540
+ data: { ...transactionHistoryDto }
541
+ }, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
542
+ }
448
543
  this.logger.log("Welcome Bank transaction history");
449
544
  try {
450
545
  const headers = {
451
546
  'Authorization': `Bearer ${token}`,
452
- 'Content-Type': 'application/json',
453
547
  'X-API-KEY': `${this.config.ASPAC_API_KEY}`,
454
548
  'X-API-VERSION': `${this.config.ASPAC_VERSION_KEY}`
455
549
  };
@@ -467,12 +561,42 @@ let ASPACService = class ASPACService {
467
561
  httpsAgent
468
562
  });
469
563
  this.logger.log({ responseData: response.data }, 'Welcome Bank Transaction History Successful');
564
+ response.data.data.transactions.forEach((txn, index) => {
565
+ const key = `${index + 1}`;
566
+ const dateTime = this.combineDateTime(txn.tranDate, txn.tranTime);
567
+ reformattedTransactions[key] = {
568
+ dateTime,
569
+ amount: txn.tranAmount,
570
+ type: txn.tranType,
571
+ description: txn.description,
572
+ transactionReference: txn.tranReference
573
+ };
574
+ });
470
575
  return {
471
576
  success: true,
472
- ...response.data,
577
+ message: response.data.data.message,
578
+ correlationId: response.data.correlationId,
579
+ timestamp: response.data.timestamp,
580
+ transactions: reformattedTransactions,
473
581
  };
474
582
  }
475
583
  catch (error) {
584
+ if (error.response.data.message === "Account number must be 14 digits" || error.response.data.message === "Account does not exist or is not active") {
585
+ throw new common_1.HttpException({
586
+ statusCode: common_1.HttpStatus.BAD_REQUEST,
587
+ code: 400010807,
588
+ message: 'Account not found.',
589
+ data: { ...transactionHistoryDto }
590
+ }, common_1.HttpStatus.BAD_REQUEST);
591
+ }
592
+ if (error.response.data.message === "Invalid page number format") {
593
+ throw new common_1.HttpException({
594
+ statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
595
+ code: 422010813,
596
+ message: 'Invalid page number format.',
597
+ data: { ...transactionHistoryDto }
598
+ }, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
599
+ }
476
600
  axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
477
601
  }
478
602
  }