@cuenca-mx/cuenca-js 0.0.1-dev.3 → 0.0.1-dev.32
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 +157 -2
- package/build/{data-c53f1052.js → data-9edbb2a0.cjs} +2 -3
- package/build/{data-7d3d5fcc.js → data-d5bcb7c8.mjs} +2 -3
- package/build/errors/{index.js → index.cjs} +0 -0
- package/build/{queries-b8f29837.js → identities-31dcced0.cjs} +51 -2
- package/build/{queries-f146b91b.js → identities-f6558f98.mjs} +48 -2
- package/build/{index.js → index.cjs} +193 -93
- package/build/index.mjs +152 -18
- package/build/jwt/{index.js → index.cjs} +7 -2
- package/build/jwt/index.mjs +2 -1
- package/build/requests/{index.js → index.cjs} +4 -3
- package/build/requests/index.mjs +2 -2
- package/build/types/index.cjs +43 -0
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-bbfb87bd.js → walletTransactionRequest-4e6b348f.mjs} +62 -2
- package/build/{walletTransactionRequest-b588cc52.js → walletTransactionRequest-572c455b.cjs} +63 -2
- package/package.json +27 -4
- package/build/types/index.js +0 -40
|
@@ -3,18 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var axios = require('axios');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
6
|
+
var Buffer = require('buffer');
|
|
7
|
+
var errors_index = require('./errors/index.cjs');
|
|
8
|
+
var jwt_index = require('./jwt/index.cjs');
|
|
9
|
+
var identities = require('./identities-31dcced0.cjs');
|
|
10
|
+
var data = require('./data-9edbb2a0.cjs');
|
|
11
|
+
var walletTransactionRequest = require('./walletTransactionRequest-572c455b.cjs');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
14
|
|
|
14
15
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
16
|
+
var Buffer__default = /*#__PURE__*/_interopDefaultLegacy(Buffer);
|
|
17
|
+
|
|
18
|
+
/* global window */
|
|
19
|
+
|
|
20
|
+
const isBrowser =
|
|
21
|
+
typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
22
|
+
|
|
23
|
+
const isNode =
|
|
24
|
+
typeof process !== 'undefined' &&
|
|
25
|
+
Object.prototype.toString.call(process) === '[object process]';
|
|
26
|
+
|
|
27
|
+
const runtimeEnv = { isBrowser, isNode };
|
|
28
|
+
|
|
29
|
+
const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.32";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};
|
|
15
30
|
|
|
16
31
|
class Client {
|
|
17
|
-
constructor({ apiKey, apiSecret, phase =
|
|
32
|
+
constructor({ apiKey, apiSecret, phase = identities.Phase.Sandbox } = {}) {
|
|
18
33
|
this.phase = phase;
|
|
19
34
|
this.basicAuth = { apiKey, apiSecret };
|
|
20
35
|
this.jwtToken = null;
|
|
@@ -32,8 +47,9 @@ class Client {
|
|
|
32
47
|
get authHeader() {
|
|
33
48
|
const { apiKey, apiSecret } = this.basicAuth;
|
|
34
49
|
if (!apiKey || !apiSecret) return '';
|
|
35
|
-
return `Basic ${Buffer.from(
|
|
36
|
-
|
|
50
|
+
return `Basic ${Buffer__default["default"].Buffer.from(
|
|
51
|
+
`${apiKey}:${apiSecret}`,
|
|
52
|
+
'utf-8',
|
|
37
53
|
).toString('base64')}`;
|
|
38
54
|
}
|
|
39
55
|
|
|
@@ -79,7 +95,14 @@ class Client {
|
|
|
79
95
|
};
|
|
80
96
|
}
|
|
81
97
|
|
|
82
|
-
async configure({
|
|
98
|
+
async configure({
|
|
99
|
+
apiKey,
|
|
100
|
+
apiSecret,
|
|
101
|
+
loginToken,
|
|
102
|
+
phase,
|
|
103
|
+
sessionId,
|
|
104
|
+
useJwt = false,
|
|
105
|
+
}) {
|
|
83
106
|
this.basicAuth = {
|
|
84
107
|
apiKey: apiKey || this.basicAuth.apiKey,
|
|
85
108
|
apiSecret: apiSecret || this.basicAuth.apiSecret,
|
|
@@ -92,6 +115,10 @@ class Client {
|
|
|
92
115
|
if (loginToken) {
|
|
93
116
|
this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
|
|
94
117
|
}
|
|
118
|
+
|
|
119
|
+
if (sessionId) {
|
|
120
|
+
this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
|
|
121
|
+
}
|
|
95
122
|
}
|
|
96
123
|
|
|
97
124
|
async get({ endpoint, format, params }) {
|
|
@@ -113,17 +140,24 @@ class Client {
|
|
|
113
140
|
async request({
|
|
114
141
|
endpoint,
|
|
115
142
|
data = null,
|
|
116
|
-
format =
|
|
143
|
+
format = identities.FileFormat.Json,
|
|
117
144
|
method = 'GET',
|
|
118
145
|
params = null,
|
|
119
146
|
}) {
|
|
120
147
|
const headers = {
|
|
121
148
|
Authorization: this.authHeader,
|
|
122
|
-
'X-User-Agent': `cuenca-js/0.0.1`, // TODO: Change for client version
|
|
123
149
|
'Content-Type': 'application/json',
|
|
124
150
|
Accept: `application/${format.value}`,
|
|
125
151
|
};
|
|
126
152
|
|
|
153
|
+
if (runtimeEnv.isNode) {
|
|
154
|
+
headers['User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
155
|
+
} else if (runtimeEnv.isBrowser) {
|
|
156
|
+
// Cannot set User-Agent header on browsers
|
|
157
|
+
// https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
|
|
158
|
+
headers['X-User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
159
|
+
}
|
|
160
|
+
|
|
127
161
|
if (this.jwtToken) {
|
|
128
162
|
if (this.jwtToken.isExpired) {
|
|
129
163
|
this.jwtToken = await jwt_index.Jwt.create(this);
|
|
@@ -255,7 +289,7 @@ class BalanceEntry {
|
|
|
255
289
|
this.amount = amount;
|
|
256
290
|
this.createdAt = data.dateToUTC(createdAt);
|
|
257
291
|
this.descriptor = descriptor;
|
|
258
|
-
this.entryType = data.enumValueFromString(
|
|
292
|
+
this.entryType = data.enumValueFromString(identities.EntryType, entryType);
|
|
259
293
|
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
260
294
|
this.id = id;
|
|
261
295
|
this.name = name;
|
|
@@ -282,7 +316,7 @@ class Transaction {
|
|
|
282
316
|
this.amount = amount;
|
|
283
317
|
this.createdAt = data.dateToUTC(createdAt);
|
|
284
318
|
this.descriptor = descriptor;
|
|
285
|
-
this.status = data.enumValueFromString(
|
|
319
|
+
this.status = data.enumValueFromString(identities.TransactionStatus, status);
|
|
286
320
|
this.userId = userId;
|
|
287
321
|
}
|
|
288
322
|
}
|
|
@@ -298,7 +332,13 @@ class BillPayment extends Transaction {
|
|
|
298
332
|
status,
|
|
299
333
|
userId,
|
|
300
334
|
}) {
|
|
301
|
-
super({
|
|
335
|
+
super({
|
|
336
|
+
amount,
|
|
337
|
+
createdAt,
|
|
338
|
+
descriptor,
|
|
339
|
+
status,
|
|
340
|
+
userId,
|
|
341
|
+
});
|
|
302
342
|
this.accountNumber = accountNumber;
|
|
303
343
|
this.id = id;
|
|
304
344
|
this.providerUri = providerUri;
|
|
@@ -337,13 +377,13 @@ class Card {
|
|
|
337
377
|
this.cvv2 = cvv2;
|
|
338
378
|
this.expMonth = expMonth;
|
|
339
379
|
this.expYear = expYear;
|
|
340
|
-
this.fundingType = data.enumValueFromString(
|
|
380
|
+
this.fundingType = data.enumValueFromString(identities.CardFundingType, fundingType);
|
|
341
381
|
this.id = id;
|
|
342
|
-
this.issuer = data.enumValueFromString(
|
|
382
|
+
this.issuer = data.enumValueFromString(identities.CardIssuer, issuer);
|
|
343
383
|
this.number = number;
|
|
344
384
|
this.pin = pin;
|
|
345
|
-
this.status = data.enumValueFromString(
|
|
346
|
-
this.type = data.enumValueFromString(
|
|
385
|
+
this.status = data.enumValueFromString(identities.CardStatus, status);
|
|
386
|
+
this.type = data.enumValueFromString(identities.CardType, type);
|
|
347
387
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
348
388
|
this.userId = userId;
|
|
349
389
|
}
|
|
@@ -412,15 +452,21 @@ class CardTransaction extends Transaction {
|
|
|
412
452
|
type,
|
|
413
453
|
userId,
|
|
414
454
|
}) {
|
|
415
|
-
super({
|
|
416
|
-
|
|
455
|
+
super({
|
|
456
|
+
amount,
|
|
457
|
+
createdAt,
|
|
458
|
+
descriptor,
|
|
459
|
+
status,
|
|
460
|
+
userId,
|
|
461
|
+
});
|
|
462
|
+
this.cardErrorType = data.enumValueFromString(identities.CardErrorType, cardErrorType);
|
|
417
463
|
this.cardLastFour = cardLastFour;
|
|
418
|
-
this.cardType = data.enumValueFromString(
|
|
464
|
+
this.cardType = data.enumValueFromString(identities.CardType, cardType);
|
|
419
465
|
this.cardUri = cardUri;
|
|
420
466
|
this.metadata = metadata;
|
|
421
467
|
this.network = network;
|
|
422
468
|
this.relatedCardTransactionsUris = relatedCardTransactionsUris;
|
|
423
|
-
this.type = data.enumValueFromString(
|
|
469
|
+
this.type = data.enumValueFromString(identities.CardTransactionType, type);
|
|
424
470
|
}
|
|
425
471
|
|
|
426
472
|
static fromObject = ({
|
|
@@ -464,8 +510,8 @@ class CardValidation {
|
|
|
464
510
|
isValidPinBlock,
|
|
465
511
|
userId,
|
|
466
512
|
}) {
|
|
467
|
-
this.cardStatus = data.enumValueFromString(
|
|
468
|
-
this.cardType = data.enumValueFromString(
|
|
513
|
+
this.cardStatus = data.enumValueFromString(identities.CardStatus, cardStatus);
|
|
514
|
+
this.cardType = data.enumValueFromString(identities.CardType, cardType);
|
|
469
515
|
this.cardUri = cardUri;
|
|
470
516
|
this.createdAt = data.dateToUTC(createdAt);
|
|
471
517
|
this.isExpired = isExpired;
|
|
@@ -495,7 +541,7 @@ class CardValidation {
|
|
|
495
541
|
});
|
|
496
542
|
|
|
497
543
|
get isActive() {
|
|
498
|
-
return this.cardStatus ===
|
|
544
|
+
return this.cardStatus === identities.CardStatus.Active;
|
|
499
545
|
}
|
|
500
546
|
}
|
|
501
547
|
|
|
@@ -509,9 +555,15 @@ class Commission extends Transaction {
|
|
|
509
555
|
type,
|
|
510
556
|
userId,
|
|
511
557
|
}) {
|
|
512
|
-
super({
|
|
558
|
+
super({
|
|
559
|
+
amount,
|
|
560
|
+
createdAt,
|
|
561
|
+
descriptor,
|
|
562
|
+
status,
|
|
563
|
+
userId,
|
|
564
|
+
});
|
|
513
565
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
514
|
-
this.type = data.enumValueFromString(
|
|
566
|
+
this.type = data.enumValueFromString(identities.CommissionType, type);
|
|
515
567
|
}
|
|
516
568
|
|
|
517
569
|
static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
|
|
@@ -538,9 +590,15 @@ class Deposit extends Transaction {
|
|
|
538
590
|
trackingKey,
|
|
539
591
|
userId,
|
|
540
592
|
}) {
|
|
541
|
-
super({
|
|
593
|
+
super({
|
|
594
|
+
amount,
|
|
595
|
+
createdAt,
|
|
596
|
+
descriptor,
|
|
597
|
+
status,
|
|
598
|
+
userId,
|
|
599
|
+
});
|
|
542
600
|
this.id = id;
|
|
543
|
-
this.network = data.enumValueFromString(
|
|
601
|
+
this.network = data.enumValueFromString(identities.DepositNetwork, network);
|
|
544
602
|
this.sourceUri = sourceUri;
|
|
545
603
|
this.trackingKey = trackingKey;
|
|
546
604
|
}
|
|
@@ -591,8 +649,15 @@ class Saving extends Wallet {
|
|
|
591
649
|
userId,
|
|
592
650
|
updatedAt,
|
|
593
651
|
}) {
|
|
594
|
-
super({
|
|
595
|
-
|
|
652
|
+
super({
|
|
653
|
+
balance,
|
|
654
|
+
createdAt,
|
|
655
|
+
deactivatedAt,
|
|
656
|
+
id,
|
|
657
|
+
userId,
|
|
658
|
+
updatedAt,
|
|
659
|
+
});
|
|
660
|
+
this.category = data.enumValueFromString(identities.SavingCategory, category);
|
|
596
661
|
this.goalAmount = goalAmount;
|
|
597
662
|
this.goalDate = data.dateToUTC(goalDate);
|
|
598
663
|
this.name = name;
|
|
@@ -616,7 +681,7 @@ class Saving extends Wallet {
|
|
|
616
681
|
const categoriesFromString = (categoriesList) => {
|
|
617
682
|
if (categoriesList == null) return [];
|
|
618
683
|
return categoriesList.map((category) =>
|
|
619
|
-
data.enumValueFromString(
|
|
684
|
+
data.enumValueFromString(identities.ServiceProviderCategory, category),
|
|
620
685
|
);
|
|
621
686
|
};
|
|
622
687
|
|
|
@@ -670,12 +735,18 @@ class Transfer extends Transaction {
|
|
|
670
735
|
updatedAt,
|
|
671
736
|
userId,
|
|
672
737
|
}) {
|
|
673
|
-
super({
|
|
738
|
+
super({
|
|
739
|
+
amount,
|
|
740
|
+
createdAt,
|
|
741
|
+
descriptor,
|
|
742
|
+
status,
|
|
743
|
+
userId,
|
|
744
|
+
});
|
|
674
745
|
this.accountNumber = accountNumber;
|
|
675
746
|
this.destinationUri = destinationUri;
|
|
676
747
|
this.id = id;
|
|
677
748
|
this.idempotencyKey = idempotencyKey;
|
|
678
|
-
this.network = data.enumValueFromString(
|
|
749
|
+
this.network = data.enumValueFromString(identities.TransferNetwork, network);
|
|
679
750
|
this.recipientName = recipientName;
|
|
680
751
|
this.trackingKey = trackingKey;
|
|
681
752
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
@@ -699,6 +770,43 @@ class Transfer extends Transaction {
|
|
|
699
770
|
});
|
|
700
771
|
}
|
|
701
772
|
|
|
773
|
+
class User {
|
|
774
|
+
constructor({
|
|
775
|
+
emailAddress,
|
|
776
|
+
level,
|
|
777
|
+
phoneNumber,
|
|
778
|
+
status,
|
|
779
|
+
termsOfService,
|
|
780
|
+
verificationId,
|
|
781
|
+
}) {
|
|
782
|
+
this.emailAddress = emailAddress;
|
|
783
|
+
this.level = level;
|
|
784
|
+
this.phoneNumber = phoneNumber;
|
|
785
|
+
this.status = data.enumValueFromString(identities.UserStatus, status);
|
|
786
|
+
this.terms = termsOfService;
|
|
787
|
+
this.verificationId = verificationId;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
get termsOfService() {
|
|
791
|
+
return this._termsOfService;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
set terms(value) {
|
|
795
|
+
if (!value) return;
|
|
796
|
+
this._termsOfService = identities.TOSAgreements.fromObject(value);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
static fromObject = ({ level, status, ...obj }) =>
|
|
800
|
+
new User({
|
|
801
|
+
level,
|
|
802
|
+
status,
|
|
803
|
+
emailAddress: obj.email_address,
|
|
804
|
+
phoneNumber: obj.phone_number,
|
|
805
|
+
termsOfService: obj.terms_of_service,
|
|
806
|
+
verificationId: obj.verification_id,
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
|
|
702
810
|
class UserCredential {
|
|
703
811
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
704
812
|
this.createdAt = data.dateToUTC(createdAt);
|
|
@@ -742,10 +850,16 @@ class WalletTransaction extends Transaction {
|
|
|
742
850
|
userId,
|
|
743
851
|
walletUri,
|
|
744
852
|
}) {
|
|
745
|
-
super({
|
|
853
|
+
super({
|
|
854
|
+
amount,
|
|
855
|
+
createdAt,
|
|
856
|
+
descriptor,
|
|
857
|
+
status,
|
|
858
|
+
userId,
|
|
859
|
+
});
|
|
746
860
|
this.id = id;
|
|
747
861
|
this.transactionType = data.enumValueFromString(
|
|
748
|
-
|
|
862
|
+
identities.WalletTransactionType,
|
|
749
863
|
transactionType,
|
|
750
864
|
);
|
|
751
865
|
this.walletUri = walletUri;
|
|
@@ -781,12 +895,18 @@ class WhatsAppTransfer extends Transaction {
|
|
|
781
895
|
updatedAt,
|
|
782
896
|
userId,
|
|
783
897
|
}) {
|
|
784
|
-
super({
|
|
898
|
+
super({
|
|
899
|
+
amount,
|
|
900
|
+
createdAt,
|
|
901
|
+
descriptor,
|
|
902
|
+
status,
|
|
903
|
+
userId,
|
|
904
|
+
});
|
|
785
905
|
this.claimUrl = claimUrl;
|
|
786
906
|
this.destinationUri = destinationUri;
|
|
787
907
|
this.id = id;
|
|
788
908
|
this.expiresAt = data.dateToUTC(expiresAt);
|
|
789
|
-
this.network = data.enumValueFromString(
|
|
909
|
+
this.network = data.enumValueFromString(identities.TransferNetwork, network);
|
|
790
910
|
this.phoneNumber = phoneNumber;
|
|
791
911
|
this.recipientName = recipientName;
|
|
792
912
|
this.trackingKey = trackingKey;
|
|
@@ -842,6 +962,7 @@ const getModelFromPath = (path, obj) => {
|
|
|
842
962
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
843
963
|
statements: () => Statement.fromObject(obj),
|
|
844
964
|
transfers: () => Transfer.fromObject(obj),
|
|
965
|
+
users: () => User.fromObject(obj),
|
|
845
966
|
user_credentials: () => UserCredential.fromObject(obj),
|
|
846
967
|
user_logins: () => UserLogin.fromObject(obj),
|
|
847
968
|
wallet_transactions: () => WalletTransaction.fromObject(obj),
|
|
@@ -981,7 +1102,7 @@ const Queryable = (SuperClass) =>
|
|
|
981
1102
|
|
|
982
1103
|
class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
983
1104
|
constructor(client) {
|
|
984
|
-
super('accounts',
|
|
1105
|
+
super('accounts', identities.AccountQuery, client);
|
|
985
1106
|
}
|
|
986
1107
|
}
|
|
987
1108
|
|
|
@@ -993,7 +1114,7 @@ class ApiKeyResource extends mix(Resource).with(
|
|
|
993
1114
|
Updateable,
|
|
994
1115
|
) {
|
|
995
1116
|
constructor(client) {
|
|
996
|
-
super('api_keys',
|
|
1117
|
+
super('api_keys', identities.ApiKeyQuery, client);
|
|
997
1118
|
}
|
|
998
1119
|
|
|
999
1120
|
async create() {
|
|
@@ -1047,7 +1168,7 @@ class ArpcResource extends mix(Resource).with(Creatable) {
|
|
|
1047
1168
|
|
|
1048
1169
|
class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1049
1170
|
constructor(client) {
|
|
1050
|
-
super('balance_entries',
|
|
1171
|
+
super('balance_entries', identities.BalanceEntryQuery, client);
|
|
1051
1172
|
}
|
|
1052
1173
|
|
|
1053
1174
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1073,7 +1194,7 @@ class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1073
1194
|
|
|
1074
1195
|
class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1075
1196
|
constructor(client) {
|
|
1076
|
-
super('bill_payments',
|
|
1197
|
+
super('bill_payments', identities.BillPaymentQuery, client);
|
|
1077
1198
|
}
|
|
1078
1199
|
|
|
1079
1200
|
async serviceProvider(providerUri) {
|
|
@@ -1111,7 +1232,7 @@ class CardResource extends mix(Resource).with(
|
|
|
1111
1232
|
Updateable,
|
|
1112
1233
|
) {
|
|
1113
1234
|
constructor(client) {
|
|
1114
|
-
super('cards',
|
|
1235
|
+
super('cards', identities.CardsQuery, client);
|
|
1115
1236
|
}
|
|
1116
1237
|
|
|
1117
1238
|
async create(userId, issuer, fundingType) {
|
|
@@ -1137,7 +1258,7 @@ class CardTransactionResource extends mix(Resource).with(
|
|
|
1137
1258
|
Retrievable,
|
|
1138
1259
|
) {
|
|
1139
1260
|
constructor(client) {
|
|
1140
|
-
super('card_transactions',
|
|
1261
|
+
super('card_transactions', identities.CardTransactionQuery, client);
|
|
1141
1262
|
}
|
|
1142
1263
|
|
|
1143
1264
|
async relatedCard(relatedCardUri) {
|
|
@@ -1189,7 +1310,7 @@ class CardValidationResource extends mix(Resource).with(Creatable) {
|
|
|
1189
1310
|
|
|
1190
1311
|
class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1191
1312
|
constructor(client) {
|
|
1192
|
-
super('commissions',
|
|
1313
|
+
super('commissions', identities.QueryParams, client);
|
|
1193
1314
|
}
|
|
1194
1315
|
|
|
1195
1316
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1203,7 +1324,7 @@ class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1203
1324
|
|
|
1204
1325
|
class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1205
1326
|
constructor(client) {
|
|
1206
|
-
super('deposits',
|
|
1327
|
+
super('deposits', identities.DepositQuery, client);
|
|
1207
1328
|
}
|
|
1208
1329
|
|
|
1209
1330
|
async source(sourceUri) {
|
|
@@ -1231,7 +1352,7 @@ class SavingResource extends mix(Resource).with(
|
|
|
1231
1352
|
Updateable,
|
|
1232
1353
|
) {
|
|
1233
1354
|
constructor(client) {
|
|
1234
|
-
super('savings',
|
|
1355
|
+
super('savings', identities.WalletQuery, client);
|
|
1235
1356
|
}
|
|
1236
1357
|
|
|
1237
1358
|
async create(category, goalAmount, goalDate, name) {
|
|
@@ -1257,22 +1378,22 @@ class ServiceProviderResource extends mix(Resource).with(
|
|
|
1257
1378
|
Retrievable,
|
|
1258
1379
|
) {
|
|
1259
1380
|
constructor(client) {
|
|
1260
|
-
super('service_providers',
|
|
1381
|
+
super('service_providers', identities.QueryParams, client);
|
|
1261
1382
|
}
|
|
1262
1383
|
}
|
|
1263
1384
|
|
|
1264
1385
|
class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
|
|
1265
1386
|
constructor(client) {
|
|
1266
|
-
super('statements',
|
|
1387
|
+
super('statements', identities.StatementQuery, client);
|
|
1267
1388
|
}
|
|
1268
1389
|
|
|
1269
1390
|
async pdf(id) {
|
|
1270
|
-
const byteString = await this._download(id,
|
|
1391
|
+
const byteString = await this._download(id, identities.FileFormat.Pdf);
|
|
1271
1392
|
return byteString;
|
|
1272
1393
|
}
|
|
1273
1394
|
|
|
1274
1395
|
async xml(id) {
|
|
1275
|
-
const byteString = await this._download(id,
|
|
1396
|
+
const byteString = await this._download(id, identities.FileFormat.Xml);
|
|
1276
1397
|
return byteString;
|
|
1277
1398
|
}
|
|
1278
1399
|
}
|
|
@@ -1283,7 +1404,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1283
1404
|
Retrievable,
|
|
1284
1405
|
) {
|
|
1285
1406
|
constructor(client) {
|
|
1286
|
-
super('transfers',
|
|
1407
|
+
super('transfers', identities.TransferQuery, client);
|
|
1287
1408
|
}
|
|
1288
1409
|
|
|
1289
1410
|
async destination(destinationUri) {
|
|
@@ -1403,13 +1524,29 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1403
1524
|
}
|
|
1404
1525
|
}
|
|
1405
1526
|
|
|
1527
|
+
class UserResourse extends mix(Resource).with(
|
|
1528
|
+
Queryable,
|
|
1529
|
+
Updateable,
|
|
1530
|
+
Retrievable,
|
|
1531
|
+
) {
|
|
1532
|
+
constructor(client) {
|
|
1533
|
+
super('users', identities.UserQuery, client);
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
async update({ termsOfService, verificationId, userId = 'me' }) {
|
|
1537
|
+
const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService, verificationId });
|
|
1538
|
+
const user = await this._update(userId, request.toCleanObject());
|
|
1539
|
+
return user;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1406
1543
|
class WalletTransactionsResource extends mix(Resource).with(
|
|
1407
1544
|
Creatable,
|
|
1408
1545
|
Queryable,
|
|
1409
1546
|
Retrievable,
|
|
1410
1547
|
) {
|
|
1411
1548
|
constructor(client) {
|
|
1412
|
-
super('wallet_transactions',
|
|
1549
|
+
super('wallet_transactions', identities.WalletTransactionQuery, client);
|
|
1413
1550
|
}
|
|
1414
1551
|
|
|
1415
1552
|
async create(amount, transactionType, walletUri) {
|
|
@@ -1436,7 +1573,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1436
1573
|
Retrievable,
|
|
1437
1574
|
) {
|
|
1438
1575
|
constructor(client) {
|
|
1439
|
-
super('whatsapp_transfers',
|
|
1576
|
+
super('whatsapp_transfers', identities.QueryParams, client);
|
|
1440
1577
|
}
|
|
1441
1578
|
|
|
1442
1579
|
async accountDestination(destinationUri) {
|
|
@@ -1449,7 +1586,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1449
1586
|
}
|
|
1450
1587
|
|
|
1451
1588
|
class Cuenca {
|
|
1452
|
-
constructor(apiKey, apiSecret, phase =
|
|
1589
|
+
constructor(apiKey, apiSecret, phase = identities.Phase.Sandbox) {
|
|
1453
1590
|
this.client = new Client({ apiKey, apiSecret, phase });
|
|
1454
1591
|
this.withClient(this.client);
|
|
1455
1592
|
}
|
|
@@ -1472,47 +1609,10 @@ class Cuenca {
|
|
|
1472
1609
|
this.transfers = new TransferResource(client);
|
|
1473
1610
|
this.userCredentials = new UserCredentialResource(client);
|
|
1474
1611
|
this.userLogins = new UserLoginResource(client);
|
|
1612
|
+
this.users = new UserResourse(client);
|
|
1475
1613
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1476
1614
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
|
1477
1615
|
}
|
|
1478
1616
|
}
|
|
1479
1617
|
|
|
1480
|
-
exports.CuencaException = errors_index.CuencaException;
|
|
1481
|
-
exports.CuencaResponseException = errors_index.CuencaResponseException;
|
|
1482
|
-
exports.InvalidPassword = errors_index.InvalidPassword;
|
|
1483
|
-
exports.MalformedJwtToken = errors_index.MalformedJwtToken;
|
|
1484
|
-
exports.MultipleResultsFound = errors_index.MultipleResultsFound;
|
|
1485
|
-
exports.NoResultFound = errors_index.NoResultFound;
|
|
1486
|
-
exports.ValidationError = errors_index.ValidationError;
|
|
1487
|
-
exports.Jwt = jwt_index.Jwt;
|
|
1488
|
-
exports.AccountQuery = queries.AccountQuery;
|
|
1489
|
-
exports.ApiKeyQuery = queries.ApiKeyQuery;
|
|
1490
|
-
exports.BalanceEntryQuery = queries.BalanceEntryQuery;
|
|
1491
|
-
exports.BillPaymentQuery = queries.BillPaymentQuery;
|
|
1492
|
-
exports.CardErrorType = queries.CardErrorType;
|
|
1493
|
-
exports.CardFundingType = queries.CardFundingType;
|
|
1494
|
-
exports.CardIssuer = queries.CardIssuer;
|
|
1495
|
-
exports.CardStatus = queries.CardStatus;
|
|
1496
|
-
exports.CardTransactionQuery = queries.CardTransactionQuery;
|
|
1497
|
-
exports.CardTransactionType = queries.CardTransactionType;
|
|
1498
|
-
exports.CardType = queries.CardType;
|
|
1499
|
-
exports.CardsQuery = queries.CardsQuery;
|
|
1500
|
-
exports.CommissionType = queries.CommissionType;
|
|
1501
|
-
exports.DepositNetwork = queries.DepositNetwork;
|
|
1502
|
-
exports.DepositQuery = queries.DepositQuery;
|
|
1503
|
-
exports.EntryType = queries.EntryType;
|
|
1504
|
-
exports.FileFormat = queries.FileFormat;
|
|
1505
|
-
exports.PageSize = queries.PageSize;
|
|
1506
|
-
exports.Phase = queries.Phase;
|
|
1507
|
-
exports.QueryParams = queries.QueryParams;
|
|
1508
|
-
exports.SavingCategory = queries.SavingCategory;
|
|
1509
|
-
exports.ServiceProviderCategory = queries.ServiceProviderCategory;
|
|
1510
|
-
exports.StatementQuery = queries.StatementQuery;
|
|
1511
|
-
exports.TrackDataMethod = queries.TrackDataMethod;
|
|
1512
|
-
exports.TransactionStatus = queries.TransactionStatus;
|
|
1513
|
-
exports.TransferNetwork = queries.TransferNetwork;
|
|
1514
|
-
exports.TransferQuery = queries.TransferQuery;
|
|
1515
|
-
exports.WalletQuery = queries.WalletQuery;
|
|
1516
|
-
exports.WalletTransactionQuery = queries.WalletTransactionQuery;
|
|
1517
|
-
exports.WalletTransactionType = queries.WalletTransactionType;
|
|
1518
1618
|
exports.Cuenca = Cuenca;
|