@cuenca-mx/cuenca-js 0.0.1-dev.5 → 0.0.1-dev.52

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.
@@ -3,22 +3,45 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var axios = require('axios');
6
- var errors_index = require('./errors/index.js');
7
- var jwt_index = require('./jwt/index.js');
8
- var queries = require('./queries-b8f29837.js');
9
- var data = require('./data-c53f1052.js');
10
- var walletTransactionRequest = require('./walletTransactionRequest-b588cc52.js');
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-c67b6b94.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.52";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 = queries.Phase.Sandbox } = {}) {
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
- Buffer.from(`${apiKey}:${apiSecret}`).toString('utf-8'),
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({ apiKey, apiSecret, loginToken, phase, useJwt = false }) {
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 }) {
@@ -102,8 +137,8 @@ class Client {
102
137
  return this.request({ method: 'POST', endpoint, data });
103
138
  }
104
139
 
105
- async patch({ endpoint, data }) {
106
- return this.request({ method: 'PATCH', endpoint, data });
140
+ async patch({ endpoint, data, multipart }) {
141
+ return this.request({ method: 'PATCH', endpoint, data, multipart });
107
142
  }
108
143
 
109
144
  async delete({ endpoint, data }) {
@@ -112,17 +147,36 @@ class Client {
112
147
 
113
148
  async request({
114
149
  endpoint,
115
- data = null,
116
- format = queries.FileFormat.Json,
150
+ data: data$1 = null,
151
+ format = data.FileFormat.Json,
117
152
  method = 'GET',
153
+ multipart = false,
118
154
  params = null,
119
155
  }) {
120
- const headers = {
121
- Authorization: this.authHeader,
122
- 'X-User-Agent': `cuenca-js/0.0.1`, // TODO: Change for client version
123
- 'Content-Type': 'application/json',
124
- Accept: `application/${format.value}`,
125
- };
156
+ console.log('multipart :', multipart);
157
+ let headers;
158
+ if (multipart) {
159
+ headers = {
160
+ 'Content-Type': 'multipart/form-data',
161
+ };
162
+ } else {
163
+ headers = {
164
+ 'Content-Type': 'application/json',
165
+ Accept: `application/${format.value}`,
166
+ };
167
+ }
168
+
169
+ if (this.authHeader) {
170
+ headers.Authorization = this.authHeader;
171
+ }
172
+
173
+ if (runtimeEnv.isNode) {
174
+ headers['User-Agent'] = `cuenca-js/${pkg.version}`;
175
+ } else if (runtimeEnv.isBrowser) {
176
+ // Cannot set User-Agent header on browsers
177
+ // https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
178
+ headers['X-User-Agent'] = `cuenca-js/${pkg.version}`;
179
+ }
126
180
 
127
181
  if (this.jwtToken) {
128
182
  if (this.jwtToken.isExpired) {
@@ -130,10 +184,11 @@ class Client {
130
184
  }
131
185
  headers['X-Cuenca-Token'] = this.jwtToken.token;
132
186
  }
133
-
187
+ console.log('headers :', headers);
134
188
  const headersInterceptor = this.addHeadersToRequest(headers);
189
+ console.log('headersInterceptor :', headersInterceptor);
135
190
 
136
- const modifiedData = data;
191
+ const modifiedData = data$1;
137
192
  if (modifiedData) {
138
193
  Object.keys(modifiedData).forEach((k) => {
139
194
  if (modifiedData[k] instanceof Date) {
@@ -255,7 +310,7 @@ class BalanceEntry {
255
310
  this.amount = amount;
256
311
  this.createdAt = data.dateToUTC(createdAt);
257
312
  this.descriptor = descriptor;
258
- this.entryType = data.enumValueFromString(queries.EntryType, entryType);
313
+ this.entryType = data.enumValueFromString(data.EntryType, entryType);
259
314
  this.fundingInstrumentUri = fundingInstrumentUri;
260
315
  this.id = id;
261
316
  this.name = name;
@@ -282,7 +337,7 @@ class Transaction {
282
337
  this.amount = amount;
283
338
  this.createdAt = data.dateToUTC(createdAt);
284
339
  this.descriptor = descriptor;
285
- this.status = data.enumValueFromString(queries.TransactionStatus, status);
340
+ this.status = data.enumValueFromString(data.TransactionStatus, status);
286
341
  this.userId = userId;
287
342
  }
288
343
  }
@@ -298,7 +353,13 @@ class BillPayment extends Transaction {
298
353
  status,
299
354
  userId,
300
355
  }) {
301
- super({ amount, createdAt, descriptor, status, userId });
356
+ super({
357
+ amount,
358
+ createdAt,
359
+ descriptor,
360
+ status,
361
+ userId,
362
+ });
302
363
  this.accountNumber = accountNumber;
303
364
  this.id = id;
304
365
  this.providerUri = providerUri;
@@ -337,13 +398,13 @@ class Card {
337
398
  this.cvv2 = cvv2;
338
399
  this.expMonth = expMonth;
339
400
  this.expYear = expYear;
340
- this.fundingType = data.enumValueFromString(queries.CardFundingType, fundingType);
401
+ this.fundingType = data.enumValueFromString(data.CardFundingType, fundingType);
341
402
  this.id = id;
342
- this.issuer = data.enumValueFromString(queries.CardIssuer, issuer);
403
+ this.issuer = data.enumValueFromString(data.CardIssuer, issuer);
343
404
  this.number = number;
344
405
  this.pin = pin;
345
- this.status = data.enumValueFromString(queries.CardStatus, status);
346
- this.type = data.enumValueFromString(queries.CardType, type);
406
+ this.status = data.enumValueFromString(data.CardStatus, status);
407
+ this.type = data.enumValueFromString(data.CardType, type);
347
408
  this.updatedAt = data.dateToUTC(updatedAt);
348
409
  this.userId = userId;
349
410
  }
@@ -412,15 +473,21 @@ class CardTransaction extends Transaction {
412
473
  type,
413
474
  userId,
414
475
  }) {
415
- super({ amount, createdAt, descriptor, status, userId });
416
- this.cardErrorType = data.enumValueFromString(queries.CardErrorType, cardErrorType);
476
+ super({
477
+ amount,
478
+ createdAt,
479
+ descriptor,
480
+ status,
481
+ userId,
482
+ });
483
+ this.cardErrorType = data.enumValueFromString(data.CardErrorType, cardErrorType);
417
484
  this.cardLastFour = cardLastFour;
418
- this.cardType = data.enumValueFromString(queries.CardType, cardType);
485
+ this.cardType = data.enumValueFromString(data.CardType, cardType);
419
486
  this.cardUri = cardUri;
420
487
  this.metadata = metadata;
421
488
  this.network = network;
422
489
  this.relatedCardTransactionsUris = relatedCardTransactionsUris;
423
- this.type = data.enumValueFromString(queries.CardTransactionType, type);
490
+ this.type = data.enumValueFromString(data.CardTransactionType, type);
424
491
  }
425
492
 
426
493
  static fromObject = ({
@@ -464,8 +531,8 @@ class CardValidation {
464
531
  isValidPinBlock,
465
532
  userId,
466
533
  }) {
467
- this.cardStatus = data.enumValueFromString(queries.CardStatus, cardStatus);
468
- this.cardType = data.enumValueFromString(queries.CardType, cardType);
534
+ this.cardStatus = data.enumValueFromString(data.CardStatus, cardStatus);
535
+ this.cardType = data.enumValueFromString(data.CardType, cardType);
469
536
  this.cardUri = cardUri;
470
537
  this.createdAt = data.dateToUTC(createdAt);
471
538
  this.isExpired = isExpired;
@@ -495,7 +562,7 @@ class CardValidation {
495
562
  });
496
563
 
497
564
  get isActive() {
498
- return this.cardStatus === queries.CardStatus.Active;
565
+ return this.cardStatus === data.CardStatus.Active;
499
566
  }
500
567
  }
501
568
 
@@ -509,9 +576,15 @@ class Commission extends Transaction {
509
576
  type,
510
577
  userId,
511
578
  }) {
512
- super({ amount, createdAt, descriptor, status, userId });
579
+ super({
580
+ amount,
581
+ createdAt,
582
+ descriptor,
583
+ status,
584
+ userId,
585
+ });
513
586
  this.relatedTransactionUri = relatedTransactionUri;
514
- this.type = data.enumValueFromString(queries.CommissionType, type);
587
+ this.type = data.enumValueFromString(data.CommissionType, type);
515
588
  }
516
589
 
517
590
  static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
@@ -538,9 +611,15 @@ class Deposit extends Transaction {
538
611
  trackingKey,
539
612
  userId,
540
613
  }) {
541
- super({ amount, createdAt, descriptor, status, userId });
614
+ super({
615
+ amount,
616
+ createdAt,
617
+ descriptor,
618
+ status,
619
+ userId,
620
+ });
542
621
  this.id = id;
543
- this.network = data.enumValueFromString(queries.DepositNetwork, network);
622
+ this.network = data.enumValueFromString(data.DepositNetwork, network);
544
623
  this.sourceUri = sourceUri;
545
624
  this.trackingKey = trackingKey;
546
625
  }
@@ -559,6 +638,96 @@ class Deposit extends Transaction {
559
638
  });
560
639
  }
561
640
 
641
+ class Identities {
642
+ constructor({
643
+ address,
644
+ blacklistValidationStatus,
645
+ countryOfBirth,
646
+ createdAt,
647
+ curp,
648
+ dateOfBirth,
649
+ extension,
650
+ firstSurname,
651
+ gender,
652
+ govId,
653
+ id,
654
+ names,
655
+ nationality,
656
+ proofOfAddress,
657
+ proofOfLife,
658
+ rfc,
659
+ rfcDocument,
660
+ rfcFile,
661
+ secondSurname,
662
+ stateOfBirth,
663
+ status,
664
+ tosAgreement,
665
+ userId,
666
+ }) {
667
+ this.address = address;
668
+ this.blacklistValidationStatus = blacklistValidationStatus;
669
+ this.countryOfBirth = countryOfBirth;
670
+ this.createdAt = createdAt;
671
+ this.curp = curp;
672
+ this.dateOfBirth = dateOfBirth;
673
+ this.extension = extension;
674
+ this.firstSurname = firstSurname;
675
+ this.gender = gender;
676
+ this.govId = govId;
677
+ this.id = id;
678
+ this.names = names;
679
+ this.nationality = nationality;
680
+ this.proofOfAddress = proofOfAddress;
681
+ this.proofOfLife = proofOfLife;
682
+ this.rfc = rfc;
683
+ this.rfcDocument = rfcDocument;
684
+ this.rfcFile = rfcFile;
685
+ this.secondSurname = secondSurname;
686
+ this.stateOfBirth = stateOfBirth;
687
+ this.status = status;
688
+ this.tosAgreement = tosAgreement;
689
+ this.userId = userId;
690
+ }
691
+
692
+ static fromObject = ({
693
+ address,
694
+ curp,
695
+ extension,
696
+ gender,
697
+ id,
698
+ names,
699
+ nationality,
700
+ rfc,
701
+ status,
702
+ ...obj
703
+ }) =>
704
+ new Identities({
705
+ address,
706
+ curp,
707
+ extension,
708
+ gender,
709
+ id,
710
+ names,
711
+ nationality,
712
+ rfc,
713
+ status,
714
+ blacklistValidationStatus: obj.blacklist_validation_status,
715
+ countryOfBirth: obj.country_of_birth,
716
+ createdAt: obj.created_at,
717
+ dateOfBirth: obj.date_of_birth,
718
+ firstSurname: obj.first_surname,
719
+ govId: obj.gov_id,
720
+ proofOfAddress: obj.proof_of_address,
721
+ proofOfLife: obj.proof_of_life,
722
+ rfcDocument: obj.rfc_document,
723
+ rfcFile: obj.rfc_file,
724
+ secondSurname: obj.second_surname,
725
+ stateOfBirth: obj.state_of_birth,
726
+ tosAgreement: obj.tos_agreement,
727
+ userId: obj.user_id,
728
+ });
729
+ }
730
+
562
731
  class LoginToken {
563
732
  constructor({ id }) {
564
733
  this.id = id;
@@ -591,8 +760,15 @@ class Saving extends Wallet {
591
760
  userId,
592
761
  updatedAt,
593
762
  }) {
594
- super({ balance, createdAt, deactivatedAt, id, userId, updatedAt });
595
- this.category = data.enumValueFromString(queries.SavingCategory, category);
763
+ super({
764
+ balance,
765
+ createdAt,
766
+ deactivatedAt,
767
+ id,
768
+ userId,
769
+ updatedAt,
770
+ });
771
+ this.category = data.enumValueFromString(data.SavingCategory, category);
596
772
  this.goalAmount = goalAmount;
597
773
  this.goalDate = data.dateToUTC(goalDate);
598
774
  this.name = name;
@@ -616,7 +792,7 @@ class Saving extends Wallet {
616
792
  const categoriesFromString = (categoriesList) => {
617
793
  if (categoriesList == null) return [];
618
794
  return categoriesList.map((category) =>
619
- data.enumValueFromString(queries.ServiceProviderCategory, category),
795
+ data.enumValueFromString(data.ServiceProviderCategory, category),
620
796
  );
621
797
  };
622
798
 
@@ -670,12 +846,18 @@ class Transfer extends Transaction {
670
846
  updatedAt,
671
847
  userId,
672
848
  }) {
673
- super({ amount, createdAt, descriptor, status, userId });
849
+ super({
850
+ amount,
851
+ createdAt,
852
+ descriptor,
853
+ status,
854
+ userId,
855
+ });
674
856
  this.accountNumber = accountNumber;
675
857
  this.destinationUri = destinationUri;
676
858
  this.id = id;
677
859
  this.idempotencyKey = idempotencyKey;
678
- this.network = data.enumValueFromString(queries.TransferNetwork, network);
860
+ this.network = data.enumValueFromString(data.TransferNetwork, network);
679
861
  this.recipientName = recipientName;
680
862
  this.trackingKey = trackingKey;
681
863
  this.updatedAt = data.dateToUTC(updatedAt);
@@ -699,6 +881,82 @@ class Transfer extends Transaction {
699
881
  });
700
882
  }
701
883
 
884
+ class User {
885
+ constructor({
886
+ emailAddress,
887
+ govtId,
888
+ identityUri,
889
+ level,
890
+ phoneNumber,
891
+ proofOfAddress,
892
+ proofOfLife,
893
+ status,
894
+ termsOfService,
895
+ verificationId,
896
+ }) {
897
+ this.emailAddress = emailAddress;
898
+ this.govstIds = govtId;
899
+ this.identityUri = identityUri;
900
+ this.level = level;
901
+ this.phoneNumber = phoneNumber;
902
+ this.addressProofs = proofOfAddress;
903
+ this.lifeProofs = proofOfLife;
904
+ this.status = data.enumValueFromString(data.UserStatus, status);
905
+ this.terms = termsOfService;
906
+ this.verificationId = verificationId;
907
+ }
908
+
909
+ get proofOfAddress() {
910
+ return this._proofOfAddress;
911
+ }
912
+
913
+ set addressProofs(value) {
914
+ if (!value) return;
915
+ this._proofOfAddress = identities.KYCFile.fromObject(value);
916
+ }
917
+
918
+ get proofOfLife() {
919
+ return this._proofOfLife;
920
+ }
921
+
922
+ set lifeProofs(value) {
923
+ if (!value) return;
924
+ this._proofOfLife = identities.KYCFile.fromObject(value);
925
+ }
926
+
927
+ get govtId() {
928
+ return this._govtId;
929
+ }
930
+
931
+ set govstIds(value) {
932
+ if (!value) return;
933
+ this._govtId = identities.KYCFile.fromObject(value);
934
+ }
935
+
936
+ get termsOfService() {
937
+ return this._termsOfService;
938
+ }
939
+
940
+ set terms(value) {
941
+ if (!value) return;
942
+ this._termsOfService = identities.TOSAgreements.fromObject(value);
943
+ }
944
+
945
+ static fromObject = ({ level, status, ...obj }) =>
946
+ new User({
947
+ level,
948
+ status,
949
+ govtId: obj.govt_id,
950
+ identityUri: obj.identity_uri,
951
+ emailAddress: obj.email_address,
952
+ phoneNumber: obj.phone_number,
953
+ proofOfAddress: obj.proof_of_address,
954
+ proofOfLife: obj.proof_of_life,
955
+ termsOfService: obj.terms_of_service,
956
+ verificationId: obj.verification_id,
957
+ });
958
+ }
959
+
702
960
  class UserCredential {
703
961
  constructor({ createdAt, id, isActive, updatedAt }) {
704
962
  this.createdAt = data.dateToUTC(createdAt);
@@ -731,6 +989,27 @@ class UserLogin {
731
989
  });
732
990
  }
733
991
 
992
+ class Verification {
993
+ constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
994
+ this.createdAt = data.dateToUTC(createdAt);
995
+ this.id = id;
996
+ this.platformId = platformId;
997
+ this.recipient = recipient;
998
+ this.type = data.enumValueFromString(data.VerificationType, type);
999
+ this.updatedAt = data.dateToUTC(updatedAt);
1000
+ }
1001
+
1002
+ static fromObject = ({ id, recipient, type, ...obj }) =>
1003
+ new Verification({
1004
+ id,
1005
+ recipient,
1006
+ type,
1007
+ createdAt: obj.created_at,
1008
+ platformId: obj.platform_id,
1009
+ updatedAt: obj.updated_at,
1010
+ });
1011
+ }
1012
+
734
1013
  class WalletTransaction extends Transaction {
735
1014
  constructor({
736
1015
  amount,
@@ -742,10 +1021,16 @@ class WalletTransaction extends Transaction {
742
1021
  userId,
743
1022
  walletUri,
744
1023
  }) {
745
- super({ amount, createdAt, descriptor, status, userId });
1024
+ super({
1025
+ amount,
1026
+ createdAt,
1027
+ descriptor,
1028
+ status,
1029
+ userId,
1030
+ });
746
1031
  this.id = id;
747
1032
  this.transactionType = data.enumValueFromString(
748
- queries.WalletTransactionType,
1033
+ data.WalletTransactionType,
749
1034
  transactionType,
750
1035
  );
751
1036
  this.walletUri = walletUri;
@@ -781,12 +1066,18 @@ class WhatsAppTransfer extends Transaction {
781
1066
  updatedAt,
782
1067
  userId,
783
1068
  }) {
784
- super({ amount, createdAt, descriptor, status, userId });
1069
+ super({
1070
+ amount,
1071
+ createdAt,
1072
+ descriptor,
1073
+ status,
1074
+ userId,
1075
+ });
785
1076
  this.claimUrl = claimUrl;
786
1077
  this.destinationUri = destinationUri;
787
1078
  this.id = id;
788
1079
  this.expiresAt = data.dateToUTC(expiresAt);
789
- this.network = data.enumValueFromString(queries.TransferNetwork, network);
1080
+ this.network = data.enumValueFromString(data.TransferNetwork, network);
790
1081
  this.phoneNumber = phoneNumber;
791
1082
  this.recipientName = recipientName;
792
1083
  this.trackingKey = trackingKey;
@@ -837,13 +1128,16 @@ const getModelFromPath = (path, obj) => {
837
1128
  card_validations: () => CardValidation.fromObject(obj),
838
1129
  commissions: () => Commission.fromObject(obj),
839
1130
  deposits: () => Deposit.fromObject(obj),
1131
+ identities: () => Identities.fromObject(obj),
840
1132
  login_tokens: () => LoginToken.fromObject(obj),
841
1133
  savings: () => Saving.fromObject(obj),
842
1134
  service_providers: () => ServiceProvider.fromObject(obj),
843
1135
  statements: () => Statement.fromObject(obj),
844
1136
  transfers: () => Transfer.fromObject(obj),
1137
+ users: () => User.fromObject(obj),
845
1138
  user_credentials: () => UserCredential.fromObject(obj),
846
1139
  user_logins: () => UserLogin.fromObject(obj),
1140
+ verifications: () => Verification.fromObject(obj),
847
1141
  wallet_transactions: () => WalletTransaction.fromObject(obj),
848
1142
  whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
849
1143
  };
@@ -900,6 +1194,19 @@ const Updateable = (SuperClass) =>
900
1194
  }
901
1195
  };
902
1196
 
1197
+ const Uploadable = (SuperClass) =>
1198
+ class Uploadable extends SuperClass {
1199
+ async _upload(id, data) {
1200
+ const response = await this.client.patch({
1201
+ endpoint: `/${this.path}/${id}`,
1202
+ data,
1203
+ multipart: true,
1204
+ });
1205
+ const model = getModelFromPath(this.path, response);
1206
+ return model;
1207
+ }
1208
+ };
1209
+
903
1210
  const Deactivable = (SuperClass) =>
904
1211
  class Deactivable extends SuperClass {
905
1212
  async _deactivate(id, data) {
@@ -981,7 +1288,7 @@ const Queryable = (SuperClass) =>
981
1288
 
982
1289
  class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
983
1290
  constructor(client) {
984
- super('accounts', queries.AccountQuery, client);
1291
+ super('accounts', identities.AccountQuery, client);
985
1292
  }
986
1293
  }
987
1294
 
@@ -993,7 +1300,7 @@ class ApiKeyResource extends mix(Resource).with(
993
1300
  Updateable,
994
1301
  ) {
995
1302
  constructor(client) {
996
- super('api_keys', queries.ApiKeyQuery, client);
1303
+ super('api_keys', identities.ApiKeyQuery, client);
997
1304
  }
998
1305
 
999
1306
  async create() {
@@ -1047,7 +1354,7 @@ class ArpcResource extends mix(Resource).with(Creatable) {
1047
1354
 
1048
1355
  class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
1049
1356
  constructor(client) {
1050
- super('balance_entries', queries.BalanceEntryQuery, client);
1357
+ super('balance_entries', identities.BalanceEntryQuery, client);
1051
1358
  }
1052
1359
 
1053
1360
  async relatedTransaction(relatedTransactionUri) {
@@ -1073,7 +1380,7 @@ class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
1073
1380
 
1074
1381
  class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
1075
1382
  constructor(client) {
1076
- super('bill_payments', queries.BillPaymentQuery, client);
1383
+ super('bill_payments', identities.BillPaymentQuery, client);
1077
1384
  }
1078
1385
 
1079
1386
  async serviceProvider(providerUri) {
@@ -1111,7 +1418,7 @@ class CardResource extends mix(Resource).with(
1111
1418
  Updateable,
1112
1419
  ) {
1113
1420
  constructor(client) {
1114
- super('cards', queries.CardsQuery, client);
1421
+ super('cards', identities.CardsQuery, client);
1115
1422
  }
1116
1423
 
1117
1424
  async create(userId, issuer, fundingType) {
@@ -1137,7 +1444,7 @@ class CardTransactionResource extends mix(Resource).with(
1137
1444
  Retrievable,
1138
1445
  ) {
1139
1446
  constructor(client) {
1140
- super('card_transactions', queries.CardTransactionQuery, client);
1447
+ super('card_transactions', identities.CardTransactionQuery, client);
1141
1448
  }
1142
1449
 
1143
1450
  async relatedCard(relatedCardUri) {
@@ -1189,7 +1496,7 @@ class CardValidationResource extends mix(Resource).with(Creatable) {
1189
1496
 
1190
1497
  class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
1191
1498
  constructor(client) {
1192
- super('commissions', queries.QueryParams, client);
1499
+ super('commissions', identities.QueryParams, client);
1193
1500
  }
1194
1501
 
1195
1502
  async relatedTransaction(relatedTransactionUri) {
@@ -1203,7 +1510,7 @@ class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
1203
1510
 
1204
1511
  class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
1205
1512
  constructor(client) {
1206
- super('deposits', queries.DepositQuery, client);
1513
+ super('deposits', identities.DepositQuery, client);
1207
1514
  }
1208
1515
 
1209
1516
  async source(sourceUri) {
@@ -1212,6 +1519,19 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
1212
1519
  }
1213
1520
  }
1214
1521
 
1522
+ class IdentitiesResource extends mix(Resource).with(Uploadable) {
1523
+ constructor(client) {
1524
+ super('identities', Object, client);
1525
+ }
1526
+
1527
+ async upload({ extension, id, rfcFile, userId = 'me' }) {
1528
+ const request = new walletTransactionRequest.IdentitiesUploadRequest({ extension, rfcFile, userId });
1529
+ const identities = await this._upload(id, request.toObject());
1530
+ // const identities = await this._update(identityId, request.toObject());
1531
+ return identities;
1532
+ }
1533
+ }
1534
+
1215
1535
  class LoginTokenResource extends mix(Resource).with(Creatable) {
1216
1536
  constructor(client) {
1217
1537
  super('login_tokens', Object, client);
@@ -1231,7 +1551,7 @@ class SavingResource extends mix(Resource).with(
1231
1551
  Updateable,
1232
1552
  ) {
1233
1553
  constructor(client) {
1234
- super('savings', queries.WalletQuery, client);
1554
+ super('savings', identities.WalletQuery, client);
1235
1555
  }
1236
1556
 
1237
1557
  async create(category, goalAmount, goalDate, name) {
@@ -1257,22 +1577,22 @@ class ServiceProviderResource extends mix(Resource).with(
1257
1577
  Retrievable,
1258
1578
  ) {
1259
1579
  constructor(client) {
1260
- super('service_providers', queries.QueryParams, client);
1580
+ super('service_providers', identities.QueryParams, client);
1261
1581
  }
1262
1582
  }
1263
1583
 
1264
1584
  class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
1265
1585
  constructor(client) {
1266
- super('statements', queries.StatementQuery, client);
1586
+ super('statements', identities.StatementQuery, client);
1267
1587
  }
1268
1588
 
1269
1589
  async pdf(id) {
1270
- const byteString = await this._download(id, queries.FileFormat.Pdf);
1590
+ const byteString = await this._download(id, data.FileFormat.Pdf);
1271
1591
  return byteString;
1272
1592
  }
1273
1593
 
1274
1594
  async xml(id) {
1275
- const byteString = await this._download(id, queries.FileFormat.Xml);
1595
+ const byteString = await this._download(id, data.FileFormat.Xml);
1276
1596
  return byteString;
1277
1597
  }
1278
1598
  }
@@ -1283,7 +1603,7 @@ class TransferResource extends mix(Resource).with(
1283
1603
  Retrievable,
1284
1604
  ) {
1285
1605
  constructor(client) {
1286
- super('transfers', queries.TransferQuery, client);
1606
+ super('transfers', identities.TransferQuery, client);
1287
1607
  }
1288
1608
 
1289
1609
  async destination(destinationUri) {
@@ -1403,13 +1723,47 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
1403
1723
  }
1404
1724
  }
1405
1725
 
1726
+ class UserResourse extends mix(Resource).with(
1727
+ Queryable,
1728
+ Updateable,
1729
+ Retrievable,
1730
+ ) {
1731
+ constructor(client) {
1732
+ super('users', identities.UserQuery, client);
1733
+ }
1734
+
1735
+ async update({ termsOfService, verificationId, userId = 'me' }) {
1736
+ const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService, verificationId });
1737
+ const user = await this._update(userId, request.toCleanObject());
1738
+ return user;
1739
+ }
1740
+ }
1741
+
1742
+ class VerificationResourse extends mix(Resource).with(Creatable, Updateable) {
1743
+ constructor(client) {
1744
+ super('verifications', Object, client);
1745
+ }
1746
+
1747
+ async create({ platformId, recipient, type }) {
1748
+ const request = new walletTransactionRequest.VerificationRequest({ platformId, recipient, type });
1749
+ const verification = await this._create(request.toObject());
1750
+ return verification;
1751
+ }
1752
+
1753
+ async update({ code, id }) {
1754
+ const request = new walletTransactionRequest.VerificationAttemptRequest({ code });
1755
+ const verification = await this._update(id, request.toObject());
1756
+ return verification;
1757
+ }
1758
+ }
1759
+
1406
1760
  class WalletTransactionsResource extends mix(Resource).with(
1407
1761
  Creatable,
1408
1762
  Queryable,
1409
1763
  Retrievable,
1410
1764
  ) {
1411
1765
  constructor(client) {
1412
- super('wallet_transactions', queries.WalletTransactionQuery, client);
1766
+ super('wallet_transactions', identities.WalletTransactionQuery, client);
1413
1767
  }
1414
1768
 
1415
1769
  async create(amount, transactionType, walletUri) {
@@ -1436,7 +1790,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
1436
1790
  Retrievable,
1437
1791
  ) {
1438
1792
  constructor(client) {
1439
- super('whatsapp_transfers', queries.QueryParams, client);
1793
+ super('whatsapp_transfers', identities.QueryParams, client);
1440
1794
  }
1441
1795
 
1442
1796
  async accountDestination(destinationUri) {
@@ -1449,8 +1803,13 @@ class WhatsAppTransferResource extends mix(Resource).with(
1449
1803
  }
1450
1804
 
1451
1805
  class Cuenca {
1452
- constructor(apiKey, apiSecret, phase = queries.Phase.Sandbox) {
1453
- this.client = new Client({ apiKey, apiSecret, phase });
1806
+ constructor({
1807
+ apiKey,
1808
+ apiSecret,
1809
+ language = 'en',
1810
+ phase = data.Phase.Sandbox,
1811
+ } = {}) {
1812
+ this.client = new Client({ apiKey, apiSecret, language, phase });
1454
1813
  this.withClient(this.client);
1455
1814
  }
1456
1815
 
@@ -1465,6 +1824,7 @@ class Cuenca {
1465
1824
  this.cardValidations = new CardValidationResource(client);
1466
1825
  this.commissions = new CommissionResource(client);
1467
1826
  this.deposits = new DepositResource(client);
1827
+ this.identities = new IdentitiesResource(client);
1468
1828
  this.loginTokens = new LoginTokenResource(client);
1469
1829
  this.savings = new SavingResource(client);
1470
1830
  this.serviceProviders = new ServiceProviderResource(client);
@@ -1472,47 +1832,11 @@ class Cuenca {
1472
1832
  this.transfers = new TransferResource(client);
1473
1833
  this.userCredentials = new UserCredentialResource(client);
1474
1834
  this.userLogins = new UserLoginResource(client);
1835
+ this.users = new UserResourse(client);
1836
+ this.verifications = new VerificationResourse(client);
1475
1837
  this.walletTransactions = new WalletTransactionsResource(client);
1476
1838
  this.whatsAppTransfers = new WhatsAppTransferResource(client);
1477
1839
  }
1478
1840
  }
1479
1841
 
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
1842
  exports.Cuenca = Cuenca;