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

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