@cuenca-mx/cuenca-js 0.0.1-dev.3 → 0.0.1-dev.30
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/base-80b9a673.cjs +28 -0
- package/build/base-c1f04b51.mjs +24 -0
- package/build/errors/{index.js → index.cjs} +0 -0
- package/build/{queries-f146b91b.js → identities-122c79fd.mjs} +49 -2
- package/build/{queries-b8f29837.js → identities-d9bd3846.cjs} +54 -4
- package/build/{index.js → index.cjs} +199 -117
- package/build/index.mjs +133 -17
- package/build/jwt/{index.js → index.cjs} +7 -2
- package/build/jwt/index.mjs +2 -1
- package/build/requests/{index.js → index.cjs} +5 -3
- package/build/requests/index.mjs +2 -2
- package/build/types/index.cjs +43 -0
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-bbfb87bd.js → walletTransactionRequest-8b125547.mjs} +63 -16
- package/build/{walletTransactionRequest-b588cc52.js → walletTransactionRequest-bda66da3.cjs} +78 -29
- package/package.json +27 -4
- package/build/data-7d3d5fcc.js +0 -11
- package/build/data-c53f1052.js +0 -14
- package/build/types/index.js +0 -40
|
@@ -3,18 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var axios = require('axios');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
6
|
+
var Buffer = require('buffer');
|
|
7
|
+
var errors_index = require('./errors/index.cjs');
|
|
8
|
+
var jwt_index = require('./jwt/index.cjs');
|
|
9
|
+
var identities = require('./identities-d9bd3846.cjs');
|
|
10
|
+
var base = require('./base-80b9a673.cjs');
|
|
11
|
+
var walletTransactionRequest = require('./walletTransactionRequest-bda66da3.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.30";const description="Cuenca client for JS";const main="./build/index.cjs";const module$1="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports$1={".":{"import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{"import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{"import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{"import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{"import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.0.2";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const scripts={build:"rm -rf build/ && yarn rollup --config",test:"yarn node --experimental-vm-modules $(yarn bin jest)",publish:"yarn build && yarn npm publish"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1",jest:"^27.4.5",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2"};const dependencies={axios:"^0.24.0",buffer:"^6.0.3"};var pkg = {name:name,version:version,description:description,main:main,module:module$1,browser:browser,files:files,exports:exports$1,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
|
|
15
30
|
|
|
16
31
|
class Client {
|
|
17
|
-
constructor({ apiKey, apiSecret, phase =
|
|
32
|
+
constructor({ apiKey, apiSecret, phase = identities.Phase.Sandbox } = {}) {
|
|
18
33
|
this.phase = phase;
|
|
19
34
|
this.basicAuth = { apiKey, apiSecret };
|
|
20
35
|
this.jwtToken = null;
|
|
@@ -32,8 +47,9 @@ class Client {
|
|
|
32
47
|
get authHeader() {
|
|
33
48
|
const { apiKey, apiSecret } = this.basicAuth;
|
|
34
49
|
if (!apiKey || !apiSecret) return '';
|
|
35
|
-
return `Basic ${Buffer.from(
|
|
36
|
-
|
|
50
|
+
return `Basic ${Buffer__default["default"].Buffer.from(
|
|
51
|
+
`${apiKey}:${apiSecret}`,
|
|
52
|
+
'utf-8',
|
|
37
53
|
).toString('base64')}`;
|
|
38
54
|
}
|
|
39
55
|
|
|
@@ -113,17 +129,24 @@ class Client {
|
|
|
113
129
|
async request({
|
|
114
130
|
endpoint,
|
|
115
131
|
data = null,
|
|
116
|
-
format =
|
|
132
|
+
format = identities.FileFormat.Json,
|
|
117
133
|
method = 'GET',
|
|
118
134
|
params = null,
|
|
119
135
|
}) {
|
|
120
136
|
const headers = {
|
|
121
137
|
Authorization: this.authHeader,
|
|
122
|
-
'X-User-Agent': `cuenca-js/0.0.1`, // TODO: Change for client version
|
|
123
138
|
'Content-Type': 'application/json',
|
|
124
139
|
Accept: `application/${format.value}`,
|
|
125
140
|
};
|
|
126
141
|
|
|
142
|
+
if (runtimeEnv.isNode) {
|
|
143
|
+
headers['User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
144
|
+
} else if (runtimeEnv.isBrowser) {
|
|
145
|
+
// Cannot set User-Agent header on browsers
|
|
146
|
+
// https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
|
|
147
|
+
headers['X-User-Agent'] = `cuenca-js/${pkg.version}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
127
150
|
if (this.jwtToken) {
|
|
128
151
|
if (this.jwtToken.isExpired) {
|
|
129
152
|
this.jwtToken = await jwt_index.Jwt.create(this);
|
|
@@ -177,7 +200,7 @@ class Client {
|
|
|
177
200
|
class Account {
|
|
178
201
|
constructor({ accountNumber, createdAt, id, institutionName, name, userId }) {
|
|
179
202
|
this.accountNumber = accountNumber;
|
|
180
|
-
this.createdAt =
|
|
203
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
181
204
|
this.id = id;
|
|
182
205
|
this.institutionName = institutionName;
|
|
183
206
|
this.name = name;
|
|
@@ -197,12 +220,12 @@ class Account {
|
|
|
197
220
|
|
|
198
221
|
class ApiKey {
|
|
199
222
|
constructor({ createdAt, deactivatedAt, id, secret, userId, updatedAt }) {
|
|
200
|
-
this.createdAt =
|
|
201
|
-
this.deactivatedAt =
|
|
223
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
224
|
+
this.deactivatedAt = base.dateToUTC(deactivatedAt);
|
|
202
225
|
this.id = id;
|
|
203
226
|
this.secret = secret;
|
|
204
227
|
this.userId = userId;
|
|
205
|
-
this.updatedAt =
|
|
228
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
206
229
|
}
|
|
207
230
|
|
|
208
231
|
static fromObject = ({ id, secret, ...obj }) =>
|
|
@@ -216,7 +239,7 @@ class ApiKey {
|
|
|
216
239
|
});
|
|
217
240
|
|
|
218
241
|
get isActive() {
|
|
219
|
-
const todayUTC =
|
|
242
|
+
const todayUTC = base.dateToUTC(Date.now());
|
|
220
243
|
return (
|
|
221
244
|
!this.deactivatedAt || this.deactivatedAt.getTime() > todayUTC.getTime()
|
|
222
245
|
);
|
|
@@ -226,7 +249,7 @@ class ApiKey {
|
|
|
226
249
|
class Arpc {
|
|
227
250
|
constructor({ arpc, createdAt, cardUri, isValidArqc }) {
|
|
228
251
|
this.arpc = arpc;
|
|
229
|
-
this.createdAt =
|
|
252
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
230
253
|
this.cardUri = cardUri;
|
|
231
254
|
this.isValidArqc = isValidArqc;
|
|
232
255
|
}
|
|
@@ -253,9 +276,9 @@ class BalanceEntry {
|
|
|
253
276
|
rollingBalance,
|
|
254
277
|
}) {
|
|
255
278
|
this.amount = amount;
|
|
256
|
-
this.createdAt =
|
|
279
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
257
280
|
this.descriptor = descriptor;
|
|
258
|
-
this.entryType =
|
|
281
|
+
this.entryType = base.enumValueFromString(identities.EntryType, entryType);
|
|
259
282
|
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
260
283
|
this.id = id;
|
|
261
284
|
this.name = name;
|
|
@@ -280,9 +303,9 @@ class BalanceEntry {
|
|
|
280
303
|
class Transaction {
|
|
281
304
|
constructor({ amount, createdAt, descriptor, status, userId }) {
|
|
282
305
|
this.amount = amount;
|
|
283
|
-
this.createdAt =
|
|
306
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
284
307
|
this.descriptor = descriptor;
|
|
285
|
-
this.status =
|
|
308
|
+
this.status = base.enumValueFromString(identities.TransactionStatus, status);
|
|
286
309
|
this.userId = userId;
|
|
287
310
|
}
|
|
288
311
|
}
|
|
@@ -298,7 +321,13 @@ class BillPayment extends Transaction {
|
|
|
298
321
|
status,
|
|
299
322
|
userId,
|
|
300
323
|
}) {
|
|
301
|
-
super({
|
|
324
|
+
super({
|
|
325
|
+
amount,
|
|
326
|
+
createdAt,
|
|
327
|
+
descriptor,
|
|
328
|
+
status,
|
|
329
|
+
userId,
|
|
330
|
+
});
|
|
302
331
|
this.accountNumber = accountNumber;
|
|
303
332
|
this.id = id;
|
|
304
333
|
this.providerUri = providerUri;
|
|
@@ -333,18 +362,18 @@ class Card {
|
|
|
333
362
|
updatedAt,
|
|
334
363
|
userId,
|
|
335
364
|
}) {
|
|
336
|
-
this.createdAt =
|
|
365
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
337
366
|
this.cvv2 = cvv2;
|
|
338
367
|
this.expMonth = expMonth;
|
|
339
368
|
this.expYear = expYear;
|
|
340
|
-
this.fundingType =
|
|
369
|
+
this.fundingType = base.enumValueFromString(identities.CardFundingType, fundingType);
|
|
341
370
|
this.id = id;
|
|
342
|
-
this.issuer =
|
|
371
|
+
this.issuer = base.enumValueFromString(identities.CardIssuer, issuer);
|
|
343
372
|
this.number = number;
|
|
344
373
|
this.pin = pin;
|
|
345
|
-
this.status =
|
|
346
|
-
this.type =
|
|
347
|
-
this.updatedAt =
|
|
374
|
+
this.status = base.enumValueFromString(identities.CardStatus, status);
|
|
375
|
+
this.type = base.enumValueFromString(identities.CardType, type);
|
|
376
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
348
377
|
this.userId = userId;
|
|
349
378
|
}
|
|
350
379
|
|
|
@@ -378,7 +407,7 @@ class Card {
|
|
|
378
407
|
class CardActivation {
|
|
379
408
|
constructor({ cardUri, createdAt, id, ipAddress, success, userId }) {
|
|
380
409
|
this.cardUri = cardUri;
|
|
381
|
-
this.createdAt =
|
|
410
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
382
411
|
this.id = id;
|
|
383
412
|
this.ipAddress = ipAddress;
|
|
384
413
|
this.success = success;
|
|
@@ -412,15 +441,21 @@ class CardTransaction extends Transaction {
|
|
|
412
441
|
type,
|
|
413
442
|
userId,
|
|
414
443
|
}) {
|
|
415
|
-
super({
|
|
416
|
-
|
|
444
|
+
super({
|
|
445
|
+
amount,
|
|
446
|
+
createdAt,
|
|
447
|
+
descriptor,
|
|
448
|
+
status,
|
|
449
|
+
userId,
|
|
450
|
+
});
|
|
451
|
+
this.cardErrorType = base.enumValueFromString(identities.CardErrorType, cardErrorType);
|
|
417
452
|
this.cardLastFour = cardLastFour;
|
|
418
|
-
this.cardType =
|
|
453
|
+
this.cardType = base.enumValueFromString(identities.CardType, cardType);
|
|
419
454
|
this.cardUri = cardUri;
|
|
420
455
|
this.metadata = metadata;
|
|
421
456
|
this.network = network;
|
|
422
457
|
this.relatedCardTransactionsUris = relatedCardTransactionsUris;
|
|
423
|
-
this.type =
|
|
458
|
+
this.type = base.enumValueFromString(identities.CardTransactionType, type);
|
|
424
459
|
}
|
|
425
460
|
|
|
426
461
|
static fromObject = ({
|
|
@@ -464,10 +499,10 @@ class CardValidation {
|
|
|
464
499
|
isValidPinBlock,
|
|
465
500
|
userId,
|
|
466
501
|
}) {
|
|
467
|
-
this.cardStatus =
|
|
468
|
-
this.cardType =
|
|
502
|
+
this.cardStatus = base.enumValueFromString(identities.CardStatus, cardStatus);
|
|
503
|
+
this.cardType = base.enumValueFromString(identities.CardType, cardType);
|
|
469
504
|
this.cardUri = cardUri;
|
|
470
|
-
this.createdAt =
|
|
505
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
471
506
|
this.isExpired = isExpired;
|
|
472
507
|
this.isPinAttemptsExceeded = isPinAttemptsExceeded;
|
|
473
508
|
this.isValidCvv = isValidCvv;
|
|
@@ -495,7 +530,7 @@ class CardValidation {
|
|
|
495
530
|
});
|
|
496
531
|
|
|
497
532
|
get isActive() {
|
|
498
|
-
return this.cardStatus ===
|
|
533
|
+
return this.cardStatus === identities.CardStatus.Active;
|
|
499
534
|
}
|
|
500
535
|
}
|
|
501
536
|
|
|
@@ -509,9 +544,15 @@ class Commission extends Transaction {
|
|
|
509
544
|
type,
|
|
510
545
|
userId,
|
|
511
546
|
}) {
|
|
512
|
-
super({
|
|
547
|
+
super({
|
|
548
|
+
amount,
|
|
549
|
+
createdAt,
|
|
550
|
+
descriptor,
|
|
551
|
+
status,
|
|
552
|
+
userId,
|
|
553
|
+
});
|
|
513
554
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
514
|
-
this.type =
|
|
555
|
+
this.type = base.enumValueFromString(identities.CommissionType, type);
|
|
515
556
|
}
|
|
516
557
|
|
|
517
558
|
static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
|
|
@@ -538,9 +579,15 @@ class Deposit extends Transaction {
|
|
|
538
579
|
trackingKey,
|
|
539
580
|
userId,
|
|
540
581
|
}) {
|
|
541
|
-
super({
|
|
582
|
+
super({
|
|
583
|
+
amount,
|
|
584
|
+
createdAt,
|
|
585
|
+
descriptor,
|
|
586
|
+
status,
|
|
587
|
+
userId,
|
|
588
|
+
});
|
|
542
589
|
this.id = id;
|
|
543
|
-
this.network =
|
|
590
|
+
this.network = base.enumValueFromString(identities.DepositNetwork, network);
|
|
544
591
|
this.sourceUri = sourceUri;
|
|
545
592
|
this.trackingKey = trackingKey;
|
|
546
593
|
}
|
|
@@ -570,11 +617,11 @@ class LoginToken {
|
|
|
570
617
|
class Wallet {
|
|
571
618
|
constructor({ balance, createdAt, deactivatedAt, id, userId, updatedAt }) {
|
|
572
619
|
this.balance = balance;
|
|
573
|
-
this.createdAt =
|
|
574
|
-
this.deactivatedAt =
|
|
620
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
621
|
+
this.deactivatedAt = base.dateToUTC(deactivatedAt);
|
|
575
622
|
this.id = id;
|
|
576
623
|
this.userId = userId;
|
|
577
|
-
this.updatedAt =
|
|
624
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
578
625
|
}
|
|
579
626
|
}
|
|
580
627
|
|
|
@@ -591,10 +638,17 @@ class Saving extends Wallet {
|
|
|
591
638
|
userId,
|
|
592
639
|
updatedAt,
|
|
593
640
|
}) {
|
|
594
|
-
super({
|
|
595
|
-
|
|
641
|
+
super({
|
|
642
|
+
balance,
|
|
643
|
+
createdAt,
|
|
644
|
+
deactivatedAt,
|
|
645
|
+
id,
|
|
646
|
+
userId,
|
|
647
|
+
updatedAt,
|
|
648
|
+
});
|
|
649
|
+
this.category = base.enumValueFromString(identities.SavingCategory, category);
|
|
596
650
|
this.goalAmount = goalAmount;
|
|
597
|
-
this.goalDate =
|
|
651
|
+
this.goalDate = base.dateToUTC(goalDate);
|
|
598
652
|
this.name = name;
|
|
599
653
|
}
|
|
600
654
|
|
|
@@ -616,7 +670,7 @@ class Saving extends Wallet {
|
|
|
616
670
|
const categoriesFromString = (categoriesList) => {
|
|
617
671
|
if (categoriesList == null) return [];
|
|
618
672
|
return categoriesList.map((category) =>
|
|
619
|
-
|
|
673
|
+
base.enumValueFromString(identities.ServiceProviderCategory, category),
|
|
620
674
|
);
|
|
621
675
|
};
|
|
622
676
|
|
|
@@ -639,7 +693,7 @@ class ServiceProvider {
|
|
|
639
693
|
|
|
640
694
|
class Statement {
|
|
641
695
|
constructor({ createdAt, id, month, year }) {
|
|
642
|
-
this.createdAt =
|
|
696
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
643
697
|
this.id = id;
|
|
644
698
|
this.month = month;
|
|
645
699
|
this.year = year;
|
|
@@ -670,15 +724,21 @@ class Transfer extends Transaction {
|
|
|
670
724
|
updatedAt,
|
|
671
725
|
userId,
|
|
672
726
|
}) {
|
|
673
|
-
super({
|
|
727
|
+
super({
|
|
728
|
+
amount,
|
|
729
|
+
createdAt,
|
|
730
|
+
descriptor,
|
|
731
|
+
status,
|
|
732
|
+
userId,
|
|
733
|
+
});
|
|
674
734
|
this.accountNumber = accountNumber;
|
|
675
735
|
this.destinationUri = destinationUri;
|
|
676
736
|
this.id = id;
|
|
677
737
|
this.idempotencyKey = idempotencyKey;
|
|
678
|
-
this.network =
|
|
738
|
+
this.network = base.enumValueFromString(identities.TransferNetwork, network);
|
|
679
739
|
this.recipientName = recipientName;
|
|
680
740
|
this.trackingKey = trackingKey;
|
|
681
|
-
this.updatedAt =
|
|
741
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
682
742
|
}
|
|
683
743
|
|
|
684
744
|
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
@@ -699,12 +759,46 @@ class Transfer extends Transaction {
|
|
|
699
759
|
});
|
|
700
760
|
}
|
|
701
761
|
|
|
762
|
+
class User {
|
|
763
|
+
constructor({
|
|
764
|
+
emailAddress,
|
|
765
|
+
phoneNumber,
|
|
766
|
+
status,
|
|
767
|
+
termsOfService,
|
|
768
|
+
verificationId,
|
|
769
|
+
}) {
|
|
770
|
+
this.emailAddress = emailAddress;
|
|
771
|
+
this.phoneNumber = phoneNumber;
|
|
772
|
+
this.status = base.enumValueFromString(identities.UserStatus, status);
|
|
773
|
+
this.terms = termsOfService;
|
|
774
|
+
this.verificationId = verificationId;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
get termsOfService() {
|
|
778
|
+
return this._termsOfService;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
set terms(value) {
|
|
782
|
+
if (!value) return;
|
|
783
|
+
this._termsOfService = identities.TOSAgreements.fromObject(value);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
static fromObject = ({ ...obj }) =>
|
|
787
|
+
new User({
|
|
788
|
+
emailAddress: obj.email_address,
|
|
789
|
+
phoneNumber: obj.phone_number,
|
|
790
|
+
status: obj.status,
|
|
791
|
+
termsOfService: obj.terms_of_service,
|
|
792
|
+
verificationId: obj.verification_id,
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
|
|
702
796
|
class UserCredential {
|
|
703
797
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
704
|
-
this.createdAt =
|
|
798
|
+
this.createdAt = base.dateToUTC(createdAt);
|
|
705
799
|
this.id = id;
|
|
706
800
|
this.isActive = isActive;
|
|
707
|
-
this.updatedAt =
|
|
801
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
708
802
|
}
|
|
709
803
|
|
|
710
804
|
static fromObject = ({ id, ...obj }) =>
|
|
@@ -719,7 +813,7 @@ class UserCredential {
|
|
|
719
813
|
class UserLogin {
|
|
720
814
|
constructor({ id, lastLoginAt, success }) {
|
|
721
815
|
this.id = id;
|
|
722
|
-
this.lastLoginAt =
|
|
816
|
+
this.lastLoginAt = base.dateToUTC(lastLoginAt);
|
|
723
817
|
this.success = success;
|
|
724
818
|
}
|
|
725
819
|
|
|
@@ -742,10 +836,16 @@ class WalletTransaction extends Transaction {
|
|
|
742
836
|
userId,
|
|
743
837
|
walletUri,
|
|
744
838
|
}) {
|
|
745
|
-
super({
|
|
839
|
+
super({
|
|
840
|
+
amount,
|
|
841
|
+
createdAt,
|
|
842
|
+
descriptor,
|
|
843
|
+
status,
|
|
844
|
+
userId,
|
|
845
|
+
});
|
|
746
846
|
this.id = id;
|
|
747
|
-
this.transactionType =
|
|
748
|
-
|
|
847
|
+
this.transactionType = base.enumValueFromString(
|
|
848
|
+
identities.WalletTransactionType,
|
|
749
849
|
transactionType,
|
|
750
850
|
);
|
|
751
851
|
this.walletUri = walletUri;
|
|
@@ -781,16 +881,22 @@ class WhatsAppTransfer extends Transaction {
|
|
|
781
881
|
updatedAt,
|
|
782
882
|
userId,
|
|
783
883
|
}) {
|
|
784
|
-
super({
|
|
884
|
+
super({
|
|
885
|
+
amount,
|
|
886
|
+
createdAt,
|
|
887
|
+
descriptor,
|
|
888
|
+
status,
|
|
889
|
+
userId,
|
|
890
|
+
});
|
|
785
891
|
this.claimUrl = claimUrl;
|
|
786
892
|
this.destinationUri = destinationUri;
|
|
787
893
|
this.id = id;
|
|
788
|
-
this.expiresAt =
|
|
789
|
-
this.network =
|
|
894
|
+
this.expiresAt = base.dateToUTC(expiresAt);
|
|
895
|
+
this.network = base.enumValueFromString(identities.TransferNetwork, network);
|
|
790
896
|
this.phoneNumber = phoneNumber;
|
|
791
897
|
this.recipientName = recipientName;
|
|
792
898
|
this.trackingKey = trackingKey;
|
|
793
|
-
this.updatedAt =
|
|
899
|
+
this.updatedAt = base.dateToUTC(updatedAt);
|
|
794
900
|
}
|
|
795
901
|
|
|
796
902
|
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
@@ -842,6 +948,7 @@ const getModelFromPath = (path, obj) => {
|
|
|
842
948
|
service_providers: () => ServiceProvider.fromObject(obj),
|
|
843
949
|
statements: () => Statement.fromObject(obj),
|
|
844
950
|
transfers: () => Transfer.fromObject(obj),
|
|
951
|
+
users: () => User.fromObject(obj),
|
|
845
952
|
user_credentials: () => UserCredential.fromObject(obj),
|
|
846
953
|
user_logins: () => UserLogin.fromObject(obj),
|
|
847
954
|
wallet_transactions: () => WalletTransaction.fromObject(obj),
|
|
@@ -981,7 +1088,7 @@ const Queryable = (SuperClass) =>
|
|
|
981
1088
|
|
|
982
1089
|
class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
983
1090
|
constructor(client) {
|
|
984
|
-
super('accounts',
|
|
1091
|
+
super('accounts', identities.AccountQuery, client);
|
|
985
1092
|
}
|
|
986
1093
|
}
|
|
987
1094
|
|
|
@@ -993,7 +1100,7 @@ class ApiKeyResource extends mix(Resource).with(
|
|
|
993
1100
|
Updateable,
|
|
994
1101
|
) {
|
|
995
1102
|
constructor(client) {
|
|
996
|
-
super('api_keys',
|
|
1103
|
+
super('api_keys', identities.ApiKeyQuery, client);
|
|
997
1104
|
}
|
|
998
1105
|
|
|
999
1106
|
async create() {
|
|
@@ -1047,7 +1154,7 @@ class ArpcResource extends mix(Resource).with(Creatable) {
|
|
|
1047
1154
|
|
|
1048
1155
|
class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1049
1156
|
constructor(client) {
|
|
1050
|
-
super('balance_entries',
|
|
1157
|
+
super('balance_entries', identities.BalanceEntryQuery, client);
|
|
1051
1158
|
}
|
|
1052
1159
|
|
|
1053
1160
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1073,7 +1180,7 @@ class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1073
1180
|
|
|
1074
1181
|
class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1075
1182
|
constructor(client) {
|
|
1076
|
-
super('bill_payments',
|
|
1183
|
+
super('bill_payments', identities.BillPaymentQuery, client);
|
|
1077
1184
|
}
|
|
1078
1185
|
|
|
1079
1186
|
async serviceProvider(providerUri) {
|
|
@@ -1111,7 +1218,7 @@ class CardResource extends mix(Resource).with(
|
|
|
1111
1218
|
Updateable,
|
|
1112
1219
|
) {
|
|
1113
1220
|
constructor(client) {
|
|
1114
|
-
super('cards',
|
|
1221
|
+
super('cards', identities.CardsQuery, client);
|
|
1115
1222
|
}
|
|
1116
1223
|
|
|
1117
1224
|
async create(userId, issuer, fundingType) {
|
|
@@ -1137,7 +1244,7 @@ class CardTransactionResource extends mix(Resource).with(
|
|
|
1137
1244
|
Retrievable,
|
|
1138
1245
|
) {
|
|
1139
1246
|
constructor(client) {
|
|
1140
|
-
super('card_transactions',
|
|
1247
|
+
super('card_transactions', identities.CardTransactionQuery, client);
|
|
1141
1248
|
}
|
|
1142
1249
|
|
|
1143
1250
|
async relatedCard(relatedCardUri) {
|
|
@@ -1189,7 +1296,7 @@ class CardValidationResource extends mix(Resource).with(Creatable) {
|
|
|
1189
1296
|
|
|
1190
1297
|
class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1191
1298
|
constructor(client) {
|
|
1192
|
-
super('commissions',
|
|
1299
|
+
super('commissions', identities.QueryParams, client);
|
|
1193
1300
|
}
|
|
1194
1301
|
|
|
1195
1302
|
async relatedTransaction(relatedTransactionUri) {
|
|
@@ -1203,7 +1310,7 @@ class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
|
1203
1310
|
|
|
1204
1311
|
class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
|
|
1205
1312
|
constructor(client) {
|
|
1206
|
-
super('deposits',
|
|
1313
|
+
super('deposits', identities.DepositQuery, client);
|
|
1207
1314
|
}
|
|
1208
1315
|
|
|
1209
1316
|
async source(sourceUri) {
|
|
@@ -1231,7 +1338,7 @@ class SavingResource extends mix(Resource).with(
|
|
|
1231
1338
|
Updateable,
|
|
1232
1339
|
) {
|
|
1233
1340
|
constructor(client) {
|
|
1234
|
-
super('savings',
|
|
1341
|
+
super('savings', identities.WalletQuery, client);
|
|
1235
1342
|
}
|
|
1236
1343
|
|
|
1237
1344
|
async create(category, goalAmount, goalDate, name) {
|
|
@@ -1257,22 +1364,22 @@ class ServiceProviderResource extends mix(Resource).with(
|
|
|
1257
1364
|
Retrievable,
|
|
1258
1365
|
) {
|
|
1259
1366
|
constructor(client) {
|
|
1260
|
-
super('service_providers',
|
|
1367
|
+
super('service_providers', identities.QueryParams, client);
|
|
1261
1368
|
}
|
|
1262
1369
|
}
|
|
1263
1370
|
|
|
1264
1371
|
class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
|
|
1265
1372
|
constructor(client) {
|
|
1266
|
-
super('statements',
|
|
1373
|
+
super('statements', identities.StatementQuery, client);
|
|
1267
1374
|
}
|
|
1268
1375
|
|
|
1269
1376
|
async pdf(id) {
|
|
1270
|
-
const byteString = await this._download(id,
|
|
1377
|
+
const byteString = await this._download(id, identities.FileFormat.Pdf);
|
|
1271
1378
|
return byteString;
|
|
1272
1379
|
}
|
|
1273
1380
|
|
|
1274
1381
|
async xml(id) {
|
|
1275
|
-
const byteString = await this._download(id,
|
|
1382
|
+
const byteString = await this._download(id, identities.FileFormat.Xml);
|
|
1276
1383
|
return byteString;
|
|
1277
1384
|
}
|
|
1278
1385
|
}
|
|
@@ -1283,7 +1390,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1283
1390
|
Retrievable,
|
|
1284
1391
|
) {
|
|
1285
1392
|
constructor(client) {
|
|
1286
|
-
super('transfers',
|
|
1393
|
+
super('transfers', identities.TransferQuery, client);
|
|
1287
1394
|
}
|
|
1288
1395
|
|
|
1289
1396
|
async destination(destinationUri) {
|
|
@@ -1351,7 +1458,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1351
1458
|
}
|
|
1352
1459
|
|
|
1353
1460
|
static _genIdempotencyKey(accountNumber, amount) {
|
|
1354
|
-
const [date] =
|
|
1461
|
+
const [date] = base.dateToUTC(Date.now()).toISOString().split('T');
|
|
1355
1462
|
return `${date}:${accountNumber}:${amount}`;
|
|
1356
1463
|
}
|
|
1357
1464
|
}
|
|
@@ -1403,13 +1510,25 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1403
1510
|
}
|
|
1404
1511
|
}
|
|
1405
1512
|
|
|
1513
|
+
class UserResourse extends mix(Resource).with(Queryable, Updateable) {
|
|
1514
|
+
constructor(client) {
|
|
1515
|
+
super('users', identities.UserQuery, client);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
async update({ termsOfService, userId = 'me', verificationId }) {
|
|
1519
|
+
const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService, verificationId });
|
|
1520
|
+
const user = await this._update(userId, request.toCleanObject());
|
|
1521
|
+
return user;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1406
1525
|
class WalletTransactionsResource extends mix(Resource).with(
|
|
1407
1526
|
Creatable,
|
|
1408
1527
|
Queryable,
|
|
1409
1528
|
Retrievable,
|
|
1410
1529
|
) {
|
|
1411
1530
|
constructor(client) {
|
|
1412
|
-
super('wallet_transactions',
|
|
1531
|
+
super('wallet_transactions', identities.WalletTransactionQuery, client);
|
|
1413
1532
|
}
|
|
1414
1533
|
|
|
1415
1534
|
async create(amount, transactionType, walletUri) {
|
|
@@ -1436,7 +1555,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1436
1555
|
Retrievable,
|
|
1437
1556
|
) {
|
|
1438
1557
|
constructor(client) {
|
|
1439
|
-
super('whatsapp_transfers',
|
|
1558
|
+
super('whatsapp_transfers', identities.QueryParams, client);
|
|
1440
1559
|
}
|
|
1441
1560
|
|
|
1442
1561
|
async accountDestination(destinationUri) {
|
|
@@ -1449,7 +1568,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
|
|
|
1449
1568
|
}
|
|
1450
1569
|
|
|
1451
1570
|
class Cuenca {
|
|
1452
|
-
constructor(apiKey, apiSecret, phase =
|
|
1571
|
+
constructor(apiKey, apiSecret, phase = identities.Phase.Sandbox) {
|
|
1453
1572
|
this.client = new Client({ apiKey, apiSecret, phase });
|
|
1454
1573
|
this.withClient(this.client);
|
|
1455
1574
|
}
|
|
@@ -1470,6 +1589,7 @@ class Cuenca {
|
|
|
1470
1589
|
this.serviceProviders = new ServiceProviderResource(client);
|
|
1471
1590
|
this.statements = new StatementResource(client);
|
|
1472
1591
|
this.transfers = new TransferResource(client);
|
|
1592
|
+
this.users = new UserResourse(client);
|
|
1473
1593
|
this.userCredentials = new UserCredentialResource(client);
|
|
1474
1594
|
this.userLogins = new UserLoginResource(client);
|
|
1475
1595
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
@@ -1477,42 +1597,4 @@ class Cuenca {
|
|
|
1477
1597
|
}
|
|
1478
1598
|
}
|
|
1479
1599
|
|
|
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
1600
|
exports.Cuenca = Cuenca;
|