@cuenca-mx/cuenca-js 0.0.1-dev.4 → 0.0.1-dev.40
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-69952249.mjs +330 -0
- package/build/{queries-b8f29837.js → data-efb53250.cjs} +62 -285
- package/build/errors/{index.js → index.cjs} +0 -0
- package/build/errors/index.mjs +64 -0
- package/build/identities-5e48f342.mjs +337 -0
- package/build/identities-93faf1ed.cjs +354 -0
- package/build/{index.js → index.cjs} +276 -96
- package/build/index.mjs +1689 -0
- package/build/jwt/index.cjs +55 -0
- package/build/jwt/{index.js → index.mjs} +5 -8
- package/build/requests/{index.js → index.cjs} +6 -3
- package/build/requests/index.mjs +3 -0
- package/build/types/index.cjs +47 -0
- package/build/types/index.mjs +3 -0
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-17132eb5.js → walletTransactionRequest-3b0c406d.mjs} +128 -5
- package/build/{walletTransactionRequest-b588cc52.js → walletTransactionRequest-832088b1.cjs} +130 -4
- package/package.json +26 -12
- package/build/README.md +0 -7
- package/build/data-7d3d5fcc.js +0 -11
- package/build/data-c53f1052.js +0 -14
- package/build/package.json +0 -37
- package/build/queries-395c7467.js +0 -546
- 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 data = require('./data-
|
|
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 data = require('./data-efb53250.cjs');
|
|
10
|
+
var identities = require('./identities-93faf1ed.cjs');
|
|
11
|
+
var walletTransactionRequest = require('./walletTransactionRequest-832088b1.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.40";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 = data.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 }) {
|
|
@@ -112,18 +139,28 @@ class Client {
|
|
|
112
139
|
|
|
113
140
|
async request({
|
|
114
141
|
endpoint,
|
|
115
|
-
data = null,
|
|
116
|
-
format =
|
|
142
|
+
data: data$1 = null,
|
|
143
|
+
format = data.FileFormat.Json,
|
|
117
144
|
method = 'GET',
|
|
118
145
|
params = null,
|
|
119
146
|
}) {
|
|
120
147
|
const headers = {
|
|
121
|
-
Authorization: this.authHeader,
|
|
122
|
-
'X-User-Agent': `cuenca-js/0.0.1`, // TODO: Change for client version
|
|
123
148
|
'Content-Type': 'application/json',
|
|
124
149
|
Accept: `application/${format.value}`,
|
|
125
150
|
};
|
|
126
151
|
|
|
152
|
+
if (this.authHeader) {
|
|
153
|
+
headers.Authorization = this.authHeader;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (runtimeEnv.isNode) {
|
|
157
|
+
headers['User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
158
|
+
} else if (runtimeEnv.isBrowser) {
|
|
159
|
+
// Cannot set User-Agent header on browsers
|
|
160
|
+
// https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
|
|
161
|
+
headers['X-User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
127
164
|
if (this.jwtToken) {
|
|
128
165
|
if (this.jwtToken.isExpired) {
|
|
129
166
|
this.jwtToken = await jwt_index.Jwt.create(this);
|
|
@@ -133,7 +170,7 @@ class Client {
|
|
|
133
170
|
|
|
134
171
|
const headersInterceptor = this.addHeadersToRequest(headers);
|
|
135
172
|
|
|
136
|
-
const modifiedData = data;
|
|
173
|
+
const modifiedData = data$1;
|
|
137
174
|
if (modifiedData) {
|
|
138
175
|
Object.keys(modifiedData).forEach((k) => {
|
|
139
176
|
if (modifiedData[k] instanceof Date) {
|
|
@@ -255,7 +292,7 @@ class BalanceEntry {
|
|
|
255
292
|
this.amount = amount;
|
|
256
293
|
this.createdAt = data.dateToUTC(createdAt);
|
|
257
294
|
this.descriptor = descriptor;
|
|
258
|
-
this.entryType = data.enumValueFromString(
|
|
295
|
+
this.entryType = data.enumValueFromString(data.EntryType, entryType);
|
|
259
296
|
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
260
297
|
this.id = id;
|
|
261
298
|
this.name = name;
|
|
@@ -282,7 +319,7 @@ class Transaction {
|
|
|
282
319
|
this.amount = amount;
|
|
283
320
|
this.createdAt = data.dateToUTC(createdAt);
|
|
284
321
|
this.descriptor = descriptor;
|
|
285
|
-
this.status = data.enumValueFromString(
|
|
322
|
+
this.status = data.enumValueFromString(data.TransactionStatus, status);
|
|
286
323
|
this.userId = userId;
|
|
287
324
|
}
|
|
288
325
|
}
|
|
@@ -298,7 +335,13 @@ class BillPayment extends Transaction {
|
|
|
298
335
|
status,
|
|
299
336
|
userId,
|
|
300
337
|
}) {
|
|
301
|
-
super({
|
|
338
|
+
super({
|
|
339
|
+
amount,
|
|
340
|
+
createdAt,
|
|
341
|
+
descriptor,
|
|
342
|
+
status,
|
|
343
|
+
userId,
|
|
344
|
+
});
|
|
302
345
|
this.accountNumber = accountNumber;
|
|
303
346
|
this.id = id;
|
|
304
347
|
this.providerUri = providerUri;
|
|
@@ -337,13 +380,13 @@ class Card {
|
|
|
337
380
|
this.cvv2 = cvv2;
|
|
338
381
|
this.expMonth = expMonth;
|
|
339
382
|
this.expYear = expYear;
|
|
340
|
-
this.fundingType = data.enumValueFromString(
|
|
383
|
+
this.fundingType = data.enumValueFromString(data.CardFundingType, fundingType);
|
|
341
384
|
this.id = id;
|
|
342
|
-
this.issuer = data.enumValueFromString(
|
|
385
|
+
this.issuer = data.enumValueFromString(data.CardIssuer, issuer);
|
|
343
386
|
this.number = number;
|
|
344
387
|
this.pin = pin;
|
|
345
|
-
this.status = data.enumValueFromString(
|
|
346
|
-
this.type = data.enumValueFromString(
|
|
388
|
+
this.status = data.enumValueFromString(data.CardStatus, status);
|
|
389
|
+
this.type = data.enumValueFromString(data.CardType, type);
|
|
347
390
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
348
391
|
this.userId = userId;
|
|
349
392
|
}
|
|
@@ -412,15 +455,21 @@ class CardTransaction extends Transaction {
|
|
|
412
455
|
type,
|
|
413
456
|
userId,
|
|
414
457
|
}) {
|
|
415
|
-
super({
|
|
416
|
-
|
|
458
|
+
super({
|
|
459
|
+
amount,
|
|
460
|
+
createdAt,
|
|
461
|
+
descriptor,
|
|
462
|
+
status,
|
|
463
|
+
userId,
|
|
464
|
+
});
|
|
465
|
+
this.cardErrorType = data.enumValueFromString(data.CardErrorType, cardErrorType);
|
|
417
466
|
this.cardLastFour = cardLastFour;
|
|
418
|
-
this.cardType = data.enumValueFromString(
|
|
467
|
+
this.cardType = data.enumValueFromString(data.CardType, cardType);
|
|
419
468
|
this.cardUri = cardUri;
|
|
420
469
|
this.metadata = metadata;
|
|
421
470
|
this.network = network;
|
|
422
471
|
this.relatedCardTransactionsUris = relatedCardTransactionsUris;
|
|
423
|
-
this.type = data.enumValueFromString(
|
|
472
|
+
this.type = data.enumValueFromString(data.CardTransactionType, type);
|
|
424
473
|
}
|
|
425
474
|
|
|
426
475
|
static fromObject = ({
|
|
@@ -464,8 +513,8 @@ class CardValidation {
|
|
|
464
513
|
isValidPinBlock,
|
|
465
514
|
userId,
|
|
466
515
|
}) {
|
|
467
|
-
this.cardStatus = data.enumValueFromString(
|
|
468
|
-
this.cardType = data.enumValueFromString(
|
|
516
|
+
this.cardStatus = data.enumValueFromString(data.CardStatus, cardStatus);
|
|
517
|
+
this.cardType = data.enumValueFromString(data.CardType, cardType);
|
|
469
518
|
this.cardUri = cardUri;
|
|
470
519
|
this.createdAt = data.dateToUTC(createdAt);
|
|
471
520
|
this.isExpired = isExpired;
|
|
@@ -495,7 +544,7 @@ class CardValidation {
|
|
|
495
544
|
});
|
|
496
545
|
|
|
497
546
|
get isActive() {
|
|
498
|
-
return this.cardStatus ===
|
|
547
|
+
return this.cardStatus === data.CardStatus.Active;
|
|
499
548
|
}
|
|
500
549
|
}
|
|
501
550
|
|
|
@@ -509,9 +558,15 @@ class Commission extends Transaction {
|
|
|
509
558
|
type,
|
|
510
559
|
userId,
|
|
511
560
|
}) {
|
|
512
|
-
super({
|
|
561
|
+
super({
|
|
562
|
+
amount,
|
|
563
|
+
createdAt,
|
|
564
|
+
descriptor,
|
|
565
|
+
status,
|
|
566
|
+
userId,
|
|
567
|
+
});
|
|
513
568
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
514
|
-
this.type = data.enumValueFromString(
|
|
569
|
+
this.type = data.enumValueFromString(data.CommissionType, type);
|
|
515
570
|
}
|
|
516
571
|
|
|
517
572
|
static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
|
|
@@ -538,9 +593,15 @@ class Deposit extends Transaction {
|
|
|
538
593
|
trackingKey,
|
|
539
594
|
userId,
|
|
540
595
|
}) {
|
|
541
|
-
super({
|
|
596
|
+
super({
|
|
597
|
+
amount,
|
|
598
|
+
createdAt,
|
|
599
|
+
descriptor,
|
|
600
|
+
status,
|
|
601
|
+
userId,
|
|
602
|
+
});
|
|
542
603
|
this.id = id;
|
|
543
|
-
this.network = data.enumValueFromString(
|
|
604
|
+
this.network = data.enumValueFromString(data.DepositNetwork, network);
|
|
544
605
|
this.sourceUri = sourceUri;
|
|
545
606
|
this.trackingKey = trackingKey;
|
|
546
607
|
}
|
|
@@ -591,8 +652,15 @@ class Saving extends Wallet {
|
|
|
591
652
|
userId,
|
|
592
653
|
updatedAt,
|
|
593
654
|
}) {
|
|
594
|
-
super({
|
|
595
|
-
|
|
655
|
+
super({
|
|
656
|
+
balance,
|
|
657
|
+
createdAt,
|
|
658
|
+
deactivatedAt,
|
|
659
|
+
id,
|
|
660
|
+
userId,
|
|
661
|
+
updatedAt,
|
|
662
|
+
});
|
|
663
|
+
this.category = data.enumValueFromString(data.SavingCategory, category);
|
|
596
664
|
this.goalAmount = goalAmount;
|
|
597
665
|
this.goalDate = data.dateToUTC(goalDate);
|
|
598
666
|
this.name = name;
|
|
@@ -616,7 +684,7 @@ class Saving extends Wallet {
|
|
|
616
684
|
const categoriesFromString = (categoriesList) => {
|
|
617
685
|
if (categoriesList == null) return [];
|
|
618
686
|
return categoriesList.map((category) =>
|
|
619
|
-
data.enumValueFromString(
|
|
687
|
+
data.enumValueFromString(data.ServiceProviderCategory, category),
|
|
620
688
|
);
|
|
621
689
|
};
|
|
622
690
|
|
|
@@ -670,12 +738,18 @@ class Transfer extends Transaction {
|
|
|
670
738
|
updatedAt,
|
|
671
739
|
userId,
|
|
672
740
|
}) {
|
|
673
|
-
super({
|
|
741
|
+
super({
|
|
742
|
+
amount,
|
|
743
|
+
createdAt,
|
|
744
|
+
descriptor,
|
|
745
|
+
status,
|
|
746
|
+
userId,
|
|
747
|
+
});
|
|
674
748
|
this.accountNumber = accountNumber;
|
|
675
749
|
this.destinationUri = destinationUri;
|
|
676
750
|
this.id = id;
|
|
677
751
|
this.idempotencyKey = idempotencyKey;
|
|
678
|
-
this.network = data.enumValueFromString(
|
|
752
|
+
this.network = data.enumValueFromString(data.TransferNetwork, network);
|
|
679
753
|
this.recipientName = recipientName;
|
|
680
754
|
this.trackingKey = trackingKey;
|
|
681
755
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
@@ -699,6 +773,79 @@ class Transfer extends Transaction {
|
|
|
699
773
|
});
|
|
700
774
|
}
|
|
701
775
|
|
|
776
|
+
class User {
|
|
777
|
+
constructor({
|
|
778
|
+
emailAddress,
|
|
779
|
+
govtId,
|
|
780
|
+
level,
|
|
781
|
+
phoneNumber,
|
|
782
|
+
proofOfAddress,
|
|
783
|
+
proofOfLife,
|
|
784
|
+
status,
|
|
785
|
+
termsOfService,
|
|
786
|
+
verificationId,
|
|
787
|
+
}) {
|
|
788
|
+
this.emailAddress = emailAddress;
|
|
789
|
+
this.govstIds = govtId;
|
|
790
|
+
this.level = level;
|
|
791
|
+
this.phoneNumber = phoneNumber;
|
|
792
|
+
this.addressProofs = proofOfAddress;
|
|
793
|
+
this.lifeProofs = proofOfLife;
|
|
794
|
+
this.status = data.enumValueFromString(data.UserStatus, status);
|
|
795
|
+
this.terms = termsOfService;
|
|
796
|
+
this.verificationId = verificationId;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
get proofOfAddress() {
|
|
800
|
+
return this._proofOfAddress;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
set addressProofs(value) {
|
|
804
|
+
if (!value) return;
|
|
805
|
+
this._proofOfAddress = identities.KYCFile.fromObject(value);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
get proofOfLife() {
|
|
809
|
+
return this._proofOfLife;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
set lifeProofs(value) {
|
|
813
|
+
if (!value) return;
|
|
814
|
+
this._proofOfLife = identities.KYCFile.fromObject(value);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
get govtId() {
|
|
818
|
+
return this._govtId;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
set govstIds(value) {
|
|
822
|
+
if (!value) return;
|
|
823
|
+
this._govtId = identities.KYCFile.fromObject(value);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
get termsOfService() {
|
|
827
|
+
return this._termsOfService;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
set terms(value) {
|
|
831
|
+
if (!value) return;
|
|
832
|
+
this._termsOfService = identities.TOSAgreements.fromObject(value);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
static fromObject = ({ level, status, ...obj }) =>
|
|
836
|
+
new User({
|
|
837
|
+
level,
|
|
838
|
+
status,
|
|
839
|
+
govtId: obj.govt_id,
|
|
840
|
+
emailAddress: obj.email_address,
|
|
841
|
+
phoneNumber: obj.phone_number,
|
|
842
|
+
proofOfAddress: obj.proof_of_address,
|
|
843
|
+
proofOfLife: obj.proof_of_life,
|
|
844
|
+
termsOfService: obj.terms_of_service,
|
|
845
|
+
verificationId: obj.verification_id,
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
|
|
702
849
|
class UserCredential {
|
|
703
850
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
704
851
|
this.createdAt = data.dateToUTC(createdAt);
|
|
@@ -731,6 +878,27 @@ class UserLogin {
|
|
|
731
878
|
});
|
|
732
879
|
}
|
|
733
880
|
|
|
881
|
+
class Verification {
|
|
882
|
+
constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
|
|
883
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
884
|
+
this.id = id;
|
|
885
|
+
this.platformId = platformId;
|
|
886
|
+
this.recipient = recipient;
|
|
887
|
+
this.type = data.enumValueFromString(data.VerificationType, type);
|
|
888
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
static fromObject = ({ id, recipient, type, ...obj }) =>
|
|
892
|
+
new Verification({
|
|
893
|
+
id,
|
|
894
|
+
recipient,
|
|
895
|
+
type,
|
|
896
|
+
createdAt: obj.created_at,
|
|
897
|
+
platformId: obj.platform_id,
|
|
898
|
+
updatedAt: obj.updated_at,
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
|
|
734
902
|
class WalletTransaction extends Transaction {
|
|
735
903
|
constructor({
|
|
736
904
|
amount,
|
|
@@ -742,10 +910,16 @@ class WalletTransaction extends Transaction {
|
|
|
742
910
|
userId,
|
|
743
911
|
walletUri,
|
|
744
912
|
}) {
|
|
745
|
-
super({
|
|
913
|
+
super({
|
|
914
|
+
amount,
|
|
915
|
+
createdAt,
|
|
916
|
+
descriptor,
|
|
917
|
+
status,
|
|
918
|
+
userId,
|
|
919
|
+
});
|
|
746
920
|
this.id = id;
|
|
747
921
|
this.transactionType = data.enumValueFromString(
|
|
748
|
-
|
|
922
|
+
data.WalletTransactionType,
|
|
749
923
|
transactionType,
|
|
750
924
|
);
|
|
751
925
|
this.walletUri = walletUri;
|
|
@@ -781,12 +955,18 @@ class WhatsAppTransfer extends Transaction {
|
|
|
781
955
|
updatedAt,
|
|
782
956
|
userId,
|
|
783
957
|
}) {
|
|
784
|
-
super({
|
|
958
|
+
super({
|
|
959
|
+
amount,
|
|
960
|
+
createdAt,
|
|
961
|
+
descriptor,
|
|
962
|
+
status,
|
|
963
|
+
userId,
|
|
964
|
+
});
|
|
785
965
|
this.claimUrl = claimUrl;
|
|
786
966
|
this.destinationUri = destinationUri;
|
|
787
967
|
this.id = id;
|
|
788
968
|
this.expiresAt = data.dateToUTC(expiresAt);
|
|
789
|
-
this.network = data.enumValueFromString(
|
|
969
|
+
this.network = data.enumValueFromString(data.TransferNetwork, network);
|
|
790
970
|
this.phoneNumber = phoneNumber;
|
|
791
971
|
this.recipientName = recipientName;
|
|
792
972
|
this.trackingKey = trackingKey;
|
|
@@ -842,8 +1022,10 @@ const getModelFromPath = (path, obj) => {
|
|
|
842
1022
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
843
1023
|
statements: () => Statement.fromObject(obj),
|
|
844
1024
|
transfers: () => Transfer.fromObject(obj),
|
|
1025
|
+
users: () => User.fromObject(obj),
|
|
845
1026
|
user_credentials: () => UserCredential.fromObject(obj),
|
|
846
1027
|
user_logins: () => UserLogin.fromObject(obj),
|
|
1028
|
+
verifications: () => Verification.fromObject(obj),
|
|
847
1029
|
wallet_transactions: () => WalletTransaction.fromObject(obj),
|
|
848
1030
|
whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
|
|
849
1031
|
};
|
|
@@ -981,7 +1163,7 @@ const Queryable = (SuperClass) =>
|
|
|
981
1163
|
|
|
982
1164
|
class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
983
1165
|
constructor(client) {
|
|
984
|
-
super('accounts',
|
|
1166
|
+
super('accounts', identities.AccountQuery, client);
|
|
985
1167
|
}
|
|
986
1168
|
}
|
|
987
1169
|
|
|
@@ -993,7 +1175,7 @@ class ApiKeyResource extends mix(Resource).with(
|
|
|
993
1175
|
Updateable,
|
|
994
1176
|
) {
|
|
995
1177
|
constructor(client) {
|
|
996
|
-
super('api_keys',
|
|
1178
|
+
super('api_keys', identities.ApiKeyQuery, client);
|
|
997
1179
|
}
|
|
998
1180
|
|
|
999
1181
|
async create() {
|
|
@@ -1047,7 +1229,7 @@ class ArpcResource extends mix(Resource).with(Creatable) {
|
|
|
1047
1229
|
|
|
1048
1230
|
class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1049
1231
|
constructor(client) {
|
|
1050
|
-
super('balance_entries',
|
|
1232
|
+
super('balance_entries', identities.BalanceEntryQuery, client);
|
|
1051
1233
|
}
|
|
1052
1234
|
|
|
1053
1235
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1073,7 +1255,7 @@ class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1073
1255
|
|
|
1074
1256
|
class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1075
1257
|
constructor(client) {
|
|
1076
|
-
super('bill_payments',
|
|
1258
|
+
super('bill_payments', identities.BillPaymentQuery, client);
|
|
1077
1259
|
}
|
|
1078
1260
|
|
|
1079
1261
|
async serviceProvider(providerUri) {
|
|
@@ -1111,7 +1293,7 @@ class CardResource extends mix(Resource).with(
|
|
|
1111
1293
|
Updateable,
|
|
1112
1294
|
) {
|
|
1113
1295
|
constructor(client) {
|
|
1114
|
-
super('cards',
|
|
1296
|
+
super('cards', identities.CardsQuery, client);
|
|
1115
1297
|
}
|
|
1116
1298
|
|
|
1117
1299
|
async create(userId, issuer, fundingType) {
|
|
@@ -1137,7 +1319,7 @@ class CardTransactionResource extends mix(Resource).with(
|
|
|
1137
1319
|
Retrievable,
|
|
1138
1320
|
) {
|
|
1139
1321
|
constructor(client) {
|
|
1140
|
-
super('card_transactions',
|
|
1322
|
+
super('card_transactions', identities.CardTransactionQuery, client);
|
|
1141
1323
|
}
|
|
1142
1324
|
|
|
1143
1325
|
async relatedCard(relatedCardUri) {
|
|
@@ -1189,7 +1371,7 @@ class CardValidationResource extends mix(Resource).with(Creatable) {
|
|
|
1189
1371
|
|
|
1190
1372
|
class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1191
1373
|
constructor(client) {
|
|
1192
|
-
super('commissions',
|
|
1374
|
+
super('commissions', identities.QueryParams, client);
|
|
1193
1375
|
}
|
|
1194
1376
|
|
|
1195
1377
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1203,7 +1385,7 @@ class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1203
1385
|
|
|
1204
1386
|
class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1205
1387
|
constructor(client) {
|
|
1206
|
-
super('deposits',
|
|
1388
|
+
super('deposits', identities.DepositQuery, client);
|
|
1207
1389
|
}
|
|
1208
1390
|
|
|
1209
1391
|
async source(sourceUri) {
|
|
@@ -1231,7 +1413,7 @@ class SavingResource extends mix(Resource).with(
|
|
|
1231
1413
|
Updateable,
|
|
1232
1414
|
) {
|
|
1233
1415
|
constructor(client) {
|
|
1234
|
-
super('savings',
|
|
1416
|
+
super('savings', identities.WalletQuery, client);
|
|
1235
1417
|
}
|
|
1236
1418
|
|
|
1237
1419
|
async create(category, goalAmount, goalDate, name) {
|
|
@@ -1257,22 +1439,22 @@ class ServiceProviderResource extends mix(Resource).with(
|
|
|
1257
1439
|
Retrievable,
|
|
1258
1440
|
) {
|
|
1259
1441
|
constructor(client) {
|
|
1260
|
-
super('service_providers',
|
|
1442
|
+
super('service_providers', identities.QueryParams, client);
|
|
1261
1443
|
}
|
|
1262
1444
|
}
|
|
1263
1445
|
|
|
1264
1446
|
class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
|
|
1265
1447
|
constructor(client) {
|
|
1266
|
-
super('statements',
|
|
1448
|
+
super('statements', identities.StatementQuery, client);
|
|
1267
1449
|
}
|
|
1268
1450
|
|
|
1269
1451
|
async pdf(id) {
|
|
1270
|
-
const byteString = await this._download(id,
|
|
1452
|
+
const byteString = await this._download(id, data.FileFormat.Pdf);
|
|
1271
1453
|
return byteString;
|
|
1272
1454
|
}
|
|
1273
1455
|
|
|
1274
1456
|
async xml(id) {
|
|
1275
|
-
const byteString = await this._download(id,
|
|
1457
|
+
const byteString = await this._download(id, data.FileFormat.Xml);
|
|
1276
1458
|
return byteString;
|
|
1277
1459
|
}
|
|
1278
1460
|
}
|
|
@@ -1283,7 +1465,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1283
1465
|
Retrievable,
|
|
1284
1466
|
) {
|
|
1285
1467
|
constructor(client) {
|
|
1286
|
-
super('transfers',
|
|
1468
|
+
super('transfers', identities.TransferQuery, client);
|
|
1287
1469
|
}
|
|
1288
1470
|
|
|
1289
1471
|
async destination(destinationUri) {
|
|
@@ -1403,13 +1585,47 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1403
1585
|
}
|
|
1404
1586
|
}
|
|
1405
1587
|
|
|
1588
|
+
class UserResourse extends mix(Resource).with(
|
|
1589
|
+
Queryable,
|
|
1590
|
+
Updateable,
|
|
1591
|
+
Retrievable,
|
|
1592
|
+
) {
|
|
1593
|
+
constructor(client) {
|
|
1594
|
+
super('users', identities.UserQuery, client);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
async update({ termsOfService, verificationId, userId = 'me' }) {
|
|
1598
|
+
const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService, verificationId });
|
|
1599
|
+
const user = await this._update(userId, request.toCleanObject());
|
|
1600
|
+
return user;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
class VerificationResourse extends mix(Resource).with(Creatable, Updateable) {
|
|
1605
|
+
constructor(client) {
|
|
1606
|
+
super('verifications', Object, client);
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
async create({ platformId, recipient, type }) {
|
|
1610
|
+
const request = new walletTransactionRequest.VerificationRequest({ platformId, recipient, type });
|
|
1611
|
+
const verification = await this._create(request.toObject());
|
|
1612
|
+
return verification;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
async update({ code, id }) {
|
|
1616
|
+
const request = new walletTransactionRequest.VerificationAttemptRequest({ code });
|
|
1617
|
+
const verification = await this._update(id, request.toObject());
|
|
1618
|
+
return verification;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1406
1622
|
class WalletTransactionsResource extends mix(Resource).with(
|
|
1407
1623
|
Creatable,
|
|
1408
1624
|
Queryable,
|
|
1409
1625
|
Retrievable,
|
|
1410
1626
|
) {
|
|
1411
1627
|
constructor(client) {
|
|
1412
|
-
super('wallet_transactions',
|
|
1628
|
+
super('wallet_transactions', identities.WalletTransactionQuery, client);
|
|
1413
1629
|
}
|
|
1414
1630
|
|
|
1415
1631
|
async create(amount, transactionType, walletUri) {
|
|
@@ -1436,7 +1652,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1436
1652
|
Retrievable,
|
|
1437
1653
|
) {
|
|
1438
1654
|
constructor(client) {
|
|
1439
|
-
super('whatsapp_transfers',
|
|
1655
|
+
super('whatsapp_transfers', identities.QueryParams, client);
|
|
1440
1656
|
}
|
|
1441
1657
|
|
|
1442
1658
|
async accountDestination(destinationUri) {
|
|
@@ -1449,7 +1665,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1449
1665
|
}
|
|
1450
1666
|
|
|
1451
1667
|
class Cuenca {
|
|
1452
|
-
constructor(apiKey, apiSecret, phase =
|
|
1668
|
+
constructor(apiKey, apiSecret, phase = data.Phase.Sandbox) {
|
|
1453
1669
|
this.client = new Client({ apiKey, apiSecret, phase });
|
|
1454
1670
|
this.withClient(this.client);
|
|
1455
1671
|
}
|
|
@@ -1472,47 +1688,11 @@ class Cuenca {
|
|
|
1472
1688
|
this.transfers = new TransferResource(client);
|
|
1473
1689
|
this.userCredentials = new UserCredentialResource(client);
|
|
1474
1690
|
this.userLogins = new UserLoginResource(client);
|
|
1691
|
+
this.users = new UserResourse(client);
|
|
1692
|
+
this.verifications = new VerificationResourse(client);
|
|
1475
1693
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1476
1694
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
|
1477
1695
|
}
|
|
1478
1696
|
}
|
|
1479
1697
|
|
|
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
1698
|
exports.Cuenca = Cuenca;
|