@cuenca-mx/cuenca-js 0.0.1-dev.5 → 0.0.1-dev.52

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,8 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var errors_index = require('./errors/index.js');
4
- var data = require('./data-c53f1052.js');
5
-
6
3
  class CardErrorType {
7
4
  static Blocked = new CardErrorType('blocked');
8
5
 
@@ -141,6 +138,38 @@ class FileFormat {
141
138
  }
142
139
  }
143
140
 
141
+ class KYCFileType {
142
+ static Ine = new KYCFileType('ine');
143
+
144
+ static Passport = new KYCFileType('passport');
145
+
146
+ static Residency = new KYCFileType('residency');
147
+
148
+ static MatriculaConsular = new KYCFileType('matricula_consular');
149
+
150
+ static ProofOfLiveness = new KYCFileType('proof_of_liveness');
151
+
152
+ static ProofOfAddress = new KYCFileType('proof_of_address');
153
+
154
+ constructor(value) {
155
+ this.value = value;
156
+ }
157
+ }
158
+
159
+ class KYCStatus {
160
+ static UploadAgain = new KYCStatus('upload_again');
161
+
162
+ static ReviewNeeded = new KYCStatus('review_needed');
163
+
164
+ static Submitted = new KYCStatus('submitted');
165
+
166
+ static Succeeded = new KYCStatus('succeeded');
167
+
168
+ constructor(value) {
169
+ this.value = value;
170
+ }
171
+ }
172
+
144
173
  class Phase {
145
174
  static Sandbox = new Phase('sandbox');
146
175
 
@@ -257,321 +286,69 @@ class TransferNetwork {
257
286
  }
258
287
  }
259
288
 
