@cuenca-mx/cuenca-js 0.0.1-dev.23 → 0.0.1-dev.26
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 +2 -0
- package/build/base-80b9a673.cjs +28 -0
- package/build/base-c1f04b51.mjs +24 -0
- package/build/identities-1d279cf3.cjs +627 -0
- package/build/identities-73634653.mjs +593 -0
- package/build/index.cjs +92 -67
- package/build/index.mjs +36 -11
- package/build/requests/index.cjs +3 -2
- package/build/requests/index.mjs +2 -2
- package/build/types/index.cjs +17 -15
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-7334f8c5.mjs → walletTransactionRequest-8b125547.mjs} +58 -18
- package/build/{walletTransactionRequest-a1851594.cjs → walletTransactionRequest-bda66da3.cjs} +72 -31
- package/package.json +1 -1
- package/build/identities-7fc7251d.mjs +0 -289
- package/build/identities-b7106a30.cjs +0 -310
- package/build/queries-59c893b6.mjs +0 -282
- package/build/queries-bc02f9a8.cjs +0 -296
package/build/index.cjs
CHANGED
|
@@ -6,9 +6,9 @@ var axios = require('axios');
|
|
|
6
6
|
var Buffer = require('buffer');
|
|
7
7
|
var errors_index = require('./errors/index.cjs');
|
|
8
8
|
var jwt_index = require('./jwt/index.cjs');
|
|
9
|
-
var identities = require('./identities-
|
|
10
|
-
var
|
|
11
|
-
var walletTransactionRequest = require('./walletTransactionRequest-
|
|
9
|
+
var identities = require('./identities-1d279cf3.cjs');
|
|
10
|
+
var base = require('./base-80b9a673.cjs');
|
|
11
|
+
var walletTransactionRequest = require('./walletTransactionRequest-bda66da3.cjs');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ const isNode =
|
|
|
26
26
|
|
|
27
27
|
const runtimeEnv = { isBrowser, isNode };
|
|
28
28
|
|
|
29
|
-
const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.
|
|
29
|
+
const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.26";const description="Cuenca client for JS";const main="./build/index.cjs";const module$1="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports$1={".":{"import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{"import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{"import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{"import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{"import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.0.2";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const scripts={build:"rm -rf build/ && yarn rollup --config",test:"yarn node --experimental-vm-modules $(yarn bin jest)",publish:"yarn build && yarn npm publish"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1",jest:"^27.4.5",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2"};const dependencies={axios:"^0.24.0",buffer:"^6.0.3"};var pkg = {name:name,version:version,description:description,main:main,module:module$1,browser:browser,files:files,exports:exports$1,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
|
|
30
30
|
|
|
31
31
|
class Client {
|
|
32
32
|
constructor({ apiKey, apiSecret, phase = identities.Phase.Sandbox } = {}) {
|
|
@@ -95,7 +95,14 @@ class Client {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
async configure({
|
|
98
|
+
async configure({
|
|
99
|
+
apiKey,
|
|
100
|
+
apiSecret,
|
|
101
|
+
loginToken,
|
|
102
|
+
phase,
|
|
103
|
+
sessionId,
|
|
104
|
+
useJwt = false,
|
|
105
|
+
}) {
|
|
99
106
|
this.basicAuth = {
|
|
100
107
|
apiKey: apiKey || this.basicAuth.apiKey,
|
|
101
108
|
apiSecret: apiSecret || this.basicAuth.apiSecret,
|
|
@@ -108,6 +115,10 @@ class Client {
|
|
|
108
115
|
if (loginToken) {
|
|
109
116
|
this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
|
|
110
117
|
}
|
|
118
|
+
|
|
119
|
+
if (sessionId) {
|
|
120
|
+
this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
|
|
121
|
+
}
|
|
111
122
|
}
|
|
112
123
|
|
|
113
124
|
async get({ endpoint, format, params }) {
|
|
@@ -200,7 +211,7 @@ class Client {
|
|
|
200
211
|
class Account {
|
|
201
212
|
constructor({ accountNumber, createdAt, id, institutionName, name, userId }) {
|
|
202
213
|
this.accountNumber = accountNumber;
|
|
203
|
-
this.createdAt =
|
|
214
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
204
215
|
this.id = id;
|
|
205
216
|
this.institutionName = institutionName;
|
|
206
217
|
this.name = name;
|
|
@@ -220,12 +231,12 @@ class Account {
|
|
|
220
231
|
|
|
221
232
|
class ApiKey {
|
|
222
233
|
constructor({ createdAt, deactivatedAt, id, secret, userId, updatedAt }) {
|
|
223
|
-
this.createdAt =
|
|
224
|
-
this.deactivatedAt =
|
|
234
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
235
|
+
this.deactivatedAt = base.dateToUTC(deactivatedAt);
|
|
225
236
|
this.id = id;
|
|
226
237
|
this.secret = secret;
|
|
227
238
|
this.userId = userId;
|
|
228
|
-
this.updatedAt =
|
|
239
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
static fromObject = ({ id, secret, ...obj }) =>
|
|
@@ -239,7 +250,7 @@ class ApiKey {
|
|
|
239
250
|
});
|
|
240
251
|
|
|
241
252
|
get isActive() {
|
|
242
|
-
const todayUTC =
|
|
253
|
+
const todayUTC = base.dateToUTC(Date.now());
|
|
243
254
|
return (
|
|
244
255
|
!this.deactivatedAt || this.deactivatedAt.getTime() > todayUTC.getTime()
|
|
245
256
|
);
|
|
@@ -249,7 +260,7 @@ class ApiKey {
|
|
|
249
260
|
class Arpc {
|
|
250
261
|
constructor({ arpc, createdAt, cardUri, isValidArqc }) {
|
|
251
262
|
this.arpc = arpc;
|
|
252
|
-
this.createdAt =
|
|
263
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
253
264
|
this.cardUri = cardUri;
|
|
254
265
|
this.isValidArqc = isValidArqc;
|
|
255
266
|
}
|
|
@@ -276,9 +287,9 @@ class BalanceEntry {
|
|
|
276
287
|
rollingBalance,
|
|
277
288
|
}) {
|
|
278
289
|
this.amount = amount;
|
|
279
|
-
this.createdAt =
|
|
290
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
280
291
|
this.descriptor = descriptor;
|
|
281
|
-
this.entryType =
|
|
292
|
+
this.entryType = base.enumValueFromString(identities.EntryType, entryType);
|
|
282
293
|
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
283
294
|
this.id = id;
|
|
284
295
|
this.name = name;
|
|
@@ -303,9 +314,9 @@ class BalanceEntry {
|
|
|
303
314
|
class Transaction {
|
|
304
315
|
constructor({ amount, createdAt, descriptor, status, userId }) {
|
|
305
316
|
this.amount = amount;
|
|
306
|
-
this.createdAt =
|
|
317
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
307
318
|
this.descriptor = descriptor;
|
|
308
|
-
this.status =
|
|
319
|
+
this.status = base.enumValueFromString(identities.TransactionStatus, status);
|
|
309
320
|
this.userId = userId;
|
|
310
321
|
}
|
|
311
322
|
}
|
|
@@ -362,18 +373,18 @@ class Card {
|
|
|
362
373
|
updatedAt,
|
|
363
374
|
userId,
|
|
364
375
|
}) {
|
|
365
|
-
this.createdAt =
|
|
376
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
366
377
|
this.cvv2 = cvv2;
|
|
367
378
|
this.expMonth = expMonth;
|
|
368
379
|
this.expYear = expYear;
|
|
369
|
-
this.fundingType =
|
|
380
|
+
this.fundingType = base.enumValueFromString(identities.CardFundingType, fundingType);
|
|
370
381
|
this.id = id;
|
|
371
|
-
this.issuer =
|
|
382
|
+
this.issuer = base.enumValueFromString(identities.CardIssuer, issuer);
|
|
372
383
|
this.number = number;
|
|
373
384
|
this.pin = pin;
|
|
374
|
-
this.status =
|
|
375
|
-
this.type =
|
|
376
|
-
this.updatedAt =
|
|
385
|
+
this.status = base.enumValueFromString(identities.CardStatus, status);
|
|
386
|
+
this.type = base.enumValueFromString(identities.CardType, type);
|
|
387
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
377
388
|
this.userId = userId;
|
|
378
389
|
}
|
|
379
390
|
|
|
@@ -407,7 +418,7 @@ class Card {
|
|
|
407
418
|
class CardActivation {
|
|
408
419
|
constructor({ cardUri, createdAt, id, ipAddress, success, userId }) {
|
|
409
420
|
this.cardUri = cardUri;
|
|
410
|
-
this.createdAt =
|
|
421
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
411
422
|
this.id = id;
|
|
412
423
|
this.ipAddress = ipAddress;
|
|
413
424
|
this.success = success;
|
|
@@ -448,14 +459,14 @@ class CardTransaction extends Transaction {
|
|
|
448
459
|
status,
|
|
449
460
|
userId,
|
|
450
461
|
});
|
|
451
|
-
this.cardErrorType =
|
|
462
|
+
this.cardErrorType = base.enumValueFromString(identities.CardErrorType, cardErrorType);
|
|
452
463
|
this.cardLastFour = cardLastFour;
|
|
453
|
-
this.cardType =
|
|
464
|
+
this.cardType = base.enumValueFromString(identities.CardType, cardType);
|
|
454
465
|
this.cardUri = cardUri;
|
|
455
466
|
this.metadata = metadata;
|
|
456
467
|
this.network = network;
|
|
457
468
|
this.relatedCardTransactionsUris = relatedCardTransactionsUris;
|
|
458
|
-
this.type =
|
|
469
|
+
this.type = base.enumValueFromString(identities.CardTransactionType, type);
|
|
459
470
|
}
|
|
460
471
|
|
|
461
472
|
static fromObject = ({
|
|
@@ -499,10 +510,10 @@ class CardValidation {
|
|
|
499
510
|
isValidPinBlock,
|
|
500
511
|
userId,
|
|
501
512
|
}) {
|
|
502
|
-
this.cardStatus =
|
|
503
|
-
this.cardType =
|
|
513
|
+
this.cardStatus = base.enumValueFromString(identities.CardStatus, cardStatus);
|
|
514
|
+
this.cardType = base.enumValueFromString(identities.CardType, cardType);
|
|
504
515
|
this.cardUri = cardUri;
|
|
505
|
-
this.createdAt =
|
|
516
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
506
517
|
this.isExpired = isExpired;
|
|
507
518
|
this.isPinAttemptsExceeded = isPinAttemptsExceeded;
|
|
508
519
|
this.isValidCvv = isValidCvv;
|
|
@@ -552,7 +563,7 @@ class Commission extends Transaction {
|
|
|
552
563
|
userId,
|
|
553
564
|
});
|
|
554
565
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
555
|
-
this.type =
|
|
566
|
+
this.type = base.enumValueFromString(identities.CommissionType, type);
|
|
556
567
|
}
|
|
557
568
|
|
|
558
569
|
static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
|
|
@@ -587,7 +598,7 @@ class Deposit extends Transaction {
|
|
|
587
598
|
userId,
|
|
588
599
|
});
|
|
589
600
|
this.id = id;
|
|
590
|
-
this.network =
|
|
601
|
+
this.network = base.enumValueFromString(identities.DepositNetwork, network);
|
|
591
602
|
this.sourceUri = sourceUri;
|
|
592
603
|
this.trackingKey = trackingKey;
|
|
593
604
|
}
|
|
@@ -617,11 +628,11 @@ class LoginToken {
|
|
|
617
628
|
class Wallet {
|
|
618
629
|
constructor({ balance, createdAt, deactivatedAt, id, userId, updatedAt }) {
|
|
619
630
|
this.balance = balance;
|
|
620
|
-
this.createdAt =
|
|
621
|
-
this.deactivatedAt =
|
|
631
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
632
|
+
this.deactivatedAt = base.dateToUTC(deactivatedAt);
|
|
622
633
|
this.id = id;
|
|
623
634
|
this.userId = userId;
|
|
624
|
-
this.updatedAt =
|
|
635
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
625
636
|
}
|
|
626
637
|
}
|
|
627
638
|
|
|
@@ -646,9 +657,9 @@ class Saving extends Wallet {
|
|
|
646
657
|
userId,
|
|
647
658
|
updatedAt,
|
|
648
659
|
});
|
|
649
|
-
this.category =
|
|
660
|
+
this.category = base.enumValueFromString(identities.SavingCategory, category);
|
|
650
661
|
this.goalAmount = goalAmount;
|
|
651
|
-
this.goalDate =
|
|
662
|
+
this.goalDate = base.dateToUTC(goalDate);
|
|
652
663
|
this.name = name;
|
|
653
664
|
}
|
|
654
665
|
|
|
@@ -670,7 +681,7 @@ class Saving extends Wallet {
|
|
|
670
681
|
const categoriesFromString = (categoriesList) => {
|
|
671
682
|
if (categoriesList == null) return [];
|
|
672
683
|
return categoriesList.map((category) =>
|
|
673
|
-
|
|
684
|
+
base.enumValueFromString(identities.ServiceProviderCategory, category),
|
|
674
685
|
);
|
|
675
686
|
};
|
|
676
687
|
|
|
@@ -693,7 +704,7 @@ class ServiceProvider {
|
|
|
693
704
|
|
|
694
705
|
class Statement {
|
|
695
706
|
constructor({ createdAt, id, month, year }) {
|
|
696
|
-
this.createdAt =
|
|
707
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
697
708
|
this.id = id;
|
|
698
709
|
this.month = month;
|
|
699
710
|
this.year = year;
|
|
@@ -735,10 +746,10 @@ class Transfer extends Transaction {
|
|
|
735
746
|
this.destinationUri = destinationUri;
|
|
736
747
|
this.id = id;
|
|
737
748
|
this.idempotencyKey = idempotencyKey;
|
|
738
|
-
this.network =
|
|
749
|
+
this.network = base.enumValueFromString(identities.TransferNetwork, network);
|
|
739
750
|
this.recipientName = recipientName;
|
|
740
751
|
this.trackingKey = trackingKey;
|
|
741
|
-
this.updatedAt =
|
|
752
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
742
753
|
}
|
|
743
754
|
|
|
744
755
|
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
@@ -760,22 +771,36 @@ class Transfer extends Transaction {
|
|
|
760
771
|
}
|
|
761
772
|
|
|
762
773
|
class User {
|
|
763
|
-
constructor({
|
|
774
|
+
constructor({
|
|
775
|
+
emailAddress,
|
|
776
|
+
phoneNumber,
|
|
777
|
+
status,
|
|
778
|
+
termsOfService,
|
|
779
|
+
verificationId,
|
|
780
|
+
}) {
|
|
781
|
+
this.emailAddress = emailAddress;
|
|
782
|
+
this.phoneNumber = phoneNumber;
|
|
783
|
+
this.status = base.enumValueFromString(identities.UserStatus, status);
|
|
764
784
|
this.termsOfService = identities.TOSAgreements.fromObject(termsOfService);
|
|
785
|
+
this.verificationId = verificationId;
|
|
765
786
|
}
|
|
766
787
|
|
|
767
788
|
static fromObject = ({ ...obj }) =>
|
|
768
789
|
new User({
|
|
790
|
+
emailAddress: obj.email_address,
|
|
791
|
+
phoneNumber: obj.phone_number,
|
|
792
|
+
status: obj.status,
|
|
769
793
|
termsOfService: obj.terms_of_service,
|
|
794
|
+
verificationId: obj.verification_id,
|
|
770
795
|
});
|
|
771
796
|
}
|
|
772
797
|
|
|
773
798
|
class UserCredential {
|
|
774
799
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
775
|
-
this.createdAt =
|
|
800
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
776
801
|
this.id = id;
|
|
777
802
|
this.isActive = isActive;
|
|
778
|
-
this.updatedAt =
|
|
803
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
779
804
|
}
|
|
780
805
|
|
|
781
806
|
static fromObject = ({ id, ...obj }) =>
|
|
@@ -790,7 +815,7 @@ class UserCredential {
|
|
|
790
815
|
class UserLogin {
|
|
791
816
|
constructor({ id, lastLoginAt, success }) {
|
|
792
817
|
this.id = id;
|
|
793
|
-
this.lastLoginAt =
|
|
818
|
+
this.lastLoginAt = base.dateToUTC(lastLoginAt);
|
|
794
819
|
this.success = success;
|
|
795
820
|
}
|
|
796
821
|
|
|
@@ -821,7 +846,7 @@ class WalletTransaction extends Transaction {
|
|
|
821
846
|
userId,
|
|
822
847
|
});
|
|
823
848
|
this.id = id;
|
|
824
|
-
this.transactionType =
|
|
849
|
+
this.transactionType = base.enumValueFromString(
|
|
825
850
|
identities.WalletTransactionType,
|
|
826
851
|
transactionType,
|
|
827
852
|
);
|
|
@@ -868,12 +893,12 @@ class WhatsAppTransfer extends Transaction {
|
|
|
868
893
|
this.claimUrl = claimUrl;
|
|
869
894
|
this.destinationUri = destinationUri;
|
|
870
895
|
this.id = id;
|
|
871
|
-
this.expiresAt =
|
|
872
|
-
this.network =
|
|
896
|
+
this.expiresAt = base.dateToUTC(expiresAt);
|
|
897
|
+
this.network = base.enumValueFromString(identities.TransferNetwork, network);
|
|
873
898
|
this.phoneNumber = phoneNumber;
|
|
874
899
|
this.recipientName = recipientName;
|
|
875
900
|
this.trackingKey = trackingKey;
|
|
876
|
-
this.updatedAt =
|
|
901
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
877
902
|
}
|
|
878
903
|
|
|
879
904
|
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
@@ -1065,7 +1090,7 @@ const Queryable = (SuperClass) =>
|
|
|
1065
1090
|
|
|
1066
1091
|
class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1067
1092
|
constructor(client) {
|
|
1068
|
-
super('accounts',
|
|
1093
|
+
super('accounts', identities.AccountQuery, client);
|
|
1069
1094
|
}
|
|
1070
1095
|
}
|
|
1071
1096
|
|
|
@@ -1077,7 +1102,7 @@ class ApiKeyResource extends mix(Resource).with(
|
|
|
1077
1102
|
Updateable,
|
|
1078
1103
|
) {
|
|
1079
1104
|
constructor(client) {
|
|
1080
|
-
super('api_keys',
|
|
1105
|
+
super('api_keys', identities.ApiKeyQuery, client);
|
|
1081
1106
|
}
|
|
1082
1107
|
|
|
1083
1108
|
async create() {
|
|
@@ -1131,7 +1156,7 @@ class ArpcResource extends mix(Resource).with(Creatable) {
|
|
|
1131
1156
|
|
|
1132
1157
|
class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1133
1158
|
constructor(client) {
|
|
1134
|
-
super('balance_entries',
|
|
1159
|
+
super('balance_entries', identities.BalanceEntryQuery, client);
|
|
1135
1160
|
}
|
|
1136
1161
|
|
|
1137
1162
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1157,7 +1182,7 @@ class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1157
1182
|
|
|
1158
1183
|
class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1159
1184
|
constructor(client) {
|
|
1160
|
-
super('bill_payments',
|
|
1185
|
+
super('bill_payments', identities.BillPaymentQuery, client);
|
|
1161
1186
|
}
|
|
1162
1187
|
|
|
1163
1188
|
async serviceProvider(providerUri) {
|
|
@@ -1195,7 +1220,7 @@ class CardResource extends mix(Resource).with(
|
|
|
1195
1220
|
Updateable,
|
|
1196
1221
|
) {
|
|
1197
1222
|
constructor(client) {
|
|
1198
|
-
super('cards',
|
|
1223
|
+
super('cards', identities.CardsQuery, client);
|
|
1199
1224
|
}
|
|
1200
1225
|
|
|
1201
1226
|
async create(userId, issuer, fundingType) {
|
|
@@ -1221,7 +1246,7 @@ class CardTransactionResource extends mix(Resource).with(
|
|
|
1221
1246
|
Retrievable,
|
|
1222
1247
|
) {
|
|
1223
1248
|
constructor(client) {
|
|
1224
|
-
super('card_transactions',
|
|
1249
|
+
super('card_transactions', identities.CardTransactionQuery, client);
|
|
1225
1250
|
}
|
|
1226
1251
|
|
|
1227
1252
|
async relatedCard(relatedCardUri) {
|
|
@@ -1273,7 +1298,7 @@ class CardValidationResource extends mix(Resource).with(Creatable) {
|
|
|
1273
1298
|
|
|
1274
1299
|
class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1275
1300
|
constructor(client) {
|
|
1276
|
-
super('commissions',
|
|
1301
|
+
super('commissions', identities.QueryParams, client);
|
|
1277
1302
|
}
|
|
1278
1303
|
|
|
1279
1304
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1287,7 +1312,7 @@ class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1287
1312
|
|
|
1288
1313
|
class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1289
1314
|
constructor(client) {
|
|
1290
|
-
super('deposits',
|
|
1315
|
+
super('deposits', identities.DepositQuery, client);
|
|
1291
1316
|
}
|
|
1292
1317
|
|
|
1293
1318
|
async source(sourceUri) {
|
|
@@ -1315,7 +1340,7 @@ class SavingResource extends mix(Resource).with(
|
|
|
1315
1340
|
Updateable,
|
|
1316
1341
|
) {
|
|
1317
1342
|
constructor(client) {
|
|
1318
|
-
super('savings',
|
|
1343
|
+
super('savings', identities.WalletQuery, client);
|
|
1319
1344
|
}
|
|
1320
1345
|
|
|
1321
1346
|
async create(category, goalAmount, goalDate, name) {
|
|
@@ -1341,13 +1366,13 @@ class ServiceProviderResource extends mix(Resource).with(
|
|
|
1341
1366
|
Retrievable,
|
|
1342
1367
|
) {
|
|
1343
1368
|
constructor(client) {
|
|
1344
|
-
super('service_providers',
|
|
1369
|
+
super('service_providers', identities.QueryParams, client);
|
|
1345
1370
|
}
|
|
1346
1371
|
}
|
|
1347
1372
|
|
|
1348
1373
|
class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
|
|
1349
1374
|
constructor(client) {
|
|
1350
|
-
super('statements',
|
|
1375
|
+
super('statements', identities.StatementQuery, client);
|
|
1351
1376
|
}
|
|
1352
1377
|
|
|
1353
1378
|
async pdf(id) {
|
|
@@ -1367,7 +1392,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1367
1392
|
Retrievable,
|
|
1368
1393
|
) {
|
|
1369
1394
|
constructor(client) {
|
|
1370
|
-
super('transfers',
|
|
1395
|
+
super('transfers', identities.TransferQuery, client);
|
|
1371
1396
|
}
|
|
1372
1397
|
|
|
1373
1398
|
async destination(destinationUri) {
|
|
@@ -1435,7 +1460,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1435
1460
|
}
|
|
1436
1461
|
|
|
1437
1462
|
static _genIdempotencyKey(accountNumber, amount) {
|
|
1438
|
-
const [date] =
|
|
1463
|
+
const [date] = base.dateToUTC(Date.now()).toISOString().split('T');
|
|
1439
1464
|
return `${date}:${accountNumber}:${amount}`;
|
|
1440
1465
|
}
|
|
1441
1466
|
}
|
|
@@ -1487,13 +1512,13 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1487
1512
|
}
|
|
1488
1513
|
}
|
|
1489
1514
|
|
|
1490
|
-
class UserResourse extends mix(Resource).with(Updateable) {
|
|
1515
|
+
class UserResourse extends mix(Resource).with(Queryable, Updateable) {
|
|
1491
1516
|
constructor(client) {
|
|
1492
|
-
super('
|
|
1517
|
+
super('users', identities.UserQuery, client);
|
|
1493
1518
|
}
|
|
1494
1519
|
|
|
1495
|
-
async update({ termsOfService, userId = 'me' }) {
|
|
1496
|
-
const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService });
|
|
1520
|
+
async update({ termsOfService, userId = 'me', verificationId }) {
|
|
1521
|
+
const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService, verificationId });
|
|
1497
1522
|
const user = await this._update(userId, request.toCleanObject());
|
|
1498
1523
|
return user;
|
|
1499
1524
|
}
|
|
@@ -1505,7 +1530,7 @@ class WalletTransactionsResource extends mix(Resource).with(
|
|
|
1505
1530
|
Retrievable,
|
|
1506
1531
|
) {
|
|
1507
1532
|
constructor(client) {
|
|
1508
|
-
super('wallet_transactions',
|
|
1533
|
+
super('wallet_transactions', identities.WalletTransactionQuery, client);
|
|
1509
1534
|
}
|
|
1510
1535
|
|
|
1511
1536
|
async create(amount, transactionType, walletUri) {
|
|
@@ -1532,7 +1557,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1532
1557
|
Retrievable,
|
|
1533
1558
|
) {
|
|
1534
1559
|
constructor(client) {
|
|
1535
|
-
super('whatsapp_transfers',
|
|
1560
|
+
super('whatsapp_transfers', identities.QueryParams, client);
|
|
1536
1561
|
}
|
|
1537
1562
|
|
|
1538
1563
|
async accountDestination(destinationUri) {
|
|
@@ -1566,8 +1591,8 @@ class Cuenca {
|
|
|
1566
1591
|
this.serviceProviders = new ServiceProviderResource(client);
|
|
1567
1592
|
this.statements = new StatementResource(client);
|
|
1568
1593
|
this.transfers = new TransferResource(client);
|
|
1569
|
-
this.userCredentials = new UserCredentialResource(client);
|
|
1570
1594
|
this.users = new UserResourse(client);
|
|
1595
|
+
this.userCredentials = new UserCredentialResource(client);
|
|
1571
1596
|
this.userLogins = new UserLoginResource(client);
|
|
1572
1597
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1573
1598
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
package/build/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import axios from 'axios';
|
|
|
2
2
|
import Buffer from 'buffer';
|
|
3
3
|
import { CuencaResponseException, CuencaException, NoResultFound, MultipleResultsFound, InvalidPassword } from './errors/index.mjs';
|
|
4
4
|
import { Jwt } from './jwt/index.mjs';
|
|
5
|
-
import { P as Phase, F as FileFormat,
|
|
6
|
-
import {
|
|
7
|
-
import { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, g as UserUpdateRequest, W as WalletTransactionRequest } from './walletTransactionRequest-
|
|
5
|
+
import { P as Phase, F as FileFormat, E as EntryType, T as TransactionStatus, C as CardIssuer, a as CardStatus, b as CardType, c as CardFundingType, d as CardErrorType, e as CardTransactionType, f as CommissionType, D as DepositNetwork, S as SavingCategory, g as ServiceProviderCategory, h as TransferNetwork, U as UserStatus, i as TOSAgreements, W as WalletTransactionType, A as AccountQuery, j as ApiKeyQuery, B as BalanceEntryQuery, k as BillPaymentQuery, l as CardsQuery, m as CardTransactionQuery, Q as QueryParams, n as DepositQuery, o as WalletQuery, p as StatementQuery, q as TransferQuery, r as UserQuery, s as WalletTransactionQuery } from './identities-73634653.mjs';
|
|
6
|
+
import { d as dateToUTC, e as enumValueFromString } from './base-c1f04b51.mjs';
|
|
7
|
+
import { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, g as UserUpdateRequest, W as WalletTransactionRequest } from './walletTransactionRequest-8b125547.mjs';
|
|
8
8
|
|
|
9
9
|
/* global window */
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ const isNode =
|
|
|
17
17
|
|
|
18
18
|
const runtimeEnv = { isBrowser, isNode };
|
|
19
19
|
|
|
20
|
-
const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.
|
|
20
|
+
const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.26";const description="Cuenca client for JS";const main="./build/index.cjs";const module="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports={".":{"import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{"import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{"import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{"import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{"import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.0.2";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const scripts={build:"rm -rf build/ && yarn rollup --config",test:"yarn node --experimental-vm-modules $(yarn bin jest)",publish:"yarn build && yarn npm publish"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1",jest:"^27.4.5",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2"};const dependencies={axios:"^0.24.0",buffer:"^6.0.3"};var pkg = {name:name,version:version,description:description,main:main,module:module,browser:browser,files:files,exports:exports,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
|
|
21
21
|
|
|
22
22
|
class Client {
|
|
23
23
|
constructor({ apiKey, apiSecret, phase = Phase.Sandbox } = {}) {
|
|
@@ -86,7 +86,14 @@ class Client {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
async configure({
|
|
89
|
+
async configure({
|
|
90
|
+
apiKey,
|
|
91
|
+
apiSecret,
|
|
92
|
+
loginToken,
|
|
93
|
+
phase,
|
|
94
|
+
sessionId,
|
|
95
|
+
useJwt = false,
|
|
96
|
+
}) {
|
|
90
97
|
this.basicAuth = {
|
|
91
98
|
apiKey: apiKey || this.basicAuth.apiKey,
|
|
92
99
|
apiSecret: apiSecret || this.basicAuth.apiSecret,
|
|
@@ -99,6 +106,10 @@ class Client {
|
|
|
99
106
|
if (loginToken) {
|
|
100
107
|
this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
|
|
101
108
|
}
|
|
109
|
+
|
|
110
|
+
if (sessionId) {
|
|
111
|
+
this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
|
|
112
|
+
}
|
|
102
113
|
}
|
|
103
114
|
|
|
104
115
|
async get({ endpoint, format, params }) {
|
|
@@ -751,13 +762,27 @@ class Transfer extends Transaction {
|
|
|
751
762
|
}
|
|
752
763
|
|
|
753
764
|
class User {
|
|
754
|
-
constructor({
|
|
765
|
+
constructor({
|
|
766
|
+
emailAddress,
|
|
767
|
+
phoneNumber,
|
|
768
|
+
status,
|
|
769
|
+
termsOfService,
|
|
770
|
+
verificationId,
|
|
771
|
+
}) {
|
|
772
|
+
this.emailAddress = emailAddress;
|
|
773
|
+
this.phoneNumber = phoneNumber;
|
|
774
|
+
this.status = enumValueFromString(UserStatus, status);
|
|
755
775
|
this.termsOfService = TOSAgreements.fromObject(termsOfService);
|
|
776
|
+
this.verificationId = verificationId;
|
|
756
777
|
}
|
|
757
778
|
|
|
758
779
|
static fromObject = ({ ...obj }) =>
|
|
759
780
|
new User({
|
|
781
|
+
emailAddress: obj.email_address,
|
|
782
|
+
phoneNumber: obj.phone_number,
|
|
783
|
+
status: obj.status,
|
|
760
784
|
termsOfService: obj.terms_of_service,
|
|
785
|
+
verificationId: obj.verification_id,
|
|
761
786
|
});
|
|
762
787
|
}
|
|
763
788
|
|
|
@@ -1478,13 +1503,13 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1478
1503
|
}
|
|
1479
1504
|
}
|
|
1480
1505
|
|
|
1481
|
-
class UserResourse extends mix(Resource).with(Updateable) {
|
|
1506
|
+
class UserResourse extends mix(Resource).with(Queryable, Updateable) {
|
|
1482
1507
|
constructor(client) {
|
|
1483
|
-
super('
|
|
1508
|
+
super('users', UserQuery, client);
|
|
1484
1509
|
}
|
|
1485
1510
|
|
|
1486
|
-
async update({ termsOfService, userId = 'me' }) {
|
|
1487
|
-
const request = new UserUpdateRequest({ termsOfService });
|
|
1511
|
+
async update({ termsOfService, userId = 'me', verificationId }) {
|
|
1512
|
+
const request = new UserUpdateRequest({ termsOfService, verificationId });
|
|
1488
1513
|
const user = await this._update(userId, request.toCleanObject());
|
|
1489
1514
|
return user;
|
|
1490
1515
|
}
|
|
@@ -1557,8 +1582,8 @@ class Cuenca {
|
|
|
1557
1582
|
this.serviceProviders = new ServiceProviderResource(client);
|
|
1558
1583
|
this.statements = new StatementResource(client);
|
|
1559
1584
|
this.transfers = new TransferResource(client);
|
|
1560
|
-
this.userCredentials = new UserCredentialResource(client);
|
|
1561
1585
|
this.users = new UserResourse(client);
|
|
1586
|
+
this.userCredentials = new UserCredentialResource(client);
|
|
1562
1587
|
this.userLogins = new UserLoginResource(client);
|
|
1563
1588
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1564
1589
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
package/build/requests/index.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var walletTransactionRequest = require('../walletTransactionRequest-
|
|
5
|
+
var walletTransactionRequest = require('../walletTransactionRequest-bda66da3.cjs');
|
|
6
|
+
require('../base-80b9a673.cjs');
|
|
6
7
|
require('../errors/index.cjs');
|
|
7
|
-
require('../identities-b7106a30.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -15,6 +15,7 @@ exports.CardRequest = walletTransactionRequest.CardRequest;
|
|
|
15
15
|
exports.CardUpdateRequest = walletTransactionRequest.CardUpdateRequest;
|
|
16
16
|
exports.CardValidationRequest = walletTransactionRequest.CardValidationRequest;
|
|
17
17
|
exports.SavingRequest = walletTransactionRequest.SavingRequest;
|
|
18
|
+
exports.TosUpdateRequest = walletTransactionRequest.TosUpdateRequest;
|
|
18
19
|
exports.TransferRequest = walletTransactionRequest.TransferRequest;
|
|
19
20
|
exports.UserCredentialRequest = walletTransactionRequest.UserCredentialRequest;
|
|
20
21
|
exports.UserCredentialUpdateRequest = walletTransactionRequest.UserCredentialUpdateRequest;
|
package/build/requests/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, g as UserUpdateRequest, W as WalletTransactionRequest } from '../walletTransactionRequest-
|
|
1
|
+
export { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, h as TosUpdateRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, g as UserUpdateRequest, W as WalletTransactionRequest } from '../walletTransactionRequest-8b125547.mjs';
|
|
2
|
+
import '../base-c1f04b51.mjs';
|
|
2
3
|
import '../errors/index.mjs';
|
|
3
|
-
import '../identities-7fc7251d.mjs';
|