@cuenca-mx/cuenca-js 0.0.1-dev.4 → 0.0.1-dev.42
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} +288 -98
- package/build/index.mjs +1699 -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,22 +3,42 @@
|
|
|
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.42";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({
|
|
32
|
+
constructor({
|
|
33
|
+
apiKey,
|
|
34
|
+
apiSecret,
|
|
35
|
+
language = 'en',
|
|
36
|
+
phase = data.Phase.Sandbox,
|
|
37
|
+
} = {}) {
|
|
18
38
|
this.phase = phase;
|
|
19
39
|
this.basicAuth = { apiKey, apiSecret };
|
|
20
40
|
this.jwtToken = null;
|
|
21
|
-
this._session = axios__default["default"].create();
|
|
41
|
+
this._session = axios__default["default"].create({ headers: { 'Accept-Language': language } });
|
|
22
42
|
}
|
|
23
43
|
|
|
24
44
|
get session() {
|
|
@@ -32,8 +52,9 @@ class Client {
|
|
|
32
52
|
get authHeader() {
|
|
33
53
|
const { apiKey, apiSecret } = this.basicAuth;
|
|
34
54
|
if (!apiKey || !apiSecret) return '';
|
|
35
|
-
return `Basic ${Buffer.from(
|
|
36
|
-
|
|
55
|
+
return `Basic ${Buffer__default["default"].Buffer.from(
|
|
56
|
+
`${apiKey}:${apiSecret}`,
|
|
57
|
+
'utf-8',
|
|
37
58
|
).toString('base64')}`;
|
|
38
59
|
}
|
|
39
60
|
|
|
@@ -79,7 +100,14 @@ class Client {
|
|
|
79
100
|
};
|
|
80
101
|
}
|
|
81
102
|
|
|
82
|
-
async configure({
|
|
103
|
+
async configure({
|
|
104
|
+
apiKey,
|
|
105
|
+
apiSecret,
|
|
106
|
+
loginToken,
|
|
107
|
+
phase,
|
|
108
|
+
sessionId,
|
|
109
|
+
useJwt = false,
|
|
110
|
+
}) {
|
|
83
111
|
this.basicAuth = {
|
|
84
112
|
apiKey: apiKey || this.basicAuth.apiKey,
|
|
85
113
|
apiSecret: apiSecret || this.basicAuth.apiSecret,
|
|
@@ -92,6 +120,10 @@ class Client {
|
|
|
92
120
|
if (loginToken) {
|
|
93
121
|
this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
|
|
94
122
|
}
|
|
123
|
+
|
|
124
|
+
if (sessionId) {
|
|
125
|
+
this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
|
|
126
|
+
}
|
|
95
127
|
}
|
|
96
128
|
|
|
97
129
|
async get({ endpoint, format, params }) {
|
|
@@ -112,18 +144,28 @@ class Client {
|
|
|
112
144
|
|
|
113
145
|
async request({
|
|
114
146
|
endpoint,
|
|
115
|
-
data = null,
|
|
116
|
-
format =
|
|
147
|
+
data: data$1 = null,
|
|
148
|
+
format = data.FileFormat.Json,
|
|
117
149
|
method = 'GET',
|
|
118
150
|
params = null,
|
|
119
151
|
}) {
|
|
120
152
|
const headers = {
|
|
121
|
-
Authorization: this.authHeader,
|
|
122
|
-
'X-User-Agent': `cuenca-js/0.0.1`, // TODO: Change for client version
|
|
123
153
|
'Content-Type': 'application/json',
|
|
124
154
|
Accept: `application/${format.value}`,
|
|
125
155
|
};
|
|
126
156
|
|
|
157
|
+
if (this.authHeader) {
|
|
158
|
+
headers.Authorization = this.authHeader;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (runtimeEnv.isNode) {
|
|
162
|
+
headers['User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
163
|
+
} else if (runtimeEnv.isBrowser) {
|
|
164
|
+
// Cannot set User-Agent header on browsers
|
|
165
|
+
// https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
|
|
166
|
+
headers['X-User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
167
|
+
}
|
|
168
|
+
|
|
127
169
|
if (this.jwtToken) {
|
|
128
170
|
if (this.jwtToken.isExpired) {
|
|
129
171
|
this.jwtToken = await jwt_index.Jwt.create(this);
|
|
@@ -133,7 +175,7 @@ class Client {
|
|
|
133
175
|
|
|
134
176
|
const headersInterceptor = this.addHeadersToRequest(headers);
|
|
135
177
|
|
|
136
|
-
const modifiedData = data;
|
|
178
|
+
const modifiedData = data$1;
|
|
137
179
|
if (modifiedData) {
|
|
138
180
|
Object.keys(modifiedData).forEach((k) => {
|
|
139
181
|
if (modifiedData[k] instanceof Date) {
|
|
@@ -255,7 +297,7 @@ class BalanceEntry {
|
|
|
255
297
|
this.amount = amount;
|
|
256
298
|
this.createdAt = data.dateToUTC(createdAt);
|
|
257
299
|
this.descriptor = descriptor;
|
|
258
|
-
this.entryType = data.enumValueFromString(
|
|
300
|
+
this.entryType = data.enumValueFromString(data.EntryType, entryType);
|
|
259
301
|
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
260
302
|
this.id = id;
|
|
261
303
|
this.name = name;
|
|
@@ -282,7 +324,7 @@ class Transaction {
|
|
|
282
324
|
this.amount = amount;
|
|
283
325
|
this.createdAt = data.dateToUTC(createdAt);
|
|
284
326
|
this.descriptor = descriptor;
|
|
285
|
-
this.status = data.enumValueFromString(
|
|
327
|
+
this.status = data.enumValueFromString(data.TransactionStatus, status);
|
|
286
328
|
this.userId = userId;
|
|
287
329
|
}
|
|
288
330
|
}
|
|
@@ -298,7 +340,13 @@ class BillPayment extends Transaction {
|
|
|
298
340
|
status,
|
|
299
341
|
userId,
|
|
300
342
|
}) {
|
|
301
|
-
super({
|
|
343
|
+
super({
|
|
344
|
+
amount,
|
|
345
|
+
createdAt,
|
|
346
|
+
descriptor,
|
|
347
|
+
status,
|
|
348
|
+
userId,
|
|
349
|
+
});
|
|
302
350
|
this.accountNumber = accountNumber;
|
|
303
351
|
this.id = id;
|
|
304
352
|
this.providerUri = providerUri;
|
|
@@ -337,13 +385,13 @@ class Card {
|
|
|
337
385
|
this.cvv2 = cvv2;
|
|
338
386
|
this.expMonth = expMonth;
|
|
339
387
|
this.expYear = expYear;
|
|
340
|
-
this.fundingType = data.enumValueFromString(
|
|
388
|
+
this.fundingType = data.enumValueFromString(data.CardFundingType, fundingType);
|
|
341
389
|
this.id = id;
|
|
342
|
-
this.issuer = data.enumValueFromString(
|
|
390
|
+
this.issuer = data.enumValueFromString(data.CardIssuer, issuer);
|
|
343
391
|
this.number = number;
|
|
344
392
|
this.pin = pin;
|
|
345
|
-
this.status = data.enumValueFromString(
|
|
346
|
-
this.type = data.enumValueFromString(
|
|
393
|
+
this.status = data.enumValueFromString(data.CardStatus, status);
|
|
394
|
+
this.type = data.enumValueFromString(data.CardType, type);
|
|
347
395
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
348
396
|
this.userId = userId;
|
|
349
397
|
}
|
|
@@ -412,15 +460,21 @@ class CardTransaction extends Transaction {
|
|
|
412
460
|
type,
|
|
413
461
|
userId,
|
|
414
462
|
}) {
|
|
415
|
-
super({
|
|
416
|
-
|
|
463
|
+
super({
|
|
464
|
+
amount,
|
|
465
|
+
createdAt,
|
|
466
|
+
descriptor,
|
|
467
|
+
status,
|
|
468
|
+
userId,
|
|
469
|
+
});
|
|
470
|
+
this.cardErrorType = data.enumValueFromString(data.CardErrorType, cardErrorType);
|
|
417
471
|
this.cardLastFour = cardLastFour;
|
|
418
|
-
this.cardType = data.enumValueFromString(
|
|
472
|
+
this.cardType = data.enumValueFromString(data.CardType, cardType);
|
|
419
473
|
this.cardUri = cardUri;
|
|
420
474
|
this.metadata = metadata;
|
|
421
475
|
this.network = network;
|
|
422
476
|
this.relatedCardTransactionsUris = relatedCardTransactionsUris;
|
|
423
|
-
this.type = data.enumValueFromString(
|
|
477
|
+
this.type = data.enumValueFromString(data.CardTransactionType, type);
|
|
424
478
|
}
|
|
425
479
|
|
|
426
480
|
static fromObject = ({
|
|
@@ -464,8 +518,8 @@ class CardValidation {
|
|
|
464
518
|
isValidPinBlock,
|
|
465
519
|
userId,
|
|
466
520
|
}) {
|
|
467
|
-
this.cardStatus = data.enumValueFromString(
|
|
468
|
-
this.cardType = data.enumValueFromString(
|
|
521
|
+
this.cardStatus = data.enumValueFromString(data.CardStatus, cardStatus);
|
|
522
|
+
this.cardType = data.enumValueFromString(data.CardType, cardType);
|
|
469
523
|
this.cardUri = cardUri;
|
|
470
524
|
this.createdAt = data.dateToUTC(createdAt);
|
|
471
525
|
this.isExpired = isExpired;
|
|
@@ -495,7 +549,7 @@ class CardValidation {
|
|
|
495
549
|
});
|
|
496
550
|
|
|
497
551
|
get isActive() {
|
|
498
|
-
return this.cardStatus ===
|
|
552
|
+
return this.cardStatus === data.CardStatus.Active;
|
|
499
553
|
}
|
|
500
554
|
}
|
|
501
555
|
|
|
@@ -509,9 +563,15 @@ class Commission extends Transaction {
|
|
|
509
563
|
type,
|
|
510
564
|
userId,
|
|
511
565
|
}) {
|
|
512
|
-
super({
|
|
566
|
+
super({
|
|
567
|
+
amount,
|
|
568
|
+
createdAt,
|
|
569
|
+
descriptor,
|
|
570
|
+
status,
|
|
571
|
+
userId,
|
|
572
|
+
});
|
|
513
573
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
514
|
-
this.type = data.enumValueFromString(
|
|
574
|
+
this.type = data.enumValueFromString(data.CommissionType, type);
|
|
515
575
|
}
|
|
516
576
|
|
|
517
577
|
static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
|
|
@@ -538,9 +598,15 @@ class Deposit extends Transaction {
|
|
|
538
598
|
trackingKey,
|
|
539
599
|
userId,
|
|
540
600
|
}) {
|
|
541
|
-
super({
|
|
601
|
+
super({
|
|
602
|
+
amount,
|
|
603
|
+
createdAt,
|
|
604
|
+
descriptor,
|
|
605
|
+
status,
|
|
606
|
+
userId,
|
|
607
|
+
});
|
|
542
608
|
this.id = id;
|
|
543
|
-
this.network = data.enumValueFromString(
|
|
609
|
+
this.network = data.enumValueFromString(data.DepositNetwork, network);
|
|
544
610
|
this.sourceUri = sourceUri;
|
|
545
611
|
this.trackingKey = trackingKey;
|
|
546
612
|
}
|
|
@@ -591,8 +657,15 @@ class Saving extends Wallet {
|
|
|
591
657
|
userId,
|
|
592
658
|
updatedAt,
|
|
593
659
|
}) {
|
|
594
|
-
super({
|
|
595
|
-
|
|
660
|
+
super({
|
|
661
|
+
balance,
|
|
662
|
+
createdAt,
|
|
663
|
+
deactivatedAt,
|
|
664
|
+
id,
|
|
665
|
+
userId,
|
|
666
|
+
updatedAt,
|
|
667
|
+
});
|
|
668
|
+
this.category = data.enumValueFromString(data.SavingCategory, category);
|
|
596
669
|
this.goalAmount = goalAmount;
|
|
597
670
|
this.goalDate = data.dateToUTC(goalDate);
|
|
598
671
|
this.name = name;
|
|
@@ -616,7 +689,7 @@ class Saving extends Wallet {
|
|
|
616
689
|
const categoriesFromString = (categoriesList) => {
|
|
617
690
|
if (categoriesList == null) return [];
|
|
618
691
|
return categoriesList.map((category) =>
|
|
619
|
-
data.enumValueFromString(
|
|
692
|
+
data.enumValueFromString(data.ServiceProviderCategory, category),
|
|
620
693
|
);
|
|
621
694
|
};
|
|
622
695
|
|
|
@@ -670,12 +743,18 @@ class Transfer extends Transaction {
|
|
|
670
743
|
updatedAt,
|
|
671
744
|
userId,
|
|
672
745
|
}) {
|
|
673
|
-
super({
|
|
746
|
+
super({
|
|
747
|
+
amount,
|
|
748
|
+
createdAt,
|
|
749
|
+
descriptor,
|
|
750
|
+
status,
|
|
751
|
+
userId,
|
|
752
|
+
});
|
|
674
753
|
this.accountNumber = accountNumber;
|
|
675
754
|
this.destinationUri = destinationUri;
|
|
676
755
|
this.id = id;
|
|
677
756
|
this.idempotencyKey = idempotencyKey;
|
|
678
|
-
this.network = data.enumValueFromString(
|
|
757
|
+
this.network = data.enumValueFromString(data.TransferNetwork, network);
|
|
679
758
|
this.recipientName = recipientName;
|
|
680
759
|
this.trackingKey = trackingKey;
|
|
681
760
|
this.updatedAt = data.dateToUTC(updatedAt);
|
|
@@ -699,6 +778,79 @@ class Transfer extends Transaction {
|
|
|
699
778
|
});
|
|
700
779
|
}
|
|
701
780
|
|
|
781
|
+
class User {
|
|
782
|
+
constructor({
|
|
783
|
+
emailAddress,
|
|
784
|
+
govtId,
|
|
785
|
+
level,
|
|
786
|
+
phoneNumber,
|
|
787
|
+
proofOfAddress,
|
|
788
|
+
proofOfLife,
|
|
789
|
+
status,
|
|
790
|
+
termsOfService,
|
|
791
|
+
verificationId,
|
|
792
|
+
}) {
|
|
793
|
+
this.emailAddress = emailAddress;
|
|
794
|
+
this.govstIds = govtId;
|
|
795
|
+
this.level = level;
|
|
796
|
+
this.phoneNumber = phoneNumber;
|
|
797
|
+
this.addressProofs = proofOfAddress;
|
|
798
|
+
this.lifeProofs = proofOfLife;
|
|
799
|
+
this.status = data.enumValueFromString(data.UserStatus, status);
|
|
800
|
+
this.terms = termsOfService;
|
|
801
|
+
this.verificationId = verificationId;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
get proofOfAddress() {
|
|
805
|
+
return this._proofOfAddress;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
set addressProofs(value) {
|
|
809
|
+
if (!value) return;
|
|
810
|
+
this._proofOfAddress = identities.KYCFile.fromObject(value);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
get proofOfLife() {
|
|
814
|
+
return this._proofOfLife;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
set lifeProofs(value) {
|
|
818
|
+
if (!value) return;
|
|
819
|
+
this._proofOfLife = identities.KYCFile.fromObject(value);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
get govtId() {
|
|
823
|
+
return this._govtId;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
set govstIds(value) {
|
|
827
|
+
if (!value) return;
|
|
828
|
+
this._govtId = identities.KYCFile.fromObject(value);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
get termsOfService() {
|
|
832
|
+
return this._termsOfService;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
set terms(value) {
|
|
836
|
+
if (!value) return;
|
|
837
|
+
this._termsOfService = identities.TOSAgreements.fromObject(value);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
static fromObject = ({ level, status, ...obj }) =>
|
|
841
|
+
new User({
|
|
842
|
+
level,
|
|
843
|
+
status,
|
|
844
|
+
govtId: obj.govt_id,
|
|
845
|
+
emailAddress: obj.email_address,
|
|
846
|
+
phoneNumber: obj.phone_number,
|
|
847
|
+
proofOfAddress: obj.proof_of_address,
|
|
848
|
+
proofOfLife: obj.proof_of_life,
|
|
849
|
+
termsOfService: obj.terms_of_service,
|
|
850
|
+
verificationId: obj.verification_id,
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
|
|
702
854
|
class UserCredential {
|
|
703
855
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
704
856
|
this.createdAt = data.dateToUTC(createdAt);
|
|
@@ -731,6 +883,27 @@ class UserLogin {
|
|
|
731
883
|
});
|
|
732
884
|
}
|
|
733
885
|
|
|
886
|
+
class Verification {
|
|
887
|
+
constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
|
|
888
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
889
|
+
this.id = id;
|
|
890
|
+
this.platformId = platformId;
|
|
891
|
+
this.recipient = recipient;
|
|
892
|
+
this.type = data.enumValueFromString(data.VerificationType, type);
|
|
893
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
static fromObject = ({ id, recipient, type, ...obj }) =>
|
|
897
|
+
new Verification({
|
|
898
|
+
id,
|
|
899
|
+
recipient,
|
|
900
|
+
type,
|
|
901
|
+
createdAt: obj.created_at,
|
|
902
|
+
platformId: obj.platform_id,
|
|
903
|
+
updatedAt: obj.updated_at,
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
|
|
734
907
|
class WalletTransaction extends Transaction {
|
|
735
908
|
constructor({
|
|
736
909
|
amount,
|
|
@@ -742,10 +915,16 @@ class WalletTransaction extends Transaction {
|
|
|
742
915
|
userId,
|
|
743
916
|
walletUri,
|
|
744
917
|
}) {
|
|
745
|
-
super({
|
|
918
|
+
super({
|
|
919
|
+
amount,
|
|
920
|
+
createdAt,
|
|
921
|
+
descriptor,
|
|
922
|
+
status,
|
|
923
|
+
userId,
|
|
924
|
+
});
|
|
746
925
|
this.id = id;
|
|
747
926
|
this.transactionType = data.enumValueFromString(
|
|
748
|
-
|
|
927
|
+
data.WalletTransactionType,
|
|
749
928
|
transactionType,
|
|
750
929
|
);
|
|
751
930
|
this.walletUri = walletUri;
|
|
@@ -781,12 +960,18 @@ class WhatsAppTransfer extends Transaction {
|
|
|
781
960
|
updatedAt,
|
|
782
961
|
userId,
|
|
783
962
|
}) {
|
|
784
|
-
super({
|
|
963
|
+
super({
|
|
964
|
+
amount,
|
|
965
|
+
createdAt,
|
|
966
|
+
descriptor,
|
|
967
|
+
status,
|
|
968
|
+
userId,
|
|
969
|
+
});
|
|
785
970
|
this.claimUrl = claimUrl;
|
|
786
971
|
this.destinationUri = destinationUri;
|
|
787
972
|
this.id = id;
|
|
788
973
|
this.expiresAt = data.dateToUTC(expiresAt);
|
|
789
|
-
this.network = data.enumValueFromString(
|
|
974
|
+
this.network = data.enumValueFromString(data.TransferNetwork, network);
|
|
790
975
|
this.phoneNumber = phoneNumber;
|
|
791
976
|
this.recipientName = recipientName;
|
|
792
977
|
this.trackingKey = trackingKey;
|
|
@@ -842,8 +1027,10 @@ const getModelFromPath = (path, obj) => {
|
|
|
842
1027
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
843
1028
|
statements: () => Statement.fromObject(obj),
|
|
844
1029
|
transfers: () => Transfer.fromObject(obj),
|
|
1030
|
+
users: () => User.fromObject(obj),
|
|
845
1031
|
user_credentials: () => UserCredential.fromObject(obj),
|
|
846
1032
|
user_logins: () => UserLogin.fromObject(obj),
|
|
1033
|
+
verifications: () => Verification.fromObject(obj),
|
|
847
1034
|
wallet_transactions: () => WalletTransaction.fromObject(obj),
|
|
848
1035
|
whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
|
|
849
1036
|
};
|
|
@@ -981,7 +1168,7 @@ const Queryable = (SuperClass) =>
|
|
|
981
1168
|
|
|
982
1169
|
class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
983
1170
|
constructor(client) {
|
|
984
|
-
super('accounts',
|
|
1171
|
+
super('accounts', identities.AccountQuery, client);
|
|
985
1172
|
}
|
|
986
1173
|
}
|
|
987
1174
|
|
|
@@ -993,7 +1180,7 @@ class ApiKeyResource extends mix(Resource).with(
|
|
|
993
1180
|
Updateable,
|
|
994
1181
|
) {
|
|
995
1182
|
constructor(client) {
|
|
996
|
-
super('api_keys',
|
|
1183
|
+
super('api_keys', identities.ApiKeyQuery, client);
|
|
997
1184
|
}
|
|
998
1185
|
|
|
999
1186
|
async create() {
|
|
@@ -1047,7 +1234,7 @@ class ArpcResource extends mix(Resource).with(Creatable) {
|
|
|
1047
1234
|
|
|
1048
1235
|
class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1049
1236
|
constructor(client) {
|
|
1050
|
-
super('balance_entries',
|
|
1237
|
+
super('balance_entries', identities.BalanceEntryQuery, client);
|
|
1051
1238
|
}
|
|
1052
1239
|
|
|
1053
1240
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1073,7 +1260,7 @@ class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1073
1260
|
|
|
1074
1261
|
class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1075
1262
|
constructor(client) {
|
|
1076
|
-
super('bill_payments',
|
|
1263
|
+
super('bill_payments', identities.BillPaymentQuery, client);
|
|
1077
1264
|
}
|
|
1078
1265
|
|
|
1079
1266
|
async serviceProvider(providerUri) {
|
|
@@ -1111,7 +1298,7 @@ class CardResource extends mix(Resource).with(
|
|
|
1111
1298
|
Updateable,
|
|
1112
1299
|
) {
|
|
1113
1300
|
constructor(client) {
|
|
1114
|
-
super('cards',
|
|
1301
|
+
super('cards', identities.CardsQuery, client);
|
|
1115
1302
|
}
|
|
1116
1303
|
|
|
1117
1304
|
async create(userId, issuer, fundingType) {
|
|
@@ -1137,7 +1324,7 @@ class CardTransactionResource extends mix(Resource).with(
|
|
|
1137
1324
|
Retrievable,
|
|
1138
1325
|
) {
|
|
1139
1326
|
constructor(client) {
|
|
1140
|
-
super('card_transactions',
|
|
1327
|
+
super('card_transactions', identities.CardTransactionQuery, client);
|
|
1141
1328
|
}
|
|
1142
1329
|
|
|
1143
1330
|
async relatedCard(relatedCardUri) {
|
|
@@ -1189,7 +1376,7 @@ class CardValidationResource extends mix(Resource).with(Creatable) {
|
|
|
1189
1376
|
|
|
1190
1377
|
class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1191
1378
|
constructor(client) {
|
|
1192
|
-
super('commissions',
|
|
1379
|
+
super('commissions', identities.QueryParams, client);
|
|
1193
1380
|
}
|
|
1194
1381
|
|
|
1195
1382
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1203,7 +1390,7 @@ class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1203
1390
|
|
|
1204
1391
|
class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1205
1392
|
constructor(client) {
|
|
1206
|
-
super('deposits',
|
|
1393
|
+
super('deposits', identities.DepositQuery, client);
|
|
1207
1394
|
}
|
|
1208
1395
|
|
|
1209
1396
|
async source(sourceUri) {
|
|
@@ -1231,7 +1418,7 @@ class SavingResource extends mix(Resource).with(
|
|
|
1231
1418
|
Updateable,
|
|
1232
1419
|
) {
|
|
1233
1420
|
constructor(client) {
|
|
1234
|
-
super('savings',
|
|
1421
|
+
super('savings', identities.WalletQuery, client);
|
|
1235
1422
|
}
|
|
1236
1423
|
|
|
1237
1424
|
async create(category, goalAmount, goalDate, name) {
|
|
@@ -1257,22 +1444,22 @@ class ServiceProviderResource extends mix(Resource).with(
|
|
|
1257
1444
|
Retrievable,
|
|
1258
1445
|
) {
|
|
1259
1446
|
constructor(client) {
|
|
1260
|
-
super('service_providers',
|
|
1447
|
+
super('service_providers', identities.QueryParams, client);
|
|
1261
1448
|
}
|
|
1262
1449
|
}
|
|
1263
1450
|
|
|
1264
1451
|
class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
|
|
1265
1452
|
constructor(client) {
|
|
1266
|
-
super('statements',
|
|
1453
|
+
super('statements', identities.StatementQuery, client);
|
|
1267
1454
|
}
|
|
1268
1455
|
|
|
1269
1456
|
async pdf(id) {
|
|
1270
|
-
const byteString = await this._download(id,
|
|
1457
|
+
const byteString = await this._download(id, data.FileFormat.Pdf);
|
|
1271
1458
|
return byteString;
|
|
1272
1459
|
}
|
|
1273
1460
|
|
|
1274
1461
|
async xml(id) {
|
|
1275
|
-
const byteString = await this._download(id,
|
|
1462
|
+
const byteString = await this._download(id, data.FileFormat.Xml);
|
|
1276
1463
|
return byteString;
|
|
1277
1464
|
}
|
|
1278
1465
|
}
|
|
@@ -1283,7 +1470,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1283
1470
|
Retrievable,
|
|
1284
1471
|
) {
|
|
1285
1472
|
constructor(client) {
|
|
1286
|
-
super('transfers',
|
|
1473
|
+
super('transfers', identities.TransferQuery, client);
|
|
1287
1474
|
}
|
|
1288
1475
|
|
|
1289
1476
|
async destination(destinationUri) {
|
|
@@ -1403,13 +1590,47 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1403
1590
|
}
|
|
1404
1591
|
}
|
|
1405
1592
|
|
|
1593
|
+
class UserResourse extends mix(Resource).with(
|
|
1594
|
+
Queryable,
|
|
1595
|
+
Updateable,
|
|
1596
|
+
Retrievable,
|
|
1597
|
+
) {
|
|
1598
|
+
constructor(client) {
|
|
1599
|
+
super('users', identities.UserQuery, client);
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
async update({ termsOfService, verificationId, userId = 'me' }) {
|
|
1603
|
+
const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService, verificationId });
|
|
1604
|
+
const user = await this._update(userId, request.toCleanObject());
|
|
1605
|
+
return user;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
class VerificationResourse extends mix(Resource).with(Creatable, Updateable) {
|
|
1610
|
+
constructor(client) {
|
|
1611
|
+
super('verifications', Object, client);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
async create({ platformId, recipient, type }) {
|
|
1615
|
+
const request = new walletTransactionRequest.VerificationRequest({ platformId, recipient, type });
|
|
1616
|
+
const verification = await this._create(request.toObject());
|
|
1617
|
+
return verification;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
async update({ code, id }) {
|
|
1621
|
+
const request = new walletTransactionRequest.VerificationAttemptRequest({ code });
|
|
1622
|
+
const verification = await this._update(id, request.toObject());
|
|
1623
|
+
return verification;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1406
1627
|
class WalletTransactionsResource extends mix(Resource).with(
|
|
1407
1628
|
Creatable,
|
|
1408
1629
|
Queryable,
|
|
1409
1630
|
Retrievable,
|
|
1410
1631
|
) {
|
|
1411
1632
|
constructor(client) {
|
|
1412
|
-
super('wallet_transactions',
|
|
1633
|
+
super('wallet_transactions', identities.WalletTransactionQuery, client);
|
|
1413
1634
|
}
|
|
1414
1635
|
|
|
1415
1636
|
async create(amount, transactionType, walletUri) {
|
|
@@ -1436,7 +1657,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1436
1657
|
Retrievable,
|
|
1437
1658
|
) {
|
|
1438
1659
|
constructor(client) {
|
|
1439
|
-
super('whatsapp_transfers',
|
|
1660
|
+
super('whatsapp_transfers', identities.QueryParams, client);
|
|
1440
1661
|
}
|
|
1441
1662
|
|
|
1442
1663
|
async accountDestination(destinationUri) {
|
|
@@ -1449,8 +1670,13 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1449
1670
|
}
|
|
1450
1671
|
|
|
1451
1672
|
class Cuenca {
|
|
1452
|
-
constructor(
|
|
1453
|
-
|
|
1673
|
+
constructor({
|
|
1674
|
+
apiKey,
|
|
1675
|
+
apiSecret,
|
|
1676
|
+
language = 'en',
|
|
1677
|
+
phase = data.Phase.Sandbox,
|
|
1678
|
+
} = {}) {
|
|
1679
|
+
this.client = new Client({ apiKey, apiSecret, language, phase });
|
|
1454
1680
|
this.withClient(this.client);
|
|
1455
1681
|
}
|
|
1456
1682
|
|
|
@@ -1472,47 +1698,11 @@ class Cuenca {
|
|
|
1472
1698
|
this.transfers = new TransferResource(client);
|
|
1473
1699
|
this.userCredentials = new UserCredentialResource(client);
|
|
1474
1700
|
this.userLogins = new UserLoginResource(client);
|
|
1701
|
+
this.users = new UserResourse(client);
|
|
1702
|
+
this.verifications = new VerificationResourse(client);
|
|
1475
1703
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1476
1704
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
|
1477
1705
|
}
|
|
1478
1706
|
}
|
|
1479
1707
|
|
|
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
1708
|
exports.Cuenca = Cuenca;
|