260
- class WalletTransactionType {
261
- static Deposit = new WalletTransactionType('deposit');
262
-
263
- static Withdrawal = new WalletTransactionType('withdrawal');
264
-
265
- constructor(value) {
266
- this.value = value;
267
- }
268
- }
269
-
270
- class PageSize {
271
- constructor(size) {
272
- this.maxSize = 100;
273
- this._ps = size;
274
- }
275
-
276
- get size() {
277
- return this._pageSize;
278
- }
279
-
280
- set _ps(value) {
281
- let validatedPageSize = this.maxSize;
282
- if (value && value > 0 && value <= this.maxSize) {
283
- validatedPageSize = value;
284
- }
285
- this._pageSize = validatedPageSize;
286
- }
287
- }
288
-
289
- class QueryParams {
290
- constructor({
291
- createdAfter,
292
- createdBefore,
293
- limit,
294
- pageSize,
295
- relatedTransaction,
296
- userId,
297
- count = false,
298
- }) {
299
- this.createdAfter = createdAfter;
300
- this.createdBefore = createdBefore;
301
- this._lmt = limit;
302
- this.relatedTransaction = relatedTransaction;
303
- this.userId = userId;
304
- this.count = count;
305
- this.pageSize = pageSize;
306
- }
289
+ class UserStatus {
290
+ static Active = new UserStatus('active');
307
291
 
308
- get limit() {
309
- return this._limit;
310
- }
292
+ static Deactivated = new UserStatus('deactivated');
311
293
 
312
- // Validator for limit
313
- set _lmt(value) {
314
- let validatedValue = null;
315
- if (value && value >= 0) {
316
- validatedValue = value;
317
- }
318
- this._limit = validatedValue;
319
- }
294
+ static Fraud = new UserStatus('fraud');
320
295
 
321
- toObject() {
322
- return {
323
- created_after: this.createdAfter,
324
- created_before: this.createdBefore,
325
- limit: this.limit,
326
- related_transaction: this.relatedTransaction,
327
- user_id: this.userId,
328
- page_size: this.pageSize && this.pageSize.size,
329
- };
330
- }
331
-
332
- toParams() {
333
- const helper = { ...this.toObject() };
334
- if (this.count) helper.count = 1;
335
- Object.keys(helper).forEach((k) => {
336
- if (helper[k] == null) delete helper[k];
337
- });
338
- return helper;
339
- }
340
-
341
- toQueryString() {
342
- return new URLSearchParams(this.toParams()).toString();
343
- }
344
- }
345
-
346
- class AccountQuery extends QueryParams {
347
- constructor({ accountNumber, ...args }) {
348
- super(args);
349
- this.accountNumber = accountNumber;
350
- }
351
-
352
- toObject() {
353
- return Object.assign(super.toObject(), {
354
- account_number: this.accountNumber,
355
- });
356
- }
357
- }
358
-
359
- class ApiKeyQuery extends QueryParams {
360
- constructor({ active, ...args }) {
361
- super(args);
362
- this.active = active;
363
- }
296
+ static PldBlocked = new UserStatus('pld_blocked');
364
297
 
365
- toObject() {
366
- return Object.assign(super.toObject(), {
367
- active: this.active,
368
- });
369
- }
370
- }
371
-
372
- class TransactionQuery extends QueryParams {
373
- constructor({ status, ...args }) {
374
- super(args);
375
- this.status = status;
376
- }
377
-
378
- toObject() {
379
- return Object.assign(super.toObject(), {
380
- status: this.status,
381
- });
382
- }
383
- }
384
-
385
- class DepositQuery extends TransactionQuery {
386
- constructor({ trackingKey, network, ...args }) {
387
- super(args);
388
- this.trackingKey = trackingKey;
389
- this.network = network;
390
- }
391
-
392
- toObject() {
393
- return Object.assign(super.toObject(), {
394
- tracking_key: this.trackingKey,
395
- network: this.network,
396
- });
397
- }
398
- }
399
-
400
- class TransferQuery extends TransactionQuery {
401
- constructor({
402
- accountNumber,
403
- idempotencyKey,
404
- trackingKey,
405
- network,
406
- ...args
407
- }) {
408
- super(args);
409
- this.accountNumber = accountNumber;
410
- this.idempotencyKey = idempotencyKey;
411
- this.trackingKey = trackingKey;
412
- this.network = network;
413
- }
414
-
415
- toObject() {
416
- return Object.assign(super.toObject(), {
417
- account_number: this.accountNumber,
418
- idempotency_key: this.idempotencyKey,
419
- tracking_key: this.trackingKey,
420
- network: this.network,
421
- });
422
- }
423
- }
424
-
425
- class BalanceEntryQuery extends QueryParams {
426
- constructor({
427
- fundingInstrumentUri,
428
- count = false,
429
- walletId = 'default',
430
- ...args
431
- }) {
432
- super(args);
433
- this.fundingInstrumentUri = fundingInstrumentUri;
434
- this.count = count;
435
- this.walletId = walletId;
436
- }
437
-
438
- toObject() {
439
- return Object.assign(super.toObject(), {
440
- wallet_id: this.walletId,
441
- funding_instrument_uri: this.fundingInstrumentUri,
442
- count: this.count,
443
- });
298
+ constructor(value) {
299
+ this.value = value;
444
300
  }
445
301
  }
446
302
 
447
- class BillPaymentQuery extends QueryParams {
448
- constructor({ accountNumber, ...args }) {
449
- super(args);
450
- this.accountNumber = accountNumber;
451
- }
452
-
453
- toObject() {
454
- return Object.assign(super.toObject(), {
455
- account_number: this.accountNumber,
456
- });
457
- }
458
- }
303
+ class VerificationType {
304
+ static Phone = new VerificationType('phone');
459
305
 
460
- class CardTransactionQuery extends QueryParams {
461
- constructor({ cardUri, ...args }) {
462
- super(args);
463
- this.cardUri = cardUri;
464
- }
306
+ static Email = new VerificationType('email');
465
307
 
466
- toObject() {
467
- return Object.assign(super.toObject(), {
468
- card_uri: this.cardUri,
469
- });
470
- }
471
- }
472
-
473
- class CardsQuery extends QueryParams {
474
- constructor({ cardUri, count = false, ...args }) {
475
- super(args);
476
- this.cardUri = cardUri;
477
- this.count = count;
478
- }
479
-
480
- toObject() {
481
- return Object.assign(super.toObject(), {
482
- card_uri: this.cardUri,
483
- count: this.count,
484
- });
308
+ constructor(value) {
309
+ this.value = value;
485
310
  }
486
311
  }
487
312
 
488
- class WalletTransactionQuery extends QueryParams {
489
- constructor({ walletUri, ...args }) {
490
- super(args);
491
- this.walletUri = walletUri;
492
- }
493
-
494
- toObject() {
495
- return Object.assign(super.toObject(), {
496
- wallet_uri: this.walletUri,
497
- });
498
- }
499
- }
313
+ class WalletTransactionType {
314
+ static Deposit = new WalletTransactionType('deposit');
500
315
 
501
- class WalletQuery extends QueryParams {
502
- constructor({ active, ...args }) {
503
- super(args);
504
- this.active = active;
505
- }
316
+ static Withdrawal = new WalletTransactionType('withdrawal');
506
317
 
507
- toObject() {
508
- return Object.assign(super.toObject(), {
509
- active: this.active,
510
- });
318
+ constructor(value) {
319
+ this.value = value;
511
320
  }
512
321
  }
513
322
 
514
- class StatementQuery extends QueryParams {
515
- constructor({ month, year, ...args }) {
516
- super(args);
517
- this.d = { month, year };
518
- }
519
-
520
- get month() {
521
- return this._date.month;
522
- }
323
+ const dateToUTC = (date) => {
324
+ if (!date) return null;
325
+ const dateObj = new Date(date);
326
+ return new Date(dateObj.getTime());
327
+ };
523
328
 
524
- get year() {
525
- return this._date.year;
526
- }
527
-
528
- set d({ month, year }) {
529
- const now = data.dateToUTC(Date.now());
530
- now.setUTCDate(1);
531
- const date = data.dateToUTC(`${year}-${month}-01`);
532
- if (date.getTime() >= now.getTime()) {
533
- throw new errors_index.ValidationError(
534
- `${year}-${month} is not a valid year-month pair`,
535
- );
536
- }
537
- this._date = { month, year };
538
- }
539
-
540
- toObject() {
541
- return Object.assign(super.toObject(), {
542
- month: this.month,
543
- year: this.year,
544
- });
545
- }
546
- }
329
+ const enumValueFromString = (enumValue, value) =>
330
+ Object.values(enumValue).find((enumV) => enumV.value === value);
547
331
 
548
- exports.AccountQuery = AccountQuery;
549
- exports.ApiKeyQuery = ApiKeyQuery;
550
- exports.BalanceEntryQuery = BalanceEntryQuery;
551
- exports.BillPaymentQuery = BillPaymentQuery;
552
332
  exports.CardErrorType = CardErrorType;
553
333
  exports.CardFundingType = CardFundingType;
554
334
  exports.CardIssuer = CardIssuer;
555
335
  exports.CardStatus = CardStatus;
556
- exports.CardTransactionQuery = CardTransactionQuery;
557
336
  exports.CardTransactionType = CardTransactionType;
558
337
  exports.CardType = CardType;
559
- exports.CardsQuery = CardsQuery;
560
338
  exports.CommissionType = CommissionType;
561
339
  exports.DepositNetwork = DepositNetwork;
562
- exports.DepositQuery = DepositQuery;
563
340
  exports.EntryType = EntryType;
564
341
  exports.FileFormat = FileFormat;
565
- exports.PageSize = PageSize;
342
+ exports.KYCFileType = KYCFileType;
343
+ exports.KYCStatus = KYCStatus;
566
344
  exports.Phase = Phase;
567
- exports.QueryParams = QueryParams;
568
345
  exports.SavingCategory = SavingCategory;
569
346
  exports.ServiceProviderCategory = ServiceProviderCategory;
570
- exports.StatementQuery = StatementQuery;
571
347
  exports.TrackDataMethod = TrackDataMethod;
572
348
  exports.TransactionStatus = TransactionStatus;
573
349
  exports.TransferNetwork = TransferNetwork;
574
- exports.TransferQuery = TransferQuery;
575
- exports.WalletQuery = WalletQuery;
576
- exports.WalletTransactionQuery = WalletTransactionQuery;
350
+ exports.UserStatus = UserStatus;
351
+ exports.VerificationType = VerificationType;
577
352
  exports.WalletTransactionType = WalletTransactionType;
353
+ exports.dateToUTC = dateToUTC;
354
+ exports.enumValueFromString = enumValueFromString;
File without changes