@barchart/portfolio-client-js 1.2.28 → 1.2.31

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.
@@ -290,6 +290,14 @@ module.exports = function () {
290
290
  return x.format();
291
291
  }).withVariableParameter('page', 'page', 'page', true).withVariableParameter('sequence', 'sequence', 'sequence', true).withVariableParameter('count', 'count', 'count', true).withVariableParameter('descending', 'descending', 'descending', true);
292
292
  }).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(ResponseInterceptor.DATA).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
293
+
294
+ _this._downloadBrokerageReportEndpoint = EndpointBuilder.for('download-brokerage-report', 'download brokerage report').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
295
+ pb.withLiteralParameter('reports', 'reports').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('frames', 'frames').withVariableParameter('frame', 'frame', 'frame', false, function (x) {
296
+ return x.code;
297
+ }).withLiteralParameter('date', 'date').withVariableParameter('start', 'start', 'start', false, function (x) {
298
+ return x.format();
299
+ });
300
+ }).withRequestInterceptor(requestInterceptorToUse).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
293
301
  return _this;
294
302
  }
295
303
 
@@ -575,13 +583,13 @@ module.exports = function () {
575
583
  assert.argumentIsOptional(periods, 'periods', Number);
576
584
  assert.argumentIsOptional(start, 'start', Day);
577
585
 
578
- var query = {
586
+ var payload = {
579
587
  portfolio: portfolio || '*',
580
588
  position: position || '*'
581
589
  };
582
590
 
583
591
  if (frames) {
584
- query.frames = frames.map(function (frame) {
592
+ payload.frames = frames.map(function (frame) {
585
593
  if (is.string(frame)) {
586
594
  return Enum.fromCode(PositionSummaryFrame, frame);
587
595
  } else {
@@ -591,7 +599,7 @@ module.exports = function () {
591
599
  }
592
600
 
593
601
  if (periods) {
594
- query.periods = periods;
602
+ payload.periods = periods;
595
603
  }
596
604
 
597
605
  if (start) {
@@ -603,10 +611,10 @@ module.exports = function () {
603
611
  s = start;
604
612
  }
605
613
 
606
- query.start = s;
614
+ payload.start = s;
607
615
  }
608
616
 
609
- return Gateway.invoke(_this11._readPositionSummariesEndpoint, query);
617
+ return Gateway.invoke(_this11._readPositionSummariesEndpoint, payload);
610
618
  });
611
619
  }
612
620
 
@@ -626,12 +634,12 @@ module.exports = function () {
626
634
  return Promise.resolve().then(function () {
627
635
  assert.argumentIsRequired(portfolio, 'portfolio', String);
628
636
 
629
- var query = {};
637
+ var payload = {};
630
638
 
631
- query.portfolio = portfolio;
632
- query.frames = frames;
639
+ payload.portfolio = portfolio;
640
+ payload.frames = frames;
633
641
 
634
- return Gateway.invoke(_this12._readPositionSummaryDefinitionEndpoint, query);
642
+ return Gateway.invoke(_this12._readPositionSummaryDefinitionEndpoint, payload);
635
643
  });
636
644
  }
637
645
 
@@ -708,11 +716,11 @@ module.exports = function () {
708
716
  assert.argumentIsRequired(portfolio, 'portfolio', Object);
709
717
  assert.argumentIsArray(transactions, 'transactions', Object);
710
718
 
711
- var batchData = {};
719
+ var payload = {};
712
720
 
713
- batchData.portfolio = portfolio.portfolio;
714
- batchData.transactionTypes = [];
715
- batchData.transactionItems = [];
721
+ payload.portfolio = portfolio.portfolio;
722
+ payload.transactionTypes = [];
723
+ payload.transactionItems = [];
716
724
 
717
725
  transactions.forEach(function (transaction) {
718
726
  transaction.portfolio = portfolio.portfolio;
@@ -724,11 +732,11 @@ module.exports = function () {
724
732
  var code = getTransactionTypeCode(transaction);
725
733
  var schema = getTransactionSchema(transaction);
726
734
 
727
- batchData.transactionTypes.push(code);
728
- batchData.transactionItems.push(JSON.stringify(schema.schema.format(transaction)));
735
+ payload.transactionTypes.push(code);
736
+ payload.transactionItems.push(JSON.stringify(schema.schema.format(transaction)));
729
737
  });
730
738
 
731
- return Gateway.invoke(_this15._batchTransactionEndpoint, batchData);
739
+ return Gateway.invoke(_this15._batchTransactionEndpoint, payload);
732
740
  });
733
741
  }
734
742
 
@@ -875,6 +883,19 @@ module.exports = function () {
875
883
  return Gateway.invoke(_this19._readTransactionsReportEndpoint, payload);
876
884
  });
877
885
  }
886
+
887
+ /**
888
+ * Reads a single page of formatted transactions.
889
+ *
890
+ * @public
891
+ * @param {String} portfolio
892
+ * @param {String} position
893
+ * @param {Number=} sequence
894
+ * @param {Number=} count
895
+ * @param {Boolean=} descending
896
+ * @returns {Promise<Object[]>}
897
+ */
898
+
878
899
  }, {
879
900
  key: 'readTransactionsFormattedPage',
880
901
  value: function readTransactionsFormattedPage(portfolio, position, sequence, count, descending) {
@@ -910,6 +931,36 @@ module.exports = function () {
910
931
  });
911
932
  }
912
933
 
934
+ /**
935
+ * @public
936
+ * @param {String=} portfolio
937
+ * @param {PositionSummaryFrame} frame
938
+ * @param {Day} start
939
+ * @returns {Promise}
940
+ */
941
+
942
+ }, {
943
+ key: 'downloadBrokerageReport',
944
+ value: function downloadBrokerageReport(portfolio, frame, start) {
945
+ var _this21 = this;
946
+
947
+ return Promise.resolve().then(function () {
948
+ checkStart.call(_this21);
949
+
950
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
951
+ assert.argumentIsRequired(frame, 'frame', PositionSummaryFrame, 'PositionSummaryFrame');
952
+ assert.argumentIsRequired(start, 'start', Day, 'Day');
953
+
954
+ var payload = {};
955
+
956
+ payload.portfolio = portfolio;
957
+ payload.frame = frame;
958
+ payload.start = start;
959
+
960
+ return Gateway.invoke(_this21._downloadBrokerageReportEndpoint, payload);
961
+ });
962
+ }
963
+
913
964
  /**
914
965
  * Creates and starts a new {@link PortfolioGateway} for use in the development environment.
915
966
  *
@@ -1505,7 +1556,7 @@ module.exports = function () {
1505
1556
  return {
1506
1557
  JwtGateway: JwtGateway,
1507
1558
  PortfolioGateway: PortfolioGateway,
1508
- version: '1.2.28'
1559
+ version: '1.2.31'
1509
1560
  };
1510
1561
  }();
1511
1562
 
@@ -347,6 +347,24 @@ module.exports = (() => {
347
347
  .withResponseInterceptor(ResponseInterceptor.DATA)
348
348
  .withErrorInterceptor(ErrorInterceptor.GENERAL)
349
349
  .endpoint;
350
+
351
+ this._downloadBrokerageReportEndpoint = EndpointBuilder.for('download-brokerage-report', 'download brokerage report')
352
+ .withVerb(VerbType.GET)
353
+ .withProtocol(protocolType)
354
+ .withHost(host)
355
+ .withPort(port)
356
+ .withPathBuilder((pb) => {
357
+ pb.withLiteralParameter('reports', 'reports')
358
+ .withLiteralParameter('portfolios', 'portfolios')
359
+ .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
360
+ .withLiteralParameter('frames', 'frames')
361
+ .withVariableParameter('frame', 'frame', 'frame', false, x => x.code)
362
+ .withLiteralParameter('date', 'date')
363
+ .withVariableParameter('start', 'start', 'start', false, x => x.format());
364
+ })
365
+ .withRequestInterceptor(requestInterceptorToUse)
366
+ .withErrorInterceptor(ErrorInterceptor.GENERAL)
367
+ .endpoint;
350
368
  }
351
369
 
352
370
  /**
@@ -592,13 +610,13 @@ module.exports = (() => {
592
610
  assert.argumentIsOptional(periods, 'periods', Number);
593
611
  assert.argumentIsOptional(start, 'start', Day);
594
612
 
595
- const query = {
613
+ const payload = {
596
614
  portfolio: portfolio || '*',
597
615
  position: position || '*'
598
616
  };
599
617
 
600
618
  if (frames) {
601
- query.frames = frames.map((frame) => {
619
+ payload.frames = frames.map((frame) => {
602
620
  if (is.string(frame)) {
603
621
  return Enum.fromCode(PositionSummaryFrame, frame);
604
622
  } else {
@@ -608,7 +626,7 @@ module.exports = (() => {
608
626
  }
609
627
 
610
628
  if (periods) {
611
- query.periods = periods;
629
+ payload.periods = periods;
612
630
  }
613
631
 
614
632
  if (start) {
@@ -620,10 +638,10 @@ module.exports = (() => {
620
638
  s = start;
621
639
  }
622
640
 
623
- query.start = s;
641
+ payload.start = s;
624
642
  }
625
643
 
626
- return Gateway.invoke(this._readPositionSummariesEndpoint, query);
644
+ return Gateway.invoke(this._readPositionSummariesEndpoint, payload);
627
645
  });
628
646
  }
629
647
 
@@ -639,12 +657,12 @@ module.exports = (() => {
639
657
  .then(() => {
640
658
  assert.argumentIsRequired(portfolio, 'portfolio', String);
641
659
 
642
- const query = { };
660
+ const payload = { };
643
661
 
644
- query.portfolio = portfolio;
645
- query.frames = frames;
662
+ payload.portfolio = portfolio;
663
+ payload.frames = frames;
646
664
 
647
- return Gateway.invoke(this._readPositionSummaryDefinitionEndpoint, query);
665
+ return Gateway.invoke(this._readPositionSummaryDefinitionEndpoint, payload);
648
666
  });
649
667
  }
650
668
 
@@ -709,11 +727,11 @@ module.exports = (() => {
709
727
  assert.argumentIsRequired(portfolio, 'portfolio', Object);
710
728
  assert.argumentIsArray(transactions, 'transactions', Object);
711
729
 
712
- const batchData = { };
730
+ const payload = { };
713
731
 
714
- batchData.portfolio = portfolio.portfolio;
715
- batchData.transactionTypes = [ ];
716
- batchData.transactionItems = [ ];
732
+ payload.portfolio = portfolio.portfolio;
733
+ payload.transactionTypes = [ ];
734
+ payload.transactionItems = [ ];
717
735
 
718
736
  transactions.forEach((transaction) => {
719
737
  transaction.portfolio = portfolio.portfolio;
@@ -725,11 +743,11 @@ module.exports = (() => {
725
743
  const code = getTransactionTypeCode(transaction);
726
744
  const schema = getTransactionSchema(transaction);
727
745
 
728
- batchData.transactionTypes.push(code);
729
- batchData.transactionItems.push(JSON.stringify(schema.schema.format(transaction)));
746
+ payload.transactionTypes.push(code);
747
+ payload.transactionItems.push(JSON.stringify(schema.schema.format(transaction)));
730
748
  });
731
749
 
732
- return Gateway.invoke(this._batchTransactionEndpoint, batchData);
750
+ return Gateway.invoke(this._batchTransactionEndpoint, payload);
733
751
  });
734
752
  }
735
753
 
@@ -861,6 +879,17 @@ module.exports = (() => {
861
879
  });
862
880
  }
863
881
 
882
+ /**
883
+ * Reads a single page of formatted transactions.
884
+ *
885
+ * @public
886
+ * @param {String} portfolio
887
+ * @param {String} position
888
+ * @param {Number=} sequence
889
+ * @param {Number=} count
890
+ * @param {Boolean=} descending
891
+ * @returns {Promise<Object[]>}
892
+ */
864
893
  readTransactionsFormattedPage(portfolio, position, sequence, count, descending) {
865
894
  return Promise.resolve()
866
895
  .then(() => {
@@ -893,6 +922,32 @@ module.exports = (() => {
893
922
  });
894
923
  }
895
924
 
925
+ /**
926
+ * @public
927
+ * @param {String=} portfolio
928
+ * @param {PositionSummaryFrame} frame
929
+ * @param {Day} start
930
+ * @returns {Promise}
931
+ */
932
+ downloadBrokerageReport(portfolio, frame, start) {
933
+ return Promise.resolve()
934
+ .then(() => {
935
+ checkStart.call(this);
936
+
937
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
938
+ assert.argumentIsRequired(frame, 'frame', PositionSummaryFrame, 'PositionSummaryFrame');
939
+ assert.argumentIsRequired(start, 'start', Day, 'Day');
940
+
941
+ const payload = { };
942
+
943
+ payload.portfolio = portfolio;
944
+ payload.frame = frame;
945
+ payload.start = start;
946
+
947
+ return Gateway.invoke(this._downloadBrokerageReportEndpoint, payload);
948
+ });
949
+ }
950
+
896
951
  /**
897
952
  * Creates and starts a new {@link PortfolioGateway} for use in the development environment.
898
953
  *
package/lib/index.js CHANGED
@@ -7,6 +7,6 @@ module.exports = (() => {
7
7
  return {
8
8
  JwtGateway: JwtGateway,
9
9
  PortfolioGateway: PortfolioGateway,
10
- version: '1.2.28'
10
+ version: '1.2.31'
11
11
  };
12
12
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-client-js",
3
- "version": "1.2.28",
3
+ "version": "1.2.31",
4
4
  "description": "JavaScript library for interfacing with Barchart's Portfolio API",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",