@cuenca-mx/cuenca-js 0.0.1-dev.21 → 0.0.1-dev.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -6,9 +6,9 @@ var axios = require('axios');
6
6
  var Buffer = require('buffer');
7
7
  var errors_index = require('./errors/index.cjs');
8
8
  var jwt_index = require('./jwt/index.cjs');
9
- var queries = require('./queries-0c03273e.cjs');
10
- var data = require('./data-9edbb2a0.cjs');
11
- var walletTransactionRequest = require('./walletTransactionRequest-f549e991.cjs');
9
+ var identities = require('./identities-b7106a30.cjs');
10
+ var queries = require('./queries-bc02f9a8.cjs');
11
+ var walletTransactionRequest = require('./walletTransactionRequest-a1851594.cjs');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
14
 
@@ -26,10 +26,10 @@ const isNode =
26
26
 
27
27
  const runtimeEnv = { isBrowser, isNode };
28
28
 
29
- const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.21";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};
29
+ const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.22";const description="Cuenca client for JS";const main="./build/index.cjs";const module$1="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports$1={".":{"import":"./build/index.mjs",require:"./build/index.cjs"},"./errors":{"import":"./build/errors/index.mjs",require:"./build/errors/index.cjs"},"./jwt":{"import":"./build/jwt/index.mjs",require:"./build/jwt/index.cjs"},"./requests":{"import":"./build/requests/index.mjs",require:"./build/requests/index.cjs"},"./types":{"import":"./build/types/index.mjs",require:"./build/types/index.cjs"}};const packageManager="yarn@3.0.2";const type="module";const repository={type:"git",url:"https://github.com/cuenca-mx/cuenca-js.git",directory:"packages/cuenca-js"};const keywords=["cuenca"];const license="MIT";const bugs={url:"https://github.com/cuenca-mx/cuenca-js/issues"};const homepage="https://cuenca.com";const scripts={build:"rm -rf build/ && yarn rollup --config",test:"yarn node --experimental-vm-modules $(yarn bin jest)",publish:"yarn build && yarn npm publish"};const devDependencies={"@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.1",jest:"^27.4.5",rollup:"^2.61.1","rollup-plugin-terser":"^7.0.2"};const dependencies={axios:"^0.24.0",buffer:"^6.0.3"};var pkg = {name:name,version:version,description:description,main:main,module:module$1,browser:browser,files:files,exports:exports$1,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
30
30
 
31
31
  class Client {
32
- constructor({ apiKey, apiSecret, phase = queries.Phase.Sandbox } = {}) {
32
+ constructor({ apiKey, apiSecret, phase = identities.Phase.Sandbox } = {}) {
33
33
  this.phase = phase;
34
34
  this.basicAuth = { apiKey, apiSecret };
35
35
  this.jwtToken = null;
@@ -95,7 +95,7 @@ class Client {
95
95
  };
96
96
  }
97
97
 
98
- async configure({ apiKey, apiSecret, loginToken, phase, sessionId,useJwt = false }) {
98
+ async configure({ apiKey, apiSecret, loginToken, phase, useJwt = false }) {
99
99
  this.basicAuth = {
100
100
  apiKey: apiKey || this.basicAuth.apiKey,
101
101
  apiSecret: apiSecret || this.basicAuth.apiSecret,
@@ -108,10 +108,6 @@ class Client {
108
108
  if (loginToken) {
109
109
  this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
110
110
  }
111
-
112
- if (sessionId) {
113
- this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
114
- }
115
111
  }
116
112
 
117
113
  async get({ endpoint, format, params }) {
@@ -133,7 +129,7 @@ class Client {
133
129
  async request({
134
130
  endpoint,
135
131
  data = null,
136
- format = queries.FileFormat.Json,
132
+ format = identities.FileFormat.Json,
137
133
  method = 'GET',
138
134
  params = null,
139
135
  }) {
@@ -204,7 +200,7 @@ class Client {
204
200
  class Account {
205
201
  constructor({ accountNumber, createdAt, id, institutionName, name, userId }) {
206
202
  this.accountNumber = accountNumber;
207
- this.createdAt = data.dateToUTC(createdAt);
203
+ this.createdAt = identities.dateToUTC(createdAt);
208
204
  this.id = id;
209
205
  this.institutionName = institutionName;
210
206
  this.name = name;
@@ -224,12 +220,12 @@ class Account {
224
220
 
225
221
  class ApiKey {
226
222
  constructor({ createdAt, deactivatedAt, id, secret, userId, updatedAt }) {
227
- this.createdAt = data.dateToUTC(createdAt);
228
- this.deactivatedAt = data.dateToUTC(deactivatedAt);
223
+ this.createdAt = identities.dateToUTC(createdAt);
224
+ this.deactivatedAt = identities.dateToUTC(deactivatedAt);
229
225
  this.id = id;
230
226
  this.secret = secret;
231
227
  this.userId = userId;
232
- this.updatedAt = data.dateToUTC(updatedAt);
228
+ this.updatedAt = identities.dateToUTC(updatedAt);
233
229
  }
234
230
 
235
231
  static fromObject = ({ id, secret, ...obj }) =>
@@ -243,7 +239,7 @@ class ApiKey {
243
239
  });
244
240
 
245
241
  get isActive() {
246
- const todayUTC = data.dateToUTC(Date.now());
242
+ const todayUTC = identities.dateToUTC(Date.now());
247
243
  return (
248
244
  !this.deactivatedAt || this.deactivatedAt.getTime() > todayUTC.getTime()
249
245
  );
@@ -253,7 +249,7 @@ class ApiKey {
253
249
  class Arpc {
254
250
  constructor({ arpc, createdAt, cardUri, isValidArqc }) {
255
251
  this.arpc = arpc;
256
- this.createdAt = data.dateToUTC(createdAt);
252
+ this.createdAt = identities.dateToUTC(createdAt);
257
253
  this.cardUri = cardUri;
258
254
  this.isValidArqc = isValidArqc;
259
255
  }
@@ -280,9 +276,9 @@ class BalanceEntry {
280
276
  rollingBalance,
281
277
  }) {
282
278
  this.amount = amount;
283
- this.createdAt = data.dateToUTC(createdAt);
279
+ this.createdAt = identities.dateToUTC(createdAt);
284
280
  this.descriptor = descriptor;
285
- this.entryType = data.enumValueFromString(queries.EntryType, entryType);
281
+ this.entryType = identities.enumValueFromString(identities.EntryType, entryType);
286
282
  this.fundingInstrumentUri = fundingInstrumentUri;
287
283
  this.id = id;
288
284
  this.name = name;
@@ -307,9 +303,9 @@ class BalanceEntry {
307
303
  class Transaction {
308
304
  constructor({ amount, createdAt, descriptor, status, userId }) {
309
305
  this.amount = amount;
310
- this.createdAt = data.dateToUTC(createdAt);
306
+ this.createdAt = identities.dateToUTC(createdAt);
311
307
  this.descriptor = descriptor;
312
- this.status = data.enumValueFromString(queries.TransactionStatus, status);
308
+ this.status = identities.enumValueFromString(identities.TransactionStatus, status);
313
309
  this.userId = userId;
314
310
  }
315
311
  }
@@ -366,18 +362,18 @@ class Card {
366
362
  updatedAt,
367
363
  userId,
368
364
  }) {
369
- this.createdAt = data.dateToUTC(createdAt);
365
+ this.createdAt = identities.dateToUTC(createdAt);
370
366
  this.cvv2 = cvv2;
371
367
  this.expMonth = expMonth;
372
368
  this.expYear = expYear;
373
- this.fundingType = data.enumValueFromString(queries.CardFundingType, fundingType);
369
+ this.fundingType = identities.enumValueFromString(identities.CardFundingType, fundingType);
374
370
  this.id = id;
375
- this.issuer = data.enumValueFromString(queries.CardIssuer, issuer);
371
+ this.issuer = identities.enumValueFromString(identities.CardIssuer, issuer);
376
372
  this.number = number;
377
373
  this.pin = pin;
378
- this.status = data.enumValueFromString(queries.CardStatus, status);
379
- this.type = data.enumValueFromString(queries.CardType, type);
380
- this.updatedAt = data.dateToUTC(updatedAt);
374
+ this.status = identities.enumValueFromString(identities.CardStatus, status);
375
+ this.type = identities.enumValueFromString(identities.CardType, type);
376
+ this.updatedAt = identities.dateToUTC(updatedAt);
381
377
  this.userId = userId;
382
378
  }
383
379
 
@@ -411,7 +407,7 @@ class Card {
411
407
  class CardActivation {
412
408
  constructor({ cardUri, createdAt, id, ipAddress, success, userId }) {
413
409
  this.cardUri = cardUri;
414
- this.createdAt = data.dateToUTC(createdAt);
410
+ this.createdAt = identities.dateToUTC(createdAt);
415
411
  this.id = id;
416
412
  this.ipAddress = ipAddress;
417
413
  this.success = success;
@@ -452,14 +448,14 @@ class CardTransaction extends Transaction {
452
448
  status,
453
449
  userId,
454
450
  });
455
- this.cardErrorType = data.enumValueFromString(queries.CardErrorType, cardErrorType);
451
+ this.cardErrorType = identities.enumValueFromString(identities.CardErrorType, cardErrorType);
456
452
  this.cardLastFour = cardLastFour;
457
- this.cardType = data.enumValueFromString(queries.CardType, cardType);
453
+ this.cardType = identities.enumValueFromString(identities.CardType, cardType);
458
454
  this.cardUri = cardUri;
459
455
  this.metadata = metadata;
460
456
  this.network = network;
461
457
  this.relatedCardTransactionsUris = relatedCardTransactionsUris;
462
- this.type = data.enumValueFromString(queries.CardTransactionType, type);
458
+ this.type = identities.enumValueFromString(identities.CardTransactionType, type);
463
459
  }
464
460
 
465
461
  static fromObject = ({
@@ -503,10 +499,10 @@ class CardValidation {
503
499
  isValidPinBlock,
504
500
  userId,
505
501
  }) {
506
- this.cardStatus = data.enumValueFromString(queries.CardStatus, cardStatus);
507
- this.cardType = data.enumValueFromString(queries.CardType, cardType);
502
+ this.cardStatus = identities.enumValueFromString(identities.CardStatus, cardStatus);
503
+ this.cardType = identities.enumValueFromString(identities.CardType, cardType);
508
504
  this.cardUri = cardUri;
509
- this.createdAt = data.dateToUTC(createdAt);
505
+ this.createdAt = identities.dateToUTC(createdAt);
510
506
  this.isExpired = isExpired;
511
507
  this.isPinAttemptsExceeded = isPinAttemptsExceeded;
512
508
  this.isValidCvv = isValidCvv;
@@ -534,7 +530,7 @@ class CardValidation {
534
530
  });
535
531
 
536
532
  get isActive() {
537
- return this.cardStatus === queries.CardStatus.Active;
533
+ return this.cardStatus === identities.CardStatus.Active;
538
534
  }
539
535
  }
540
536
 
@@ -556,7 +552,7 @@ class Commission extends Transaction {
556
552
  userId,
557
553
  });
558
554
  this.relatedTransactionUri = relatedTransactionUri;
559
- this.type = data.enumValueFromString(queries.CommissionType, type);
555
+ this.type = identities.enumValueFromString(identities.CommissionType, type);
560
556
  }
561
557
 
562
558
  static fromObject = ({ amount, descriptor, status, type, ...obj }) =>
@@ -591,7 +587,7 @@ class Deposit extends Transaction {
591
587
  userId,
592
588
  });
593
589
  this.id = id;
594
- this.network = data.enumValueFromString(queries.DepositNetwork, network);
590
+ this.network = identities.enumValueFromString(identities.DepositNetwork, network);
595
591
  this.sourceUri = sourceUri;
596
592
  this.trackingKey = trackingKey;
597
593
  }
@@ -621,11 +617,11 @@ class LoginToken {
621
617
  class Wallet {
622
618
  constructor({ balance, createdAt, deactivatedAt, id, userId, updatedAt }) {
623
619
  this.balance = balance;
624
- this.createdAt = data.dateToUTC(createdAt);
625
- this.deactivatedAt = data.dateToUTC(deactivatedAt);
620
+ this.createdAt = identities.dateToUTC(createdAt);
621
+ this.deactivatedAt = identities.dateToUTC(deactivatedAt);
626
622
  this.id = id;
627
623
  this.userId = userId;
628
- this.updatedAt = data.dateToUTC(updatedAt);
624
+ this.updatedAt = identities.dateToUTC(updatedAt);
629
625
  }
630
626
  }
631
627
 
@@ -650,9 +646,9 @@ class Saving extends Wallet {
650
646
  userId,
651
647
  updatedAt,
652
648
  });
653
- this.category = data.enumValueFromString(queries.SavingCategory, category);
649
+ this.category = identities.enumValueFromString(identities.SavingCategory, category);
654
650
  this.goalAmount = goalAmount;
655
- this.goalDate = data.dateToUTC(goalDate);
651
+ this.goalDate = identities.dateToUTC(goalDate);
656
652
  this.name = name;
657
653
  }
658
654
 
@@ -674,7 +670,7 @@ class Saving extends Wallet {
674
670
  const categoriesFromString = (categoriesList) => {
675
671
  if (categoriesList == null) return [];
676
672
  return categoriesList.map((category) =>
677
- data.enumValueFromString(queries.ServiceProviderCategory, category),
673
+ identities.enumValueFromString(identities.ServiceProviderCategory, category),
678
674
  );
679
675
  };
680
676
 
@@ -697,7 +693,7 @@ class ServiceProvider {
697
693
 
698
694
  class Statement {
699
695
  constructor({ createdAt, id, month, year }) {
700
- this.createdAt = data.dateToUTC(createdAt);
696
+ this.createdAt = identities.dateToUTC(createdAt);
701
697
  this.id = id;
702
698
  this.month = month;
703
699
  this.year = year;
@@ -739,10 +735,10 @@ class Transfer extends Transaction {
739
735
  this.destinationUri = destinationUri;
740
736
  this.id = id;
741
737
  this.idempotencyKey = idempotencyKey;
742
- this.network = data.enumValueFromString(queries.TransferNetwork, network);
738
+ this.network = identities.enumValueFromString(identities.TransferNetwork, network);
743
739
  this.recipientName = recipientName;
744
740
  this.trackingKey = trackingKey;
745
- this.updatedAt = data.dateToUTC(updatedAt);
741
+ this.updatedAt = identities.dateToUTC(updatedAt);
746
742
  }
747
743
 
748
744
  static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
@@ -763,12 +759,23 @@ class Transfer extends Transaction {
763
759
  });
764
760
  }
765
761
 
762
+ class User {
763
+ constructor({ termsOfService }) {
764
+ this.termsOfService = identities.TOSAgreements.fromObject(termsOfService);
765
+ }
766
+
767
+ static fromObject = ({ ...obj }) =>
768
+ new User({
769
+ termsOfService: obj.terms_of_service,
770
+ });
771
+ }
772
+
766
773
  class UserCredential {
767
774
  constructor({ createdAt, id, isActive, updatedAt }) {
768
- this.createdAt = data.dateToUTC(createdAt);
775
+ this.createdAt = identities.dateToUTC(createdAt);
769
776
  this.id = id;
770
777
  this.isActive = isActive;
771
- this.updatedAt = data.dateToUTC(updatedAt);
778
+ this.updatedAt = identities.dateToUTC(updatedAt);
772
779
  }
773
780
 
774
781
  static fromObject = ({ id, ...obj }) =>
@@ -783,7 +790,7 @@ class UserCredential {
783
790
  class UserLogin {
784
791
  constructor({ id, lastLoginAt, success }) {
785
792
  this.id = id;
786
- this.lastLoginAt = data.dateToUTC(lastLoginAt);
793
+ this.lastLoginAt = identities.dateToUTC(lastLoginAt);
787
794
  this.success = success;
788
795
  }
789
796
 
@@ -814,8 +821,8 @@ class WalletTransaction extends Transaction {
814
821
  userId,
815
822
  });
816
823
  this.id = id;
817
- this.transactionType = data.enumValueFromString(
818
- queries.WalletTransactionType,
824
+ this.transactionType = identities.enumValueFromString(
825
+ identities.WalletTransactionType,
819
826
  transactionType,
820
827
  );
821
828
  this.walletUri = walletUri;
@@ -861,12 +868,12 @@ class WhatsAppTransfer extends Transaction {
861
868
  this.claimUrl = claimUrl;
862
869
  this.destinationUri = destinationUri;
863
870
  this.id = id;
864
- this.expiresAt = data.dateToUTC(expiresAt);
865
- this.network = data.enumValueFromString(queries.TransferNetwork, network);
871
+ this.expiresAt = identities.dateToUTC(expiresAt);
872
+ this.network = identities.enumValueFromString(identities.TransferNetwork, network);
866
873
  this.phoneNumber = phoneNumber;
867
874
  this.recipientName = recipientName;
868
875
  this.trackingKey = trackingKey;
869
- this.updatedAt = data.dateToUTC(updatedAt);
876
+ this.updatedAt = identities.dateToUTC(updatedAt);
870
877
  }
871
878
 
872
879
  static fromObject = ({ amount, descriptor, id, network, status, ...obj }) =>
@@ -918,6 +925,7 @@ const getModelFromPath = (path, obj) => {
918
925
  service_providers: () => ServiceProvider.fromObject(obj),
919
926
  statements: () => Statement.fromObject(obj),
920
927
  transfers: () => Transfer.fromObject(obj),
928
+ users: () => User.fromObject(obj),
921
929
  user_credentials: () => UserCredential.fromObject(obj),
922
930
  user_logins: () => UserLogin.fromObject(obj),
923
931
  wallet_transactions: () => WalletTransaction.fromObject(obj),
@@ -1343,12 +1351,12 @@ class StatementResource extends mix(Resource).with(Downlodable, Queryable) {
1343
1351
  }
1344
1352
 
1345
1353
  async pdf(id) {
1346
- const byteString = await this._download(id, queries.FileFormat.Pdf);
1354
+ const byteString = await this._download(id, identities.FileFormat.Pdf);
1347
1355
  return byteString;
1348
1356
  }
1349
1357
 
1350
1358
  async xml(id) {
1351
- const byteString = await this._download(id, queries.FileFormat.Xml);
1359
+ const byteString = await this._download(id, identities.FileFormat.Xml);
1352
1360
  return byteString;
1353
1361
  }
1354
1362
  }
@@ -1427,7 +1435,7 @@ class TransferResource extends mix(Resource).with(
1427
1435
  }
1428
1436
 
1429
1437
  static _genIdempotencyKey(accountNumber, amount) {
1430
- const [date] = data.dateToUTC(Date.now()).toISOString().split('T');
1438
+ const [date] = identities.dateToUTC(Date.now()).toISOString().split('T');
1431
1439
  return `${date}:${accountNumber}:${amount}`;
1432
1440
  }
1433
1441
  }
@@ -1479,6 +1487,18 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
1479
1487
  }
1480
1488
  }
1481
1489
 
1490
+ class UserResourse extends mix(Resource).with(Updateable) {
1491
+ constructor(client) {
1492
+ super('user', Object, client);
1493
+ }
1494
+
1495
+ async update({ termsOfService, userId = 'me' }) {
1496
+ const request = new walletTransactionRequest.UserUpdateRequest({ termsOfService });
1497
+ const user = await this._update(userId, request.toCleanObject());
1498
+ return user;
1499
+ }
1500
+ }
1501
+
1482
1502
  class WalletTransactionsResource extends mix(Resource).with(
1483
1503
  Creatable,
1484
1504
  Queryable,
@@ -1525,7 +1545,7 @@ class WhatsAppTransferResource extends mix(Resource).with(
1525
1545
  }
1526
1546
 
1527
1547
  class Cuenca {
1528
- constructor(apiKey, apiSecret, phase = queries.Phase.Sandbox) {
1548
+ constructor(apiKey, apiSecret, phase = identities.Phase.Sandbox) {
1529
1549
  this.client = new Client({ apiKey, apiSecret, phase });
1530
1550
  this.withClient(this.client);
1531
1551
  }
package/build/index.mjs CHANGED
@@ -2,9 +2,9 @@ import axios from 'axios';
2
2
  import Buffer from 'buffer';
3
3
  import { CuencaResponseException, CuencaException, NoResultFound, MultipleResultsFound, InvalidPassword } from './errors/index.mjs';
4
4
  import { Jwt } from './jwt/index.mjs';
5
- import { P as Phase, F as FileFormat, E as EntryType, T as TransactionStatus, C as CardIssuer, a as CardStatus, b as CardType, c as CardFundingType, d as CardErrorType, e as CardTransactionType, f as CommissionType, D as DepositNetwork, S as SavingCategory, g as ServiceProviderCategory, h as TransferNetwork, W as WalletTransactionType, A as AccountQuery, i as ApiKeyQuery, B as BalanceEntryQuery, j as BillPaymentQuery, k as CardsQuery, l as CardTransactionQuery, Q as QueryParams, m as DepositQuery, n as WalletQuery, o as StatementQuery, p as TransferQuery, q as WalletTransactionQuery } from './queries-c73144c4.mjs';
6
- import { d as dateToUTC, e as enumValueFromString } from './data-d5bcb7c8.mjs';
7
- import { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, W as WalletTransactionRequest } from './walletTransactionRequest-60d3cf69.mjs';
5
+ import { P as Phase, F as FileFormat, d as dateToUTC, e as enumValueFromString, E as EntryType, T as TransactionStatus, C as CardIssuer, a as CardStatus, b as CardType, c as CardFundingType, f as CardErrorType, g as CardTransactionType, h as CommissionType, D as DepositNetwork, S as SavingCategory, i as ServiceProviderCategory, j as TransferNetwork, k as TOSAgreements, W as WalletTransactionType } from './identities-7fc7251d.mjs';
6
+ import { A as AccountQuery, a as ApiKeyQuery, B as BalanceEntryQuery, b as BillPaymentQuery, C as CardsQuery, c as CardTransactionQuery, Q as QueryParams, D as DepositQuery, W as WalletQuery, S as StatementQuery, T as TransferQuery, d as WalletTransactionQuery } from './queries-59c893b6.mjs';
7
+ import { A as ApiKeyUpdateRequest, a as ArpcRequest, C as CardActivationRequest, b as CardRequest, c as CardUpdateRequest, d as CardValidationRequest, S as SavingRequest, T as TransferRequest, U as UserCredentialRequest, e as UserCredentialUpdateRequest, f as UserLoginRequest, g as UserUpdateRequest, W as WalletTransactionRequest } from './walletTransactionRequest-7334f8c5.mjs';
8
8
 
9
9
  /* global window */
10
10
 
@@ -17,7 +17,7 @@ const isNode =
17
17
 
18
18
  const runtimeEnv = { isBrowser, isNode };
19
19
 
20
- const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.21";const description="Cuenca client for JS";const main="./build/index.cjs";const module="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports={".":{"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,browser:browser,files:files,exports:exports,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
20
+ const name="@cuenca-mx/cuenca-js";const version="0.0.1-dev.22";const description="Cuenca client for JS";const main="./build/index.cjs";const module="./build/index.mjs";const browser="./build/umd/cuenca.umd.js";const files=["build/**/*"];const exports={".":{"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,browser:browser,files:files,exports:exports,packageManager:packageManager,type:type,repository:repository,keywords:keywords,license:license,bugs:bugs,homepage:homepage,scripts:scripts,devDependencies:devDependencies,dependencies:dependencies};
21
21
 
22
22
  class Client {
23
23
  constructor({ apiKey, apiSecret, phase = Phase.Sandbox } = {}) {
@@ -86,7 +86,7 @@ class Client {
86
86
  };
87
87
  }
88
88
 
89
- async configure({ apiKey, apiSecret, loginToken, phase, sessionId,useJwt = false }) {
89
+ async configure({ apiKey, apiSecret, loginToken, phase, useJwt = false }) {
90
90
  this.basicAuth = {
91
91
  apiKey: apiKey || this.basicAuth.apiKey,
92
92
  apiSecret: apiSecret || this.basicAuth.apiSecret,
@@ -99,10 +99,6 @@ class Client {
99
99
  if (loginToken) {
100
100
  this.addHeadersToRequest({ 'X-Cuenca-LoginToken': loginToken });
101
101
  }
102
-
103
- if (sessionId) {
104
- this.addHeadersToRequest({ 'X-Cuenca-SessionId': sessionId });
105
- }
106
102
  }
107
103
 
108
104
  async get({ endpoint, format, params }) {
@@ -754,6 +750,17 @@ class Transfer extends Transaction {
754
750
  });
755
751
  }
756
752
 
753
+ class User {
754
+ constructor({ termsOfService }) {
755
+ this.termsOfService = TOSAgreements.fromObject(termsOfService);
756
+ }
757
+
758
+ static fromObject = ({ ...obj }) =>
759
+ new User({
760
+ termsOfService: obj.terms_of_service,
761
+ });
762
+ }
763
+
757
764
  class UserCredential {
758
765
  constructor({ createdAt, id, isActive, updatedAt }) {
759
766
  this.createdAt = dateToUTC(createdAt);
@@ -909,6 +916,7 @@ const getModelFromPath = (path, obj) => {
909
916
  service_providers: () => ServiceProvider.fromObject(obj),
910
917
  statements: () => Statement.fromObject(obj),
911
918
  transfers: () => Transfer.fromObject(obj),
919
+ users: () => User.fromObject(obj),
912
920
  user_credentials: () => UserCredential.fromObject(obj),
913
921
  user_logins: () => UserLogin.fromObject(obj),
914
922
  wallet_transactions: () => WalletTransaction.fromObject(obj),
@@ -1470,6 +1478,18 @@ class UserLoginResource extends mix(Resource).with(Creatable, Deactivable) {
1470
1478
  }
1471
1479
  }
1472
1480
 
1481
+ class UserResourse extends mix(Resource).with(Updateable) {
1482
+ constructor(client) {
1483
+ super('user', Object, client);
1484
+ }
1485
+
1486
+ async update({ termsOfService, userId = 'me' }) {
1487
+ const request = new UserUpdateRequest({ termsOfService });
1488
+ const user = await this._update(userId, request.toCleanObject());
1489
+ return user;
1490
+ }
1491
+ }
1492
+
1473
1493
  class WalletTransactionsResource extends mix(Resource).with(
1474
1494
  Creatable,
1475
1495
  Queryable,