@cuenca-mx/cuenca-js 0.0.1-dev.30 → 0.0.1-dev.33
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/build/{base-80b9a673.cjs → data-9edbb2a0.cjs} +0 -15
- package/build/data-d5bcb7c8.mjs +10 -0
- package/build/{identities-d9bd3846.cjs → identities-434e06c7.cjs} +62 -7
- package/build/{identities-122c79fd.mjs → identities-915953e4.mjs} +58 -6
- package/build/index.cjs +108 -53
- package/build/index.mjs +65 -10
- package/build/requests/index.cjs +2 -3
- package/build/requests/index.mjs +2 -2
- package/build/types/index.cjs +5 -2
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-8b125547.mjs → walletTransactionRequest-4e6b348f.mjs} +52 -39
- package/build/{walletTransactionRequest-bda66da3.cjs → walletTransactionRequest-572c455b.cjs} +65 -53
- package/package.json +1 -1
- package/build/base-c1f04b51.mjs +0 -24
|
@@ -9,20 +9,5 @@ const dateToUTC = (date) => {
|
|
|
9
9
|
const enumValueFromString = (enumValue, value) =>
|
|
10
10
|
Object.values(enumValue).find((enumV) => enumV.value === value);
|
|
11
11
|
|
|
12
|
-
class BaseRequest {
|
|
13
|
-
toObject() {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
toCleanObject() {
|
|
18
|
-
const obj = this.toObject();
|
|
19
|
-
Object.keys(obj).forEach((k) => {
|
|
20
|
-
if (obj[k] == null) delete obj[k];
|
|
21
|
-
});
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
exports.BaseRequest = BaseRequest;
|
|
27
12
|
exports.dateToUTC = dateToUTC;
|
|
28
13
|
exports.enumValueFromString = enumValueFromString;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const dateToUTC = (date) => {
|
|
2
|
+
if (!date) return null;
|
|
3
|
+
const dateObj = new Date(date);
|
|
4
|
+
return new Date(dateObj.getTime());
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const enumValueFromString = (enumValue, value) =>
|
|
8
|
+
Object.values(enumValue).find((enumV) => enumV.value === value);
|
|
9
|
+
|
|
10
|
+
export { dateToUTC as d, enumValueFromString as e };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var errors_index = require('./errors/index.cjs');
|
|
4
|
-
var
|
|
4
|
+
var data = require('./data-9edbb2a0.cjs');
|
|
5
5
|
|
|
6
6
|
class CardErrorType {
|
|
7
7
|
static Blocked = new CardErrorType('blocked');
|
|
@@ -141,6 +141,38 @@ class FileFormat {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
class KYCFileType {
|
|
145
|
+
static Ine = new KYCFileType('ine');
|
|
146
|
+
|
|
147
|
+
static Passport = new KYCFileType('passport');
|
|
148
|
+
|
|
149
|
+
static Residency = new KYCFileType('residency');
|
|
150
|
+
|
|
151
|
+
static MatriculaConsular = new KYCFileType('matricula_consular');
|
|
152
|
+
|
|
153
|
+
static ProofOfLiveness = new KYCFileType('proof_of_liveness');
|
|
154
|
+
|
|
155
|
+
static ProofOfAddress = new KYCFileType('proof_of_address');
|
|
156
|
+
|
|
157
|
+
constructor(value) {
|
|
158
|
+
this.value = value;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
class KYCStatus {
|
|
163
|
+
static UploadAgain = new KYCStatus('upload_again');
|
|
164
|
+
|
|
165
|
+
static ReviewNeeded = new KYCStatus('review_needed');
|
|
166
|
+
|
|
167
|
+
static Submitted = new KYCStatus('submitted');
|
|
168
|
+
|
|
169
|
+
static Succeeded = new KYCStatus('succeeded');
|
|
170
|
+
|
|
171
|
+
constructor(value) {
|
|
172
|
+
this.value = value;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
144
176
|
class Phase {
|
|
145
177
|
static Sandbox = new Phase('sandbox');
|
|
146
178
|
|
|
@@ -262,9 +294,9 @@ class UserStatus {
|
|
|
262
294
|
|
|
263
295
|
static Deactivated = new UserStatus('deactivated');
|
|
264
296
|
|
|
265
|
-
static
|
|
297
|
+
static Fraud = new UserStatus('fraud');
|
|
266
298
|
|
|
267
|
-
static
|
|
299
|
+
static PldBlocked = new UserStatus('pld_blocked');
|
|
268
300
|
|
|
269
301
|
constructor(value) {
|
|
270
302
|
this.value = value;
|
|
@@ -557,9 +589,9 @@ class StatementQuery extends QueryParams {
|
|
|
557
589
|
}
|
|
558
590
|
|
|
559
591
|
set d({ month, year }) {
|
|
560
|
-
const now =
|
|
592
|
+
const now = data.dateToUTC(Date.now());
|
|
561
593
|
now.setUTCDate(1);
|
|
562
|
-
const date =
|
|
594
|
+
const date = data.dateToUTC(`${year}-${month}-01`);
|
|
563
595
|
if (date.getTime() >= now.getTime()) {
|
|
564
596
|
throw new errors_index.ValidationError(
|
|
565
597
|
`${year}-${month} is not a valid year-month pair`,
|
|
@@ -576,9 +608,8 @@ class StatementQuery extends QueryParams {
|
|
|
576
608
|
}
|
|
577
609
|
}
|
|
578
610
|
|
|
579
|
-
class TOSAgreements
|
|
611
|
+
class TOSAgreements {
|
|
580
612
|
constructor({ ip, location, version }) {
|
|
581
|
-
super();
|
|
582
613
|
this.ip = ip;
|
|
583
614
|
this.location = location;
|
|
584
615
|
this.version = version;
|
|
@@ -592,6 +623,27 @@ class TOSAgreements extends base.BaseRequest {
|
|
|
592
623
|
});
|
|
593
624
|
}
|
|
594
625
|
|
|
626
|
+
class KYCFile {
|
|
627
|
+
constructor({ data: data$1, isMx, status, type, uriBack, uriFront }) {
|
|
628
|
+
this.data = data$1;
|
|
629
|
+
this.isMx = isMx;
|
|
630
|
+
this.status = data.enumValueFromString(KYCStatus, status);
|
|
631
|
+
this.type = data.enumValueFromString(KYCFileType, type);
|
|
632
|
+
this.uriBack = uriBack;
|
|
633
|
+
this.uriFront = uriFront;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
static fromObject = ({ data, isMx, status, type, ...obj }) =>
|
|
637
|
+
new KYCFile({
|
|
638
|
+
data,
|
|
639
|
+
isMx,
|
|
640
|
+
status,
|
|
641
|
+
type,
|
|
642
|
+
uriBack: obj.uri_back,
|
|
643
|
+
uriFront: obj.uri_front,
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
595
647
|
exports.AccountQuery = AccountQuery;
|
|
596
648
|
exports.ApiKeyQuery = ApiKeyQuery;
|
|
597
649
|
exports.BalanceEntryQuery = BalanceEntryQuery;
|
|
@@ -609,6 +661,9 @@ exports.DepositNetwork = DepositNetwork;
|
|
|
609
661
|
exports.DepositQuery = DepositQuery;
|
|
610
662
|
exports.EntryType = EntryType;
|
|
611
663
|
exports.FileFormat = FileFormat;
|
|
664
|
+
exports.KYCFile = KYCFile;
|
|
665
|
+
exports.KYCFileType = KYCFileType;
|
|
666
|
+
exports.KYCStatus = KYCStatus;
|
|
612
667
|
exports.PageSize = PageSize;
|
|
613
668
|
exports.Phase = Phase;
|
|
614
669
|
exports.QueryParams = QueryParams;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidationError } from './errors/index.mjs';
|
|
2
|
-
import { d as dateToUTC,
|
|
2
|
+
import { d as dateToUTC, e as enumValueFromString } from './data-d5bcb7c8.mjs';
|
|
3
3
|
|
|
4
4
|
class CardErrorType {
|
|
5
5
|
static Blocked = new CardErrorType('blocked');
|
|
@@ -139,6 +139,38 @@ class FileFormat {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
class KYCFileType {
|
|
143
|
+
static Ine = new KYCFileType('ine');
|
|
144
|
+
|
|
145
|
+
static Passport = new KYCFileType('passport');
|
|
146
|
+
|
|
147
|
+
static Residency = new KYCFileType('residency');
|
|
148
|
+
|
|
149
|
+
static MatriculaConsular = new KYCFileType('matricula_consular');
|
|
150
|
+
|
|
151
|
+
static ProofOfLiveness = new KYCFileType('proof_of_liveness');
|
|
152
|
+
|
|
153
|
+
static ProofOfAddress = new KYCFileType('proof_of_address');
|
|
154
|
+
|
|
155
|
+
constructor(value) {
|
|
156
|
+
this.value = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class KYCStatus {
|
|
161
|
+
static UploadAgain = new KYCStatus('upload_again');
|
|
162
|
+
|
|
163
|
+
static ReviewNeeded = new KYCStatus('review_needed');
|
|
164
|
+
|
|
165
|
+
static Submitted = new KYCStatus('submitted');
|
|
166
|
+
|
|
167
|
+
static Succeeded = new KYCStatus('succeeded');
|
|
168
|
+
|
|
169
|
+
constructor(value) {
|
|
170
|
+
this.value = value;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
142
174
|
class Phase {
|
|
143
175
|
static Sandbox = new Phase('sandbox');
|
|
144
176
|
|
|
@@ -260,9 +292,9 @@ class UserStatus {
|
|
|
260
292
|
|
|
261
293
|
static Deactivated = new UserStatus('deactivated');
|
|
262
294
|
|
|
263
|
-
static
|
|
295
|
+
static Fraud = new UserStatus('fraud');
|
|
264
296
|
|
|
265
|
-
static
|
|
297
|
+
static PldBlocked = new UserStatus('pld_blocked');
|
|
266
298
|
|
|
267
299
|
constructor(value) {
|
|
268
300
|
this.value = value;
|
|
@@ -574,9 +606,8 @@ class StatementQuery extends QueryParams {
|
|
|
574
606
|
}
|
|
575
607
|
}
|
|
576
608
|
|
|
577
|
-
class TOSAgreements
|
|
609
|
+
class TOSAgreements {
|
|
578
610
|
constructor({ ip, location, version }) {
|
|
579
|
-
super();
|
|
580
611
|
this.ip = ip;
|
|
581
612
|
this.location = location;
|
|
582
613
|
this.version = version;
|
|
@@ -590,4 +621,25 @@ class TOSAgreements extends BaseRequest {
|
|
|
590
621
|
});
|
|
591
622
|
}
|
|
592
623
|
|
|
593
|
-
|
|
624
|
+
class KYCFile {
|
|
625
|
+
constructor({ data, isMx, status, type, uriBack, uriFront }) {
|
|
626
|
+
this.data = data;
|
|
627
|
+
this.isMx = isMx;
|
|
628
|
+
this.status = enumValueFromString(KYCStatus, status);
|
|
629
|
+
this.type = enumValueFromString(KYCFileType, type);
|
|
630
|
+
this.uriBack = uriBack;
|
|
631
|
+
this.uriFront = uriFront;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
static fromObject = ({ data, isMx, status, type, ...obj }) =>
|
|
635
|
+
new KYCFile({
|
|
636
|
+
data,
|
|
637
|
+
isMx,
|
|
638
|
+
status,
|
|
639
|
+
type,
|
|
640
|
+
uriBack: obj.uri_back,
|
|
641
|
+
uriFront: obj.uri_front,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export { AccountQuery as A, BalanceEntryQuery as B, CardFundingType as C, DepositNetwork as D, EntryType as E, FileFormat as F, KYCFile as K, Phase as P, QueryParams as Q, SavingCategory as S, TransactionStatus as T, UserStatus as U, WalletTransactionType as W, CardIssuer as a, CardStatus as b, CardType as c, CardErrorType as d, CardTransactionType as e, CommissionType as f, ServiceProviderCategory as g, TransferNetwork as h, TOSAgreements as i, ApiKeyQuery as j, BillPaymentQuery as k, CardsQuery as l, CardTransactionQuery as m, DepositQuery as n, WalletQuery as o, StatementQuery as p, TransferQuery as q, UserQuery as r, WalletTransactionQuery as s, KYCFileType as t, KYCStatus as u, TrackDataMethod as v, PageSize as w };
|
package/build/index.cjs
CHANGED
|
@@ -6,9 +6,9 @@ var axios = require('axios');
|
|
|
6
6
|
var Buffer = require('buffer');
|
|
7
7
|
var errors_index = require('./errors/index.cjs');
|
|
8
8
|
var jwt_index = require('./jwt/index.cjs');
|
|
9
|
-
var identities = require('./identities-
|
|
10
|
-
var
|
|
11
|
-
var walletTransactionRequest = require('./walletTransactionRequest-
|
|
9
|
+
var identities = require('./identities-434e06c7.cjs');
|
|
10
|
+
var data = require('./data-9edbb2a0.cjs');
|
|
11
|
+
var walletTransactionRequest = require('./walletTransactionRequest-572c455b.cjs');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ const isNode =
|
|
|
26
26
|
|
|
27
27
|
const runtimeEnv = { isBrowser, isNode };
|
|
28
28
|
|
|
29
|
-
const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.
|
|
29
|
+
const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.33";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};
|
|
30
30
|
|
|
31
31
|
class Client {
|
|
32
32
|
constructor({ apiKey, apiSecret, phase = identities.Phase.Sandbox } = {}) {
|
|
@@ -95,7 +95,14 @@ class Client {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
async configure({
|
|
98
|
+
async configure({
|
|
99
|
+
apiKey,
|
|
100
|
+
apiSecret,
|
|
101
|
+
loginToken,
|
|
102
|
+
phase,
|
|
103
|
+
sessionId,
|
|
104
|
+
useJwt = false,
|
|
105
|
+
}) {
|
|
99
106
|
this.basicAuth = {
|
|
100
107
|
apiKey: apiKey || this.basicAuth.apiKey,
|
|
101
108
|
apiSecret: apiSecret || this.basicAuth.apiSecret,
|
|
@@ -108,6 +115,10 @@ class Client {
|
|
|
108
115
|
if (loginToken) {
|
|
109
116
|
this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
|
|
110
117
|
}
|
|
118
|
+
|
|
119
|
+
if (sessionId) {
|
|
120
|
+
this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
|
|
121
|
+
}
|
|
111
122
|
}
|
|
112
123
|
|
|
113
124
|
async get({ endpoint, format, params }) {
|
|
@@ -200,7 +211,7 @@ class Client {
|
|
|
200
211
|
class Account {
|
|
201
212
|
constructor({ accountNumber, createdAt, id, institutionName, name, userId }) {
|
|
202
213
|
this.accountNumber = accountNumber;
|
|
203
|
-
this.createdAt =
|
|
214
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
204
215
|
this.id = id;
|
|
205
216
|
this.institutionName = institutionName;
|
|
206
217
|
this.name = name;
|
|
@@ -220,12 +231,12 @@ class Account {
|
|
|
220
231
|
|
|
221
232
|
class ApiKey {
|
|
222
233
|
constructor({ createdAt, deactivatedAt, id, secret, userId, updatedAt }) {
|
|
223
|
-
this.createdAt =
|
|
224
|
-
this.deactivatedAt =
|
|
234
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
235
|
+
this.deactivatedAt = data.dateToUTC(deactivatedAt);
|
|
225
236
|
this.id = id;
|
|
226
237
|
this.secret = secret;
|
|
227
238
|
this.userId = userId;
|
|
228
|
-
this.updatedAt =
|
|
239
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
static fromObject = ({ id, secret, ...obj }) =>
|
|
@@ -239,7 +250,7 @@ class ApiKey {
|
|
|
239
250
|
});
|
|
240
251
|
|
|
241
252
|
get isActive() {
|
|
242
|
-
const todayUTC =
|
|
253
|
+
const todayUTC = data.dateToUTC(Date.now());
|
|
243
254
|
return (
|
|
244
255
|
!this.deactivatedAt || this.deactivatedAt.getTime() > todayUTC.getTime()
|
|
245
256
|
);
|
|
@@ -249,7 +260,7 @@ class ApiKey {
|
|
|
249
260
|
class Arpc {
|
|
250
261
|
constructor({ arpc, createdAt, cardUri, isValidArqc }) {
|
|
251
262
|
this.arpc = arpc;
|
|
252
|
-
this.createdAt =
|
|
263
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
253
264
|
this.cardUri = cardUri;
|
|
254
265
|
this.isValidArqc = isValidArqc;
|
|
255
266
|
}
|
|
@@ -276,9 +287,9 @@ class BalanceEntry {
|
|
|
276
287
|
rollingBalance,
|
|
277
288
|
}) {
|
|
278
289
|
this.amount = amount;
|
|
279
|
-
this.createdAt =
|
|
290
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
280
291
|
this.descriptor = descriptor;
|
|
281
|
-
this.entryType =
|
|
292
|
+
this.entryType = data.enumValueFromString(identities.EntryType, entryType);
|
|
282
293
|
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
283
294
|
this.id = id;
|
|
284
295
|
this.name = name;
|
|
@@ -303,9 +314,9 @@ class BalanceEntry {
|
|
|
303
314
|
class Transaction {
|
|
304
315
|
constructor({ amount, createdAt, descriptor, status, userId }) {
|
|
305
316
|
this.amount = amount;
|
|
306
|
-
this.createdAt =
|
|
317
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
307
318
|
this.descriptor = descriptor;
|
|
308
|
-
this.status =
|
|
319
|
+
this.status = data.enumValueFromString(identities.TransactionStatus, status);
|
|
309
320
|
this.userId = userId;
|
|
310
321
|
}
|
|
311
322
|
}
|
|
@@ -362,18 +373,18 @@ class Card {
|
|
|
362
373
|
updatedAt,
|
|
363
374
|
userId,
|
|
364
375
|
}) {
|
|
365
|
-
this.createdAt =
|
|
376
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
366
377
|
this.cvv2 = cvv2;
|
|
367
378
|
this.expMonth = expMonth;
|
|
368
379
|
this.expYear = expYear;
|
|
369
|
-
this.fundingType =
|
|
380
|
+
this.fundingType = data.enumValueFromString(identities.CardFundingType, fundingType);
|
|
370
381
|
this.id = id;
|
|
371
|
-
this.issuer =
|
|
382
|
+
this.issuer = data.enumValueFromString(identities.CardIssuer, issuer);
|
|
372
383
|
this.number = number;
|
|
373
384
|
this.pin = pin;
|
|
374
|
-
this.status =
|
|
375
|
-
this.type =
|
|
376
|
-
this.updatedAt =
|
|
385
|
+
this.status = data.enumValueFromString(identities.CardStatus, status);
|
|
386
|
+
this.type = data.enumValueFromString(identities.CardType, type);
|
|
387
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
377
388
|
this.userId = userId;
|
|
378
389
|
}
|
|
379
390
|
|
|
@@ -407,7 +418,7 @@ class Card {
|
|
|
407
418
|
class CardActivation {
|
|
408
419
|
constructor({ cardUri, createdAt, id, ipAddress, success, userId }) {
|
|
409
420
|
this.cardUri = cardUri;
|
|
410
|
-
this.createdAt =
|
|
421
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
411
422
|
this.id = id;
|
|
412
423
|
this.ipAddress = ipAddress;
|
|
413
424
|
this.success = success;
|
|
@@ -448,14 +459,14 @@ class CardTransaction extends Transaction {
|
|
|
448
459
|
status,
|
|
449
460
|
userId,
|
|
450
461
|
});
|
|
451
|
-
this.cardErrorType =
|
|
462
|
+
this.cardErrorType = data.enumValueFromString(identities.CardErrorType, cardErrorType);
|
|
452
463
|
this.cardLastFour = cardLastFour;
|
|
453
|
-
this.cardType =
|
|
464
|
+
this.cardType = data.enumValueFromString(identities.CardType, cardType);
|
|
454
465
|
this.cardUri = cardUri;
|
|
455
466
|
this.metadata = metadata;
|
|
456
467
|
this.network = network;
|
|
457
468
|
this.relatedCardTransactionsUris = relatedCardTransactionsUris;
|
|
458
|
-
this.type =
|
|
469
|
+
this.type = data.enumValueFromString(identities.CardTransactionType, type);
|
|
459
470
|
}
|
|
460
471
|
|
|
461
472
|
static fromObject = ({
|
|
@@ -499,10 +510,10 @@ class CardValidation {
|
|
|
499
510
|
isValidPinBlock,
|
|
500
511
|
userId,
|
|
501
512
|
}) {
|
|
502
|
-
this.cardStatus =
|
|
503
|
-
this.cardType =
|
|
513
|
+
this.cardStatus = data.enumValueFromString(identities.CardStatus, cardStatus);
|
|
514
|
+
this.cardType = data.enumValueFromString(identities.CardType, cardType);
|
|
504
515
|
this.cardUri = cardUri;
|
|
505
|
-
this.createdAt =
|
|
516
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
506
517
|
this.isExpired = isExpired;
|
|
507
518
|
this.isPinAttemptsExceeded = isPinAttemptsExceeded;
|
|
508
519
|
this.isValidCvv = isValidCvv;
|
|
@@ -552,7 +563,7 @@ class Commission extends Transaction {
|
|
|
552
563
|
userId,
|
|
553
564
|
});
|
|
554
565
|
this.relatedTransactionUri = relatedTransactionUri;
|
|
555
|
-
this.type =
|
|
566
|
+
this.type = data.enumValueFromString(identities.CommissionType, type);
|
|
556
567
|
}
|
|
557
568
|
|
|
558
569
|
static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
|
|
@@ -587,7 +598,7 @@ class Deposit extends Transaction {
|
|
|
587
598
|
userId,
|
|
588
599
|
});
|
|
589
600
|
this.id = id;
|
|
590
|
-
this.network =
|
|
601
|
+
this.network = data.enumValueFromString(identities.DepositNetwork, network);
|
|
591
602
|
this.sourceUri = sourceUri;
|
|
592
603
|
this.trackingKey = trackingKey;
|
|
593
604
|
}
|
|
@@ -617,11 +628,11 @@ class LoginToken {
|
|
|
617
628
|
class Wallet {
|
|
618
629
|
constructor({ balance, createdAt, deactivatedAt, id, userId, updatedAt }) {
|
|
619
630
|
this.balance = balance;
|
|
620
|
-
this.createdAt =
|
|
621
|
-
this.deactivatedAt =
|
|
631
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
632
|
+
this.deactivatedAt = data.dateToUTC(deactivatedAt);
|
|
622
633
|
this.id = id;
|
|
623
634
|
this.userId = userId;
|
|
624
|
-
this.updatedAt =
|
|
635
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
625
636
|
}
|
|
626
637
|
}
|
|
627
638
|
|
|
@@ -646,9 +657,9 @@ class Saving extends Wallet {
|
|
|
646
657
|
userId,
|
|
647
658
|
updatedAt,
|
|
648
659
|
});
|
|
649
|
-
this.category =
|
|
660
|
+
this.category = data.enumValueFromString(identities.SavingCategory, category);
|
|
650
661
|
this.goalAmount = goalAmount;
|
|
651
|
-
this.goalDate =
|
|
662
|
+
this.goalDate = data.dateToUTC(goalDate);
|
|
652
663
|
this.name = name;
|
|
653
664
|
}
|
|
654
665
|
|
|
@@ -670,7 +681,7 @@ class Saving extends Wallet {
|
|
|
670
681
|
const categoriesFromString = (categoriesList) => {
|
|
671
682
|
if (categoriesList == null) return [];
|
|
672
683
|
return categoriesList.map((category) =>
|
|
673
|
-
|
|
684
|
+
data.enumValueFromString(identities.ServiceProviderCategory, category),
|
|
674
685
|
);
|
|
675
686
|
};
|
|
676
687
|
|
|
@@ -693,7 +704,7 @@ class ServiceProvider {
|
|
|
693
704
|
|
|
694
705
|
class Statement {
|
|
695
706
|
constructor({ createdAt, id, month, year }) {
|
|
696
|
-
this.createdAt =
|
|
707
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
697
708
|
this.id = id;
|
|
698
709
|
this.month = month;
|
|
699
710
|
this.year = year;
|
|
@@ -735,10 +746,10 @@ class Transfer extends Transaction {
|
|
|
735
746
|
this.destinationUri = destinationUri;
|
|
736
747
|
this.id = id;
|
|
737
748
|
this.idempotencyKey = idempotencyKey;
|
|
738
|
-
this.network =
|
|
749
|
+
this.network = data.enumValueFromString(identities.TransferNetwork, network);
|
|
739
750
|
this.recipientName = recipientName;
|
|
740
751
|
this.trackingKey = trackingKey;
|
|
741
|
-
this.updatedAt =
|
|
752
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
742
753
|
}
|
|
743
754
|
|
|
744
755
|
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
@@ -762,18 +773,53 @@ class Transfer extends Transaction {
|
|
|
762
773
|
class User {
|
|
763
774
|
constructor({
|
|
764
775
|
emailAddress,
|
|
776
|
+
govtId,
|
|
777
|
+
level,
|
|
765
778
|
phoneNumber,
|
|
779
|
+
proofOfAddress,
|
|
780
|
+
proofOfLife,
|
|
766
781
|
status,
|
|
767
782
|
termsOfService,
|
|
768
783
|
verificationId,
|
|
769
784
|
}) {
|
|
770
785
|
this.emailAddress = emailAddress;
|
|
786
|
+
this.govstIds = govtId;
|
|
787
|
+
this.level = level;
|
|
771
788
|
this.phoneNumber = phoneNumber;
|
|
772
|
-
this.
|
|
789
|
+
this.addressProofs = proofOfAddress;
|
|
790
|
+
this.lifeProofs = proofOfLife;
|
|
791
|
+
this.status = data.enumValueFromString(identities.UserStatus, status);
|
|
773
792
|
this.terms = termsOfService;
|
|
774
793
|
this.verificationId = verificationId;
|
|
775
794
|
}
|
|
776
795
|
|
|
796
|
+
get proofOfAddress() {
|
|
797
|
+
return this._proofOfAddress;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
set addressProofs(value) {
|
|
801
|
+
if (!value) return;
|
|
802
|
+
this._proofOfAddress = identities.KYCFile.fromObject(value);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
get proofOfLife() {
|
|
806
|
+
return this._proofOfLife;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
set lifeProofs(value) {
|
|
810
|
+
if (!value) return;
|
|
811
|
+
this._proofOfLife = identities.KYCFile.fromObject(value);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
get govtId() {
|
|
815
|
+
return this._govtId;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
set govstIds(value) {
|
|
819
|
+
if (!value) return;
|
|
820
|
+
this._govtId = identities.KYCFile.fromObject(value);
|
|
821
|
+
}
|
|
822
|
+
|
|
777
823
|
get termsOfService() {
|
|
778
824
|
return this._termsOfService;
|
|
779
825
|
}
|
|
@@ -783,11 +829,15 @@ class User {
|
|
|
783
829
|
this._termsOfService = identities.TOSAgreements.fromObject(value);
|
|
784
830
|
}
|
|
785
831
|
|
|
786
|
-
static fromObject = ({ ...obj }) =>
|
|
832
|
+
static fromObject = ({ level, status, ...obj }) =>
|
|
787
833
|
new User({
|
|
834
|
+
level,
|
|
835
|
+
status,
|
|
836
|
+
govtId: obj.govt_id,
|
|
788
837
|
emailAddress: obj.email_address,
|
|
789
838
|
phoneNumber: obj.phone_number,
|
|
790
|
-
|
|
839
|
+
proofOfAddress: obj.proof_of_address,
|
|
840
|
+
proofOfLife: obj.proof_of_life,
|
|
791
841
|
termsOfService: obj.terms_of_service,
|
|
792
842
|
verificationId: obj.verification_id,
|
|
793
843
|
});
|
|
@@ -795,10 +845,10 @@ class User {
|
|
|
795
845
|
|
|
796
846
|
class UserCredential {
|
|
797
847
|
constructor({ createdAt, id, isActive, updatedAt }) {
|
|
798
|
-
this.createdAt =
|
|
848
|
+
this.createdAt = data.dateToUTC(createdAt);
|
|
799
849
|
this.id = id;
|
|
800
850
|
this.isActive = isActive;
|
|
801
|
-
this.updatedAt =
|
|
851
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
802
852
|
}
|
|
803
853
|
|
|
804
854
|
static fromObject = ({ id, ...obj }) =>
|
|
@@ -813,7 +863,7 @@ class UserCredential {
|
|
|
813
863
|
class UserLogin {
|
|
814
864
|
constructor({ id, lastLoginAt, success }) {
|
|
815
865
|
this.id = id;
|
|
816
|
-
this.lastLoginAt =
|
|
866
|
+
this.lastLoginAt = data.dateToUTC(lastLoginAt);
|
|
817
867
|
this.success = success;
|
|
818
868
|
}
|
|
819
869
|
|
|
@@ -844,7 +894,7 @@ class WalletTransaction extends Transaction {
|
|
|
844
894
|
userId,
|
|
845
895
|
});
|
|
846
896
|
this.id = id;
|
|
847
|
-
this.transactionType =
|
|
897
|
+
this.transactionType = data.enumValueFromString(
|
|
848
898
|
identities.WalletTransactionType,
|
|
849
899
|
transactionType,
|
|
850
900
|
);
|
|
@@ -891,12 +941,12 @@ class WhatsAppTransfer extends Transaction {
|
|
|
891
941
|
this.claimUrl = claimUrl;
|
|
892
942
|
this.destinationUri = destinationUri;
|
|
893
943
|
this.id = id;
|
|
894
|
-
this.expiresAt =
|
|
895
|
-
this.network =
|
|
944
|
+
this.expiresAt = data.dateToUTC(expiresAt);
|
|
945
|
+
this.network = data.enumValueFromString(identities.TransferNetwork, network);
|
|
896
946
|
this.phoneNumber = phoneNumber;
|
|
897
947
|
this.recipientName = recipientName;
|
|
898
948
|
this.trackingKey = trackingKey;
|
|
899
|
-
this.updatedAt =
|
|
949
|
+
this.updatedAt = data.dateToUTC(updatedAt);
|
|
900
950
|
}
|
|
901
951
|
|
|
902
952
|
static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
|
|
@@ -1458,7 +1508,7 @@ class TransferResource extends mix(Resource).with(
|
|
|
1458
1508
|
}
|
|
1459
1509
|
|
|
1460
1510
|
static _genIdempotencyKey(accountNumber, amount) {
|
|
1461
|
-
const [date] =
|
|
1511
|
+
const [date] = data.dateToUTC(Date.now()).toISOString().split('T');
|
|
1462
1512
|
return `${date}:${accountNumber}:${amount}`;
|
|
1463
1513
|
}
|
|
1464
1514
|
}
|
|
@@ -1510,14 +1560,19 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
|
|
|
1510
1560
|
}
|
|
1511
1561
|
}
|
|
1512
1562
|
|
|
1513
|
-
class UserResourse extends mix(Resource).with(
|
|
1563
|
+
class UserResourse extends mix(Resource).with(
|
|
1564
|
+
Queryable,
|
|
1565
|
+
Updateable,
|
|
1566
|
+
Retrievable,
|
|
1567
|
+
) {
|
|
1514
1568
|
constructor(client) {
|
|
1515
1569
|
super('users', identities.UserQuery, client);
|
|
1516
1570
|
}
|
|
1517
1571
|
|
|
1518
|
-
async update({ termsOfService, userId = 'me'
|
|
1572
|
+
async update({ termsOfService, verificationId, userId = 'me' }) {
|
|
1519
1573
|
const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService, verificationId });
|
|
1520
1574
|
const user = await this._update(userId, request.toCleanObject());
|
|
1575
|
+
console.log('User:', user);
|
|
1521
1576
|
return user;
|
|
1522
1577
|
}
|
|
1523
1578
|
}
|
|
@@ -1589,9 +1644,9 @@ class Cuenca {
|
|
|
1589
1644
|
this.serviceProviders = new ServiceProviderResource(client);
|
|
1590
1645
|
this.statements = new StatementResource(client);
|
|
1591
1646
|
this.transfers = new TransferResource(client);
|
|
1592
|
-
this.users = new UserResourse(client);
|
|
1593
1647
|
this.userCredentials = new UserCredentialResource(client);
|
|
1594
1648
|
this.userLogins = new UserLoginResource(client);
|
|
1649
|
+
this.users = new UserResourse(client);
|
|
1595
1650
|
this.walletTransactions = new WalletTransactionsResource(client);
|
|
1596
1651
|
this.whatsAppTransfers = new WhatsAppTransferResource(client);
|
|
1597
1652
|
}
|