@cuenca-mx/cuenca-js 0.0.1-dev.2 → 0.0.1-dev.22
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.
- package/README.md +155 -2
- package/build/{cjs/errors.js → errors/index.cjs} +0 -0
- package/build/{esm/errors.js → errors/index.mjs} +0 -0
- package/build/identities-7fc7251d.mjs +289 -0
- package/build/{cjs/queries-08df635b.js → identities-b7106a30.cjs} +20 -287
- package/build/{cjs/index.js → index.cjs} +169 -111
- package/build/{esm/index.js → index.mjs} +111 -19
- package/build/{cjs/jwt.js → jwt/index.cjs} +8 -3
- package/build/{esm/jwt.js → jwt/index.mjs} +3 -2
- package/build/queries-59c893b6.mjs +282 -0
- package/build/queries-bc02f9a8.cjs +296 -0
- package/build/{cjs/requests.js → requests/index.cjs} +4 -3
- package/build/{esm/requests.js → requests/index.mjs} +3 -3
- package/build/types/index.cjs +41 -0
- package/build/types/index.mjs +3 -0
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{esm/walletTransactionRequest-18aad4dc.js → walletTransactionRequest-7334f8c5.mjs} +10 -3
- package/build/{cjs/walletTransactionRequest-82837ee6.js → walletTransactionRequest-a1851594.cjs} +28 -20
- package/package.json +28 -5
- package/build/cjs/data-c53f1052.js +0 -14
- package/build/cjs/types.js +0 -40
- package/build/esm/data-7d3d5fcc.js +0 -11
- package/build/esm/queries-716c6be4.js +0 -546
- package/build/esm/types.js +0 -3
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var errors = require('./errors.js');
|
|
4
|
-
var data = require('./data-c53f1052.js');
|
|
5
|
-
|
|
6
3
|
class CardErrorType {
|
|
7
4
|
static Blocked = new CardErrorType('blocked');
|
|
8
5
|
|
|
@@ -267,311 +264,47 @@ class WalletTransactionType {
|
|
|
267
264
|
}
|
|
268
265
|
}
|
|
269
266
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
}
|
|
307
|
-
|
|
308
|
-
get limit() {
|
|
309
|
-
return this._limit;
|
|
310
|
-
}
|
|
311
|
-
|
|
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
|
-
}
|
|
320
|
-
|
|
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
|
-
}
|
|
267
|
+
const dateToUTC = (date) => {
|
|
268
|
+
if (!date) return null;
|
|
269
|
+
const dateObj = new Date(date);
|
|
270
|
+
return new Date(dateObj.getTime());
|
|
271
|
+
};
|
|
340
272
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
}
|
|
273
|
+
const enumValueFromString = (enumValue, value) =>
|
|
274
|
+
Object.values(enumValue).find((enumV) => enumV.value === value);
|
|
345
275
|
|
|
346
|
-
class
|
|
347
|
-
constructor({
|
|
348
|
-
|
|
349
|
-
this.
|
|
276
|
+
class TOSAgreements {
|
|
277
|
+
constructor({ ip, location, version }) {
|
|
278
|
+
this.ip = ip;
|
|
279
|
+
this.location = location;
|
|
280
|
+
this.version = version;
|
|
350
281
|
}
|
|
351
282
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
283
|
+
static fromObject = ({ ip, location, version }) =>
|
|
284
|
+
new TOSAgreements({
|
|
285
|
+
ip,
|
|
286
|
+
location,
|
|
287
|
+
version,
|
|
355
288
|
});
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
class ApiKeyQuery extends QueryParams {
|
|
360
|
-
constructor({ active, ...args }) {
|
|
361
|
-
super(args);
|
|
362
|
-
this.active = active;
|
|
363
|
-
}
|
|
364
|
-
|
|
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
|
-
});
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
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
|
-
}
|
|
459
|
-
|
|
460
|
-
class CardTransactionQuery extends QueryParams {
|
|
461
|
-
constructor({ cardUri, ...args }) {
|
|
462
|
-
super(args);
|
|
463
|
-
this.cardUri = cardUri;
|
|
464
|
-
}
|
|
465
|
-
|
|
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
|
-
});
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
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
|
-
}
|
|
500
|
-
|
|
501
|
-
class WalletQuery extends QueryParams {
|
|
502
|
-
constructor({ active, ...args }) {
|
|
503
|
-
super(args);
|
|
504
|
-
this.active = active;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
toObject() {
|
|
508
|
-
return Object.assign(super.toObject(), {
|
|
509
|
-
active: this.active,
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
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
|
-
}
|
|
523
|
-
|
|
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.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
289
|
}
|
|
547
290
|
|
|
548
|
-
exports.AccountQuery = AccountQuery;
|
|
549
|
-
exports.ApiKeyQuery = ApiKeyQuery;
|
|
550
|
-
exports.BalanceEntryQuery = BalanceEntryQuery;
|
|
551
|
-
exports.BillPaymentQuery = BillPaymentQuery;
|
|
552
291
|
exports.CardErrorType = CardErrorType;
|
|
553
292
|
exports.CardFundingType = CardFundingType;
|
|
554
293
|
exports.CardIssuer = CardIssuer;
|
|
555
294
|
exports.CardStatus = CardStatus;
|
|
556
|
-
exports.CardTransactionQuery = CardTransactionQuery;
|
|
557
295
|
exports.CardTransactionType = CardTransactionType;
|
|
558
296
|
exports.CardType = CardType;
|
|
559
|
-
exports.CardsQuery = CardsQuery;
|
|
560
297
|
exports.CommissionType = CommissionType;
|
|
561
298
|
exports.DepositNetwork = DepositNetwork;
|
|
562
|
-
exports.DepositQuery = DepositQuery;
|
|
563
299
|
exports.EntryType = EntryType;
|
|
564
300
|
exports.FileFormat = FileFormat;
|
|
565
|
-
exports.PageSize = PageSize;
|
|
566
301
|
exports.Phase = Phase;
|
|
567
|
-
exports.QueryParams = QueryParams;
|
|
568
302
|
exports.SavingCategory = SavingCategory;
|
|
569
303
|
exports.ServiceProviderCategory = ServiceProviderCategory;
|
|
570
|
-
exports.
|
|
304
|
+
exports.TOSAgreements = TOSAgreements;
|
|
571
305
|
exports.TrackDataMethod = TrackDataMethod;
|
|
572
306
|
exports.TransactionStatus = TransactionStatus;
|
|
573
307
|
exports.TransferNetwork = TransferNetwork;
|
|
574
|
-
exports.TransferQuery = TransferQuery;
|
|
575
|
-
exports.WalletQuery = WalletQuery;
|
|
576
|
-
exports.WalletTransactionQuery = WalletTransactionQuery;
|
|
577
308
|
exports.WalletTransactionType = WalletTransactionType;
|
|
309
|
+
exports.dateToUTC = dateToUTC;
|
|
310
|
+
exports.enumValueFromString = enumValueFromString;
|