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