@barchart/portfolio-client-js 10.0.1 → 10.2.0

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/lib/data/.meta.js CHANGED
@@ -298,6 +298,17 @@ const InstrumentType = require('@barchart/portfolio-api-common/lib/data/Instrume
298
298
  * @property {String[]} positions - Array of position identifiers for which are currently being calculated. An empty result indicates all position valuations are up-to-date.
299
299
  */
300
300
 
301
+ /**
302
+ * The result of recalculating aggregate values in a requested currency for the authorized user.
303
+ *
304
+ * @typedef UpdateValuesCurrencyResult
305
+ * @type {Object}
306
+ * @memberOf Schema
307
+ * @property {Boolean} success - Indicates the aggregate values were successfully recalculated.
308
+ * @property {String} userId - The identifier of the authorized user whose values were recalculated.
309
+ * @property {String} currency - The currency code used for the recalculation.
310
+ */
311
+
301
312
  /**
302
313
  * Instructions for connecting to a brokerage via SnapTrade.
303
314
  *
@@ -330,6 +330,23 @@ module.exports = (() => {
330
330
  .withErrorInterceptor(errorInterceptor)
331
331
  .endpoint;
332
332
 
333
+ this._updateValuesCurrencyEndpoint = EndpointBuilder.for('update-values-currency', 'update values currency')
334
+ .withVerb(VerbType.PUT)
335
+ .withProtocol(protocolType)
336
+ .withHost(host)
337
+ .withPort(port)
338
+ .withPathBuilder((pb) => {
339
+ pb.withLiteralParameter('version', REST_API_VERSION)
340
+ .withLiteralParameter('values', 'values')
341
+ .withLiteralParameter('currency', 'currency');
342
+ })
343
+ .withBody('currency')
344
+ .withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
345
+ .withRequestInterceptor(requestInterceptor)
346
+ .withResponseInterceptor(responseInterceptorForDeserialization)
347
+ .withErrorInterceptor(errorInterceptor)
348
+ .endpoint;
349
+
333
350
  this._readTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions')
334
351
  .withVerb(VerbType.GET)
335
352
  .withProtocol(protocolType)
@@ -1055,6 +1072,22 @@ module.exports = (() => {
1055
1072
  return Gateway.invoke(this._queryPositionValuationsEndpoint, { symbol });
1056
1073
  }
1057
1074
 
1075
+ /**
1076
+ * Recalculates aggregate values for the authorized user in the requested currency.
1077
+ *
1078
+ * @public
1079
+ * @async
1080
+ * @param {String} currency - The target currency code (e.g. `USD`).
1081
+ * @returns {Promise<Schema.UpdateValuesCurrencyResult>}
1082
+ */
1083
+ async updateValuesCurrency(currency) {
1084
+ checkStart.call(this);
1085
+
1086
+ assert.argumentIsRequired(currency, 'currency', String);
1087
+
1088
+ return Gateway.invoke(this._updateValuesCurrencyEndpoint, { currency });
1089
+ }
1090
+
1058
1091
  /**
1059
1092
  * Creates a new transaction.
1060
1093
  *
@@ -1412,13 +1445,16 @@ module.exports = (() => {
1412
1445
  * @param {String} connection - The SnapTrade identifier for the brokerage connection.
1413
1446
  * @param {String} account - The SnapTrade identifier for the brokerage account.
1414
1447
  * @param {SnapTradeLinkStatusCallback} callback
1448
+ * @param {Number=} interval - The polling interval, in milliseconds. Default is 2500 ms.
1415
1449
  * @returns {Disposable}
1416
1450
  */
1417
- subscribeSnapTradeAccountLink(connection, account, callback) {
1451
+ subscribeSnapTradeAccountLink(connection, account, callback, interval = 2500) {
1418
1452
  checkStart.call(this);
1419
1453
 
1420
1454
  assert.argumentIsRequired(connection, 'connection', String);
1421
1455
  assert.argumentIsRequired(account, 'account', String);
1456
+ assert.argumentIsRequired(callback, 'callback', Function);
1457
+ assert.argumentIsOptional(interval, 'interval', Number);
1422
1458
 
1423
1459
  let disposable;
1424
1460
 
@@ -1436,7 +1472,7 @@ module.exports = (() => {
1436
1472
  }
1437
1473
  };
1438
1474
 
1439
- const token = setInterval(poll, 2500);
1475
+ const token = setInterval(poll, interval);
1440
1476
 
1441
1477
  disposable = Disposable.fromAction(() => {
1442
1478
  clearInterval(token);
@@ -1917,4 +1953,4 @@ module.exports = (() => {
1917
1953
  */
1918
1954
 
1919
1955
  return PortfolioGateway;
1920
- })();
1956
+ })();
package/lib/index.js CHANGED
@@ -7,6 +7,6 @@ module.exports = (() => {
7
7
  return {
8
8
  JwtProvider: JwtProvider,
9
9
  PortfolioGateway: PortfolioGateway,
10
- version: '10.0.1'
10
+ version: '10.2.0'
11
11
  };
12
12
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-client-js",
3
- "version": "10.0.1",
3
+ "version": "10.2.0",
4
4
  "description": "JavaScript SDK for Barchart's Portfolio Service",
5
5
  "homepage": "https://docs.barchart.com/portfolio/#/",
6
6
  "author": {