@cuenca-mx/cuenca-js 0.0.1-dev.9 → 0.0.2-dev.3

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,46 @@
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-b9ee2ed8.cjs');
12
+ require('module');
11
13
 
12
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
15
 
14
16
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
17
+ var Buffer__default = /*#__PURE__*/_interopDefaultLegacy(Buffer);
18
+
19
+ /* global window */
20
+
21
+ const isBrowser =
22
+ typeof window !== 'undefined' && typeof window.document !== 'undefined';
23
+
24
+ const isNode =
25
+ typeof process !== 'undefined' &&
26
+ Object.prototype.toString.call(process) === '[object process]';
27
+
28
+ const runtimeEnv = { isBrowser, isNode };
29
+
30
+ const name="@cuenca-mx/cuenca-js";const version="0.0.2-dev.3";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","form-data":"^4.0.0","formdata-node":"^4.3.2"};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
31
 
16
32
  class Client {
17
- constructor({ apiKey, apiSecret, phase = queries.Phase.Sandbox } = {}) {
33
+ constructor({
34
+ apiKey,
35
+ apiSecret,
36
+ language = 'en',
37
+ phase = data.Phase.Sandbox,
38
+ } = {}) {
18
39
  this.phase = phase;
19
40
  this.basicAuth = { apiKey, apiSecret };
20
41
  this.jwtToken = null;
21
- this._session = axios__default["default"].create();
42
+ this._session = axios__default["default"].create({
43
+ headers: { 'Accept-Language': language },
44
+ timeout: 45000,
45
+ });
22
46
  }
23
47
 
24
48
  get session() {
@@ -32,8 +56,9 @@ class Client {
32
56
  get authHeader() {
33
57
  const { apiKey, apiSecret } = this.basicAuth;
34
58
  if (!apiKey || !apiSecret) return '';
35
- return `Basic ${Buffer.from(
36
- Buffer.from(`${apiKey}:${apiSecret}`).toString('utf-8'),
59
+ return `Basic ${Buffer__default["default"].Buffer.from(
60
+ `${apiKey}:${apiSecret}`,
61
+ 'utf-8',
37
62
  ).toString('base64')}`;
38
63
  }
39
64
 
@@ -79,7 +104,14 @@ class Client {
79
104
  };
80
105
  }
81
106
 
82
- async configure({ apiKey, apiSecret, loginToken, phase, useJwt = false }) {
107
+ async configure({
108
+ apiKey,
109
+ apiSecret,
110
+ loginToken,
111
+ phase,
112
+ sessionId,
113
+ useJwt = false,
114
+ }) {
83
115
  this.basicAuth = {
84
116
  apiKey: apiKey || this.basicAuth.apiKey,
85
117
  apiSecret: apiSecret || this.basicAuth.apiSecret,
@@ -92,14 +124,18 @@ class Client {
92
124
  if (loginToken) {
93
125
  this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
94
126
  }
127
+
128
+ if (sessionId) {
129
+ this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
130
+ }
95
131
  }
96
132
 
97
133
  async get({ endpoint, format, params }) {
98
134
  return this.request({ endpoint, format, params });
99
135
  }
100
136
 
101
- async post({ endpoint, data }) {
102
- return this.request({ method: 'POST', endpoint, data });
137
+ async post({ endpoint, data, multipart }) {
138
+ return this.request({ method: 'POST', endpoint, data, multipart });
103
139
  }
104
140
 
105
141
  async patch({ endpoint, data }) {
@@ -112,17 +148,35 @@ class Client {
112
148
 
113
149
  async request({
114
150
  endpoint,
115
- data = null,
116
- format = queries.FileFormat.Json,
151
+ data: data$1 = null,
152
+ format = data.FileFormat.Json,
117
153
  method = 'GET',
154
+ multipart = false,
118
155
  params = null,
119
156
  }) {
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
- };
157
+ console.log('multipart :', multipart);
158
+ console.log('endPoint', endpoint);
159
+ let headers;
160
+ if (multipart) {
161
+ headers = data$1.getHeaders();
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) {
@@ -142,6 +197,8 @@ class Client {
142
197
  });
143
198
  }
144
199
 
200
+ console.log('modifiedData :', modifiedData);
201
+
145
202
  const configInterceptor = this.addConfigToRequest({
146
203
  method,
147
204
  params,
@@ -255,7 +312,7 @@ class BalanceEntry {
255
312
  this.amount = amount;
256
313
  this.createdAt = data.dateToUTC(createdAt);
257
314
  this.descriptor = descriptor;
258
- this.entryType = data.enumValueFromString(queries.EntryType, entryType);
315
+ this.entryType = data.enumValueFromString(data.EntryType, entryType);
259
316
  this.fundingInstrumentUri = fundingInstrumentUri;
260
317
  this.id = id;
261
318
  this.name = name;
@@ -282,7 +339,7 @@ class Transaction {
282
339
  this.amount = amount;
283
340
  this.createdAt = data.dateToUTC(createdAt);
284
341
  this.descriptor = descriptor;
285
- this.status = data.enumValueFromString(queries.TransactionStatus, status);
342
+ this.status = data.enumValueFromString(data.TransactionStatus, status);
286
343
  this.userId = userId;
287
344
  }
288
345
  }
@@ -298,7 +355,13 @@ class BillPayment extends Transaction {
298
355
  status,
299
356
  userId,
300
357
  }) {
301
- super({ amount, createdAt, descriptor, status, userId });
358
+ super({
359
+ amount,
360
+ createdAt,
361
+ descriptor,
362
+ status,
363
+ userId,
364
+ });
302
365
  this.accountNumber = accountNumber;
303
366
  this.id = id;
304
367
  this.providerUri = providerUri;
@@ -337,13 +400,13 @@ class Card {
337
400
  this.cvv2 = cvv2;
338
401
  this.expMonth = expMonth;
339
402
  this.expYear = expYear;
340
- this.fundingType = data.enumValueFromString(queries.CardFundingType, fundingType);
403
+ this.fundingType = data.enumValueFromString(data.CardFundingType, fundingType);
341
404
  this.id = id;
342
- this.issuer = data.enumValueFromString(queries.CardIssuer, issuer);
405
+ this.issuer = data.enumValueFromString(data.CardIssuer, issuer);
343
406
  this.number = number;
344
407
  this.pin = pin;
345
- this.status = data.enumValueFromString(queries.CardStatus, status);
346
- this.type = data.enumValueFromString(queries.CardType, type);
408
+ this.status = data.enumValueFromString(data.CardStatus, status);
409
+ this.type = data.enumValueFromString(data.CardType, type);
347
410
  this.updatedAt = data.dateToUTC(updatedAt);
348
411
  this.userId = userId;
349
412
  }
@@ -412,15 +475,21 @@ class CardTransaction extends Transaction {
412
475
  type,
413
476
  userId,
414
477
  }) {
415
- super({ amount, createdAt, descriptor, status, userId });
416
- this.cardErrorType = data.enumValueFromString(queries.CardErrorType, cardErrorType);
478
+ super({
479
+ amount,
480
+ createdAt,
481
+ descriptor,
482
+ status,
483
+ userId,
484
+ });
485
+ this.cardErrorType = data.enumValueFromString(data.CardErrorType, cardErrorType);
417
486
  this.cardLastFour = cardLastFour;
418
- this.cardType = data.enumValueFromString(queries.CardType, cardType);
487
+ this.cardType = data.enumValueFromString(data.CardType, cardType);
419
488
  this.cardUri = cardUri;
420
489
  this.metadata = metadata;
421
490
  this.network = network;
422
491
  this.relatedCardTransactionsUris = relatedCardTransactionsUris;
423
- this.type = data.enumValueFromString(queries.CardTransactionType, type);
492
+ this.type = data.enumValueFromString(data.CardTransactionType, type);
424
493
  }
425
494
 
426
495
  static fromObject = ({
@@ -464,8 +533,8 @@ class CardValidation {
464
533
  isValidPinBlock,
465
534
  userId,
466
535
  }) {
467
- this.cardStatus = data.enumValueFromString(queries.CardStatus, cardStatus);
468
- this.cardType = data.enumValueFromString(queries.CardType, cardType);
536
+ this.cardStatus = data.enumValueFromString(data.CardStatus, cardStatus);
537
+ this.cardType = data.enumValueFromString(data.CardType, cardType);
469
538
  this.cardUri = cardUri;
470
539
  this.createdAt = data.dateToUTC(createdAt);
471
540
  this.isExpired = isExpired;
@@ -495,7 +564,7 @@ class CardValidation {
495
564
  });
496
565
 
497
566
  get isActive() {
498
- return this.cardStatus === queries.CardStatus.Active;
567
+ return this.cardStatus === data.CardStatus.Active;
499
568
  }
500
569
  }
501
570
 
@@ -509,9 +578,15 @@ class Commission extends Transaction {
509
578
  type,
510
579
  userId,
511
580
  }) {
512
- super({ amount, createdAt, descriptor, status, userId });
581
+ super({
582
+ amount,
583
+ createdAt,
584
+ descriptor,
585
+ status,
586
+ userId,
587
+ });
513
588
  this.relatedTransactionUri = relatedTransactionUri;
514
- this.type = data.enumValueFromString(queries.CommissionType, type);
589
+ this.type = data.enumValueFromString(data.CommissionType, type);
515
590
  }
516
591
 
517
592
  static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
@@ -538,9 +613,15 @@ class Deposit extends Transaction {
538
613
  trackingKey,
539
614
  userId,
540
615
  }) {
541
- super({ amount, createdAt, descriptor, status, userId });
616
+ super({
617
+ amount,
618
+ createdAt,
619
+ descriptor,
620
+ status,
621
+ userId,
622
+ });
542
623
  this.id = id;
543
- this.network = data.enumValueFromString(queries.DepositNetwork, network);
624
+ this.network = data.enumValueFromString(data.DepositNetwork, network);
544
625
  this.sourceUri = sourceUri;
545
626
  this.trackingKey = trackingKey;
546
627
  }
@@ -559,6 +640,96 @@ class Deposit extends Transaction {
559
640
  });
560
641
  }
561
642
 
643
+ class Identities {
644
+ constructor({
645
+ address,
646
+ blacklistValidationStatus,
647
+ countryOfBirth,
648
+ createdAt,
649
+ curp,
650
+ dateOfBirth,
651
+ extension,
652
+ firstSurname,
653
+ gender,
654
+ govId,
655
+ id,
656
+ names,
657
+ nationality,
658
+ proofOfAddress,
659
+ proofOfLife,
660
+ rfc,
661
+ rfcDocument,
662
+ rfcFile,
663
+ secondSurname,
664
+ stateOfBirth,
665
+ status,
666
+ tosAgreement,
667
+ userId,
668
+ }) {
669
+ this.address = address;
670
+ this.blacklistValidationStatus = blacklistValidationStatus;
671
+ this.countryOfBirth = countryOfBirth;
672
+ this.createdAt = createdAt;
673
+ this.curp = curp;
674
+ this.dateOfBirth = dateOfBirth;
675
+ this.extension = extension;
676
+ this.firstSurname = firstSurname;
677
+ this.gender = gender;
678
+ this.govId = govId;
679
+ this.id = id;
680
+ this.names = names;
681
+ this.nationality = nationality;
682
+ this.proofOfAddress = proofOfAddress;
683
+ this.proofOfLife = proofOfLife;
684
+ this.rfc = rfc;
685
+ this.rfcDocument = rfcDocument;
686
+ this.rfcFile = rfcFile;
687
+ this.secondSurname = secondSurname;
688
+ this.stateOfBirth = stateOfBirth;
689
+ this.status = status;
690
+ this.tosAgreement = tosAgreement;
691
+ this.userId = userId;
692
+ }
693
+
694
+ static fromObject = ({
695
+ address,
696
+ curp,
697
+ extension,
698
+ gender,
699
+ id,
700
+ names,
701
+ nationality,
702
+ rfc,
703
+ status,
704
+ ...obj
705
+ }) =>
706
+ new Identities({
707
+ address,
708
+ curp,
709
+ extension,
710
+ gender,
711
+ id,
712
+ names,
713
+ nationality,
714
+ rfc,
715
+ status,
716
+ blacklistValidationStatus: obj.blacklist_validation_status,
717
+ countryOfBirth: obj.country_of_birth,
718
+ createdAt: obj.created_at,
719
+ dateOfBirth: obj.date_of_birth,
720
+ firstSurname: obj.first_surname,
721
+ govId: obj.gov_id,
722
+ proofOfAddress: obj.proof_of_address,
723
+ proofOfLife: obj.proof_of_life,
724
+ rfcDocument: obj.rfc_document,
725
+ rfcFile: obj.rfc_file,
726
+ secondSurname: obj.second_surname,
727
+ stateOfBirth: obj.state_of_birth,
728
+ tosAgreement: obj.tos_agreement,
729
+ userId: obj.user_id,
730
+ });
731
+ }
732
+
562
733
  class LoginToken {
563
734
  constructor({ id }) {
564
735
  this.id = id;
@@ -591,8 +762,15 @@ class Saving extends Wallet {
591
762
  userId,
592
763
  updatedAt,
593
764
  }) {
594
- super({ balance, createdAt, deactivatedAt, id, userId, updatedAt });
595
- this.category = data.enumValueFromString(queries.SavingCategory, category);
765
+ super({
766
+ balance,
767
+ createdAt,
768
+ deactivatedAt,
769
+ id,
770
+ userId,
771
+ updatedAt,
772
+ });
773
+ this.category = data.enumValueFromString(data.SavingCategory, category);
596
774
  this.goalAmount = goalAmount;
597
775
  this.goalDate = data.dateToUTC(goalDate);
598
776
  this.name = name;
@@ -616,7 +794,7 @@ class Saving extends Wallet {
616
794
  const categoriesFromString = (categoriesList) => {
617
795
  if (categoriesList == null) return [];
618
796
  return categoriesList.map((category) =>
619
- data.enumValueFromString(queries.ServiceProviderCategory, category),
797
+ data.enumValueFromString(data.ServiceProviderCategory, category),
620
798
  );
621
799
  };
622
800
 
@@ -670,12 +848,18 @@ class Transfer extends Transaction {
670
848
  updatedAt,
671
849
  userId,
672
850
  }) {
673
- super({ amount, createdAt, descriptor, status, userId });
851
+ super({
852
+ amount,
853
+ createdAt,
854
+ descriptor,
855
+ status,
856
+ userId,
857
+ });
674
858
  this.accountNumber = accountNumber;
675
859
  this.destinationUri = destinationUri;
676
860
  this.id = id;
677
861
  this.idempotencyKey = idempotencyKey;
678
- this.network = data.enumValueFromString(queries.TransferNetwork, network);
862
+ this.network = data.enumValueFromString(data.TransferNetwork, network);
679
863
  this.recipientName = recipientName;
680
864
  this.trackingKey = trackingKey;
681
865
  this.updatedAt = data.dateToUTC(updatedAt);
@@ -699,6 +883,82 @@ class Transfer extends Transaction {
699
883
  });
700
884
  }
701
885
 
886
+ class User {
887
+ constructor({
888
+ emailAddress,
889
+ govtId,
890
+ identityUri,
891
+ level,
892
+ phoneNumber,
893
+ proofOfAddress,
894
+ proofOfLife,
895
+ status,
896
+ termsOfService,
897
+ verificationId,
898
+ }) {
899
+ this.emailAddress = emailAddress;
900
+ this.govstIds = govtId;
901
+ this.identityUri = identityUri;
902
+ this.level = level;
903
+ this.phoneNumber = phoneNumber;
904
+ this.addressProofs = proofOfAddress;
905
+ this.lifeProofs = proofOfLife;
906
+ this.status = data.enumValueFromString(data.UserStatus, status);
907
+ this.terms = termsOfService;
908
+ this.verificationId = verificationId;
909
+ }
910
+
911
+ get proofOfAddress() {
912
+ return this._proofOfAddress;
913
+ }
914
+
915
+ set addressProofs(value) {
916
+ if (!value) return;
917
+ this._proofOfAddress = identities.KYCFile.fromObject(value);
918
+ }
919
+
920
+ get proofOfLife() {
921
+ return this._proofOfLife;
922
+ }
923
+
924
+ set lifeProofs(value) {
925
+ if (!value) return;
926
+ this._proofOfLife = identities.KYCFile.fromObject(value);
927
+ }
928
+
929
+ get govtId() {
930
+ return this._govtId;
931
+ }
932
+
933
+ set govstIds(value) {
934
+ if (!value) return;
935
+ this._govtId = identities.KYCFile.fromObject(value);
936
+ }
937
+
938
+ get termsOfService() {
939
+ return this._termsOfService;
940
+ }
941
+
942
+ set terms(value) {
943
+ if (!value) return;
944
+ this._termsOfService = identities.TOSAgreements.fromObject(value);
945
+ }
946
+
947
+ static fromObject = ({ level, status, ...obj }) =>
948
+ new User({
949
+ level,
950
+ status,
951
+ govtId: obj.govt_id,
952
+ identityUri: obj.identity_uri,
953
+ emailAddress: obj.email_address,
954
+ phoneNumber: obj.phone_number,
955
+ proofOfAddress: obj.proof_of_address,
956
+ proofOfLife: obj.proof_of_life,
957
+ termsOfService: obj.terms_of_service,
958
+ verificationId: obj.verification_id,
959
+ });
960
+ }
961
+
702
962
  class UserCredential {
703
963
  constructor({ createdAt, id, isActive, updatedAt }) {
704
964
  this.createdAt = data.dateToUTC(createdAt);
@@ -731,6 +991,27 @@ class UserLogin {
731
991
  });
732
992
  }
733
993
 
994
+ class Verification {
995
+ constructor({ createdAt, id, platformId, recipient, type, updatedAt }) {
996
+ this.createdAt = data.dateToUTC(createdAt);
997
+ this.id = id;
998
+ this.platformId = platformId;
999
+ this.recipient = recipient;
1000
+ this.type = data.enumValueFromString(data.VerificationType, type);
1001
+ this.updatedAt = data.dateToUTC(updatedAt);
1002
+ }
1003
+
1004
+ static fromObject = ({ id, recipient, type, ...obj }) =>
1005
+ new Verification({
1006
+ id,
1007
+ recipient,
1008
+ type,
1009
+ createdAt: obj.created_at,
1010
+ platformId: obj.platform_id,
1011
+ updatedAt: obj.updated_at,
1012
+ });
1013
+ }
1014
+
734
1015
  class WalletTransaction extends Transaction {
735
1016
  constructor({
736
1017
  amount,
@@ -742,10 +1023,16 @@ class WalletTransaction extends Transaction {
742
1023
  userId,
743
1024
  walletUri,
744
1025
  }) {
745
- super({ amount, createdAt, descriptor, status, userId });
1026
+ super({
1027
+ amount,
1028
+ createdAt,
1029
+ descriptor,
1030
+ status,
1031
+ userId,
1032
+ });
746
1033
  this.id = id;
747
1034
  this.transactionType = data.enumValueFromString(
748
- queries.WalletTransactionType,
1035
+ data.WalletTransactionType,
749
1036
  transactionType,
750
1037
  );
751
1038
  this.walletUri = walletUri;
@@ -781,12 +1068,18 @@ class WhatsAppTransfer extends Transaction {
781
1068
  updatedAt,
782
1069
  userId,
783
1070
  }) {
784
- super({ amount, createdAt, descriptor, status, userId });
1071
+ super({
1072
+ amount,
1073
+ createdAt,
1074
+ descriptor,
1075
+ status,
1076
+ userId,
1077
+ });
785
1078
  this.claimUrl = claimUrl;
786
1079
  this.destinationUri = destinationUri;
787
1080
  this.id = id;
788
1081
  this.expiresAt = data.dateToUTC(expiresAt);
789
- this.network = data.enumValueFromString(queries.TransferNetwork, network);
1082
+ this.network = data.enumValueFromString(data.TransferNetwork, network);
790
1083
  this.phoneNumber = phoneNumber;
791
1084
  this.recipientName = recipientName;
792
1085
  this.trackingKey = trackingKey;
@@ -837,13 +1130,16 @@ const getModelFromPath = (path, obj) => {
837
1130
  card_validations: () => CardValidation.fromObject(obj),
838
1131
  commissions: () => Commission.fromObject(obj),
839
1132
  deposits: () => Deposit.fromObject(obj),
1133
+ identities: () => Identities.fromObject(obj),
840
1134
  login_tokens: () => LoginToken.fromObject(obj),
841
1135
  savings: () => Saving.fromObject(obj),
842
1136
  service_providers: () => ServiceProvider.fromObject(obj),
843
1137
  statements: () => Statement.fromObject(obj),
844
1138
  transfers: () => Transfer.fromObject(obj),
1139
+ users: () => User.fromObject(obj),
845
1140
  user_credentials: () => UserCredential.fromObject(obj),
846
1141
  user_logins: () => UserLogin.fromObject(obj),
1142
+ verifications: () => Verification.fromObject(obj),
847
1143
  wallet_transactions: () => WalletTransaction.fromObject(obj),
848
1144
  whatsapp_transfers: () => WhatsAppTransfer.fromObject(obj),
849
1145
  };
@@ -900,6 +1196,19 @@ const Updateable = (SuperClass) =>
900
1196
  }
901
1197
  };
902
1198
 
1199
+ const Uploadable = (SuperClass) =>
1200
+ class Uploadable extends SuperClass {
1201
+ async _upload(id, data) {
1202
+ const response = await this.client.post({
1203
+ endpoint: `/${this.path}`,
1204
+ data,
1205
+ multipart: true,
1206
+ });
1207
+ const model = getModelFromPath(this.path, response);
1208
+ return model;
1209
+ }
1210
+ };
1211
+
903
1212
  const Deactivable = (SuperClass) =>
904
1213
  class Deactivable extends SuperClass {
905
1214
  async _deactivate(id, data) {
@@ -981,7 +1290,7 @@ const Queryable = (SuperClass) =>
981
1290
 
982
1291
  class AccountResource extends mix(Resource).with(Queryable, Retrievable) {
983
1292
  constructor(client) {
984
- super('accounts', queries.AccountQuery, client);
1293
+ super('accounts', identities.AccountQuery, client);
985
1294
  }
986
1295
  }
987
1296
 
@@ -993,7 +1302,7 @@ class ApiKeyResource extends mix(Resource).with(
993
1302
  Updateable,
994
1303
  ) {
995
1304
  constructor(client) {
996
- super('api_keys', queries.ApiKeyQuery, client);
1305
+ super('api_keys', identities.ApiKeyQuery, client);
997
1306
  }
998
1307
 
999
1308
  async create() {
@@ -1047,7 +1356,7 @@ class ArpcResource extends mix(Resource).with(Creatable) {
1047
1356
 
1048
1357
  class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
1049
1358
  constructor(client) {
1050
- super('balance_entries', queries.BalanceEntryQuery, client);
1359
+ super('balance_entries', identities.BalanceEntryQuery, client);
1051
1360
  }
1052
1361
 
1053
1362
  async relatedTransaction(relatedTransactionUri) {
@@ -1073,7 +1382,7 @@ class BalanceEntryResource extends mix(Resource).with(Queryable, Retrievable) {
1073
1382
 
1074
1383
  class BillPaymentResource extends mix(Resource).with(Queryable, Retrievable) {
1075
1384
  constructor(client) {
1076
- super('bill_payments', queries.BillPaymentQuery, client);
1385
+ super('bill_payments', identities.BillPaymentQuery, client);
1077
1386
  }
1078
1387
 
1079
1388
  async serviceProvider(providerUri) {
@@ -1111,7 +1420,7 @@ class CardResource extends mix(Resource).with(
1111
1420
  Updateable,
1112
1421
  ) {
1113
1422
  constructor(client) {
1114
- super('cards', queries.CardsQuery, client);
1423
+ super('cards', identities.CardsQuery, client);
1115
1424
  }
1116
1425
 
1117
1426
  async create(userId, issuer, fundingType) {
@@ -1137,7 +1446,7 @@ class CardTransactionResource extends mix(Resource).with(
1137
1446
  Retrievable,
1138
1447
  ) {
1139
1448
  constructor(client) {
1140
- super('card_transactions', queries.CardTransactionQuery, client);
1449
+ super('card_transactions', identities.CardTransactionQuery, client);
1141
1450
  }
1142
1451
 
1143
1452
  async relatedCard(relatedCardUri) {
@@ -1189,7 +1498,7 @@ class CardValidationResource extends mix(Resource).with(Creatable) {
1189
1498
 
1190
1499
  class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
1191
1500
  constructor(client) {
1192
- super('commissions', queries.QueryParams, client);
1501
+ super('commissions', identities.QueryParams, client);
1193
1502
  }
1194
1503
 
1195
1504
  async relatedTransaction(relatedTransactionUri) {
@@ -1203,7 +1512,7 @@ class CommissionResource extends mix(Resource).with(Queryable, Retrievable) {
1203
1512
 
1204
1513
  class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
1205
1514
  constructor(client) {
1206
- super('deposits', queries.DepositQuery, client);
1515
+ super('deposits', identities.DepositQuery, client);
1207
1516
  }
1208
1517
 
1209
1518
  async source(sourceUri) {
@@ -1212,6 +1521,19 @@ class DepositResource extends mix(Resource).with(Queryable, Retrievable) {
1212
1521
  }
1213
1522
  }
1214
1523
 
1524
+ class IdentitiesResource extends mix(Resource).with(Uploadable) {
1525
+ constructor(client) {
1526
+ super('identities', Object, client);
1527
+ }
1528
+
1529
+ async upload({ extension, id, rfcFile, userId = 'me' }) {
1530
+ const request = new walletTransactionRequest.IdentitiesUploadRequest({ extension, rfcFile, userId });
1531
+ const identities = await this._upload(id, request.toFormData());
1532
+ // const identities = await this._update(identityId, request.toObject());
1533
+ return identities;
1534
+ }
1535
+ }
1536
+
1215
1537
  class LoginTokenResource extends mix(Resource).with(Creatable) {
1216
1538
  constructor(client) {
1217
1539
  super('login_tokens', Object, client);
@@ -1231,7 +1553,7 @@ class SavingResource extends mix(Resource).with(
1231
1553
  Updateable,
1232
1554
  ) {
1233
1555
  constructor(client) {
1234
- super('savings', queries.WalletQuery, client);
1556
+ super('savings', identities.WalletQuery, client);
1235
1557
  }
1236
1558
 
1237
1559
  async create(category, goalAmount, goalDate, name) {
@@ -1257,22 +1579,22 @@ class ServiceProviderResource extends mix(Resource).with(
1257
1579
  Retrievable,
1258
1580
  ) {
1259
1581
  constructor(client) {
1260
- super('service_providers', queries.QueryParams, client);
1582
+ super('service_providers', identities.QueryParams, client);
1261
1583
  }
1262
1584
  }
1263
1585
 
1264
1586
  class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
1265
1587
  constructor(client) {
1266
- super('statements', queries.StatementQuery, client);
1588
+ super('statements', identities.StatementQuery, client);
1267
1589
  }
1268
1590
 
1269
1591
  async pdf(id) {
1270
- const byteString = await this._download(id, queries.FileFormat.Pdf);
1592
+ const byteString = await this._download(id, data.FileFormat.Pdf);
1271
1593
  return byteString;
1272
1594
  }
1273
1595
 
1274
1596
  async xml(id) {
1275
- const byteString = await this._download(id, queries.FileFormat.Xml);
1597
+ const byteString = await this._download(id, data.FileFormat.Xml);
1276
1598
  return byteString;
1277
1599
  }
1278
1600
  }
@@ -1283,7 +1605,7 @@ class TransferResource extends mix(Resource).with(
1283
1605
  Retrievable,
1284
1606
  ) {
1285
1607
  constructor(client) {
1286
- super('transfers', queries.TransferQuery, client);
1608
+ super('transfers', identities.TransferQuery, client);
1287
1609
  }
1288
1610
 
1289
1611
  async destination(destinationUri) {
@@ -1403,13 +1725,47 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
1403
1725
  }
1404
1726
  }
1405
1727
 
1728
+ class UserResourse extends mix(Resource).with(
1729
+ Queryable,
1730
+ Updateable,
1731
+ Retrievable,
1732
+ ) {
1733
+ constructor(client) {
1734
+ super('users', identities.UserQuery, client);
1735
+ }
1736
+
1737
+ async update({ userId = 'me', ...req }) {
1738
+ const request = new walletTransactionRequest.UserUpdateRequest(req);
1739
+ const user = await this._update(userId, request.toCleanObject());
1740
+ return user;
1741
+ }
1742
+ }
1743
+
1744
+ class VerificationResourse extends mix(Resource).with(Creatable, Updateable) {
1745
+ constructor(client) {
1746
+ super('verifications', Object, client);
1747
+ }
1748
+
1749
+ async create({ platformId, recipient, type }) {
1750
+ const request = new walletTransactionRequest.VerificationRequest({ platformId, recipient, type });
1751
+ const verification = await this._create(request.toObject());
1752
+ return verification;
1753
+ }
1754
+
1755
+ async update({ code, id }) {
1756
+ const request = new walletTransactionRequest.VerificationAttemptRequest({ code });
1757
+ const verification = await this._update(id, request.toObject());
1758
+ return verification;
1759
+ }
1760
+ }
1761
+
1406
1762
  class WalletTransactionsResource extends mix(Resource).with(
1407
1763
  Creatable,
1408
1764
  Queryable,
1409
1765
  Retrievable,
1410
1766
  ) {
1411
1767
  constructor(client) {
1412
- super('wallet_transactions', queries.WalletTransactionQuery, client);
1768
+ super('wallet_transactions', identities.WalletTransactionQuery, client);
1413
1769
  }
1414
1770
 
1415
1771
  async create(amount, transactionType, walletUri) {
@@ -1436,7 +1792,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
1436
1792
  Retrievable,
1437
1793
  ) {
1438
1794
  constructor(client) {
1439
- super('whatsapp_transfers', queries.QueryParams, client);
1795
+ super('whatsapp_transfers', identities.QueryParams, client);
1440
1796
  }
1441
1797
 
1442
1798
  async accountDestination(destinationUri) {
@@ -1449,8 +1805,13 @@ class WhatsAppTransferResource extends mix(Resource).with(
1449
1805
  }
1450
1806
 
1451
1807
  class Cuenca {
1452
- constructor(apiKey, apiSecret, phase = queries.Phase.Sandbox) {
1453
- this.client = new Client({ apiKey, apiSecret, phase });
1808
+ constructor({
1809
+ apiKey,
1810
+ apiSecret,
1811
+ language = 'en',
1812
+ phase = data.Phase.Sandbox,
1813
+ } = {}) {
1814
+ this.client = new Client({ apiKey, apiSecret, language, phase });
1454
1815
  this.withClient(this.client);
1455
1816
  }
1456
1817
 
@@ -1465,6 +1826,7 @@ class Cuenca {
1465
1826
  this.cardValidations = new CardValidationResource(client);
1466
1827
  this.commissions = new CommissionResource(client);
1467
1828
  this.deposits = new DepositResource(client);
1829
+ this.identities = new IdentitiesResource(client);
1468
1830
  this.loginTokens = new LoginTokenResource(client);
1469
1831
  this.savings = new SavingResource(client);
1470
1832
  this.serviceProviders = new ServiceProviderResource(client);
@@ -1472,47 +1834,11 @@ class Cuenca {
1472
1834
  this.transfers = new TransferResource(client);
1473
1835
  this.userCredentials = new UserCredentialResource(client);
1474
1836
  this.userLogins = new UserLoginResource(client);
1837
+ this.users = new UserResourse(client);
1838
+ this.verifications = new VerificationResourse(client);
1475
1839
  this.walletTransactions = new WalletTransactionsResource(client);
1476
1840
  this.whatsAppTransfers = new WhatsAppTransferResource(client);
1477
1841
  }
1478
1842
  }
1479
1843
 
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
1844
  exports.Cuenca = Cuenca;