@barchart/portfolio-client-js 1.2.3 → 1.2.6

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.
@@ -215,7 +215,7 @@ module.exports = function () {
215
215
 
216
216
  _this._updatePositionEndpoint = EndpointBuilder.for('update-position', 'update position').withVerb(VerbType.PUT).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
217
217
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
218
- }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(RequestInterceptor.fromDelegate(updatePositionRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
218
+ }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.fromDelegate(updatePositionRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
219
219
 
220
220
  _this._deletePositionEndpoint = EndpointBuilder.for('delete-position', 'delete position').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
221
221
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
@@ -247,6 +247,14 @@ module.exports = function () {
247
247
  });
248
248
  }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
249
249
 
250
+ _this._editTransactionEndpoint = EndpointBuilder.for('edit-transaction', 'edit transaction').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
251
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
252
+ }).withQueryBuilder(function (qb) {
253
+ qb.withVariableParameter('type', 'type', 'type', false, function (i) {
254
+ return i.code;
255
+ });
256
+ }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
257
+
250
258
  _this._deleteTransactionEndpoint = EndpointBuilder.for('delete-transaction', 'delete transaction').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
251
259
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
252
260
  }).withQueryBuilder(function (qb) {
@@ -575,13 +583,52 @@ module.exports = function () {
575
583
  });
576
584
  }
577
585
 
586
+ /**
587
+ * Edits a transaction.
588
+ *
589
+ * @public
590
+ * @param {Object} transaction
591
+ * @returns {Promise.<TransactionMutateResult>}
592
+ */
593
+
594
+ }, {
595
+ key: 'editTransaction',
596
+ value: function editTransaction(transaction) {
597
+ var _this12 = this;
598
+
599
+ return Promise.resolve().then(function () {
600
+ checkStart.call(_this12);
601
+
602
+ assert.argumentIsRequired(transaction, 'transaction', Object);
603
+ assert.argumentIsRequired(transaction.portfolio, 'transaction.portfolio', String);
604
+ assert.argumentIsRequired(transaction.position, 'transaction.position', String);
605
+ assert.argumentIsRequired(transaction.sequence, 'transaction.sequence', Number);
606
+
607
+ var code = void 0;
608
+
609
+ if (is.string(transaction.type)) {
610
+ assert.argumentIsRequired(transaction.type.code, 'transaction.type.code', String);
611
+
612
+ code = transaction.type;
613
+ } else {
614
+ assert.argumentIsRequired(transaction.type, 'transaction.type', TransactionType, 'TransactionType');
615
+
616
+ code = transaction.type.code;
617
+ }
618
+
619
+ var schema = TransactionSchema.forCreate(Enum.fromCode(TransactionType, code));
620
+
621
+ return Gateway.invoke(_this12._editTransactionEndpoint, schema.schema.format(transaction));
622
+ });
623
+ }
624
+
578
625
  /**
579
626
  * Deletes a transaction.
580
627
  *
581
628
  * @public
582
629
  * @param {String} portfolio
583
630
  * @param {String} position
584
- * @param {Number} transaction
631
+ * @param {Number} sequence
585
632
  * @param {Boolean=} force
586
633
  * @param {Boolean=} echo
587
634
  * @returns {Promise.<TransactionMutateResult>}
@@ -590,10 +637,10 @@ module.exports = function () {
590
637
  }, {
591
638
  key: 'deleteTransaction',
592
639
  value: function deleteTransaction(portfolio, position, sequence, force, echo) {
593
- var _this12 = this;
640
+ var _this13 = this;
594
641
 
595
642
  return Promise.resolve().then(function () {
596
- checkStart.call(_this12);
643
+ checkStart.call(_this13);
597
644
 
598
645
  assert.argumentIsRequired(portfolio, 'portfolio', String);
599
646
  assert.argumentIsRequired(position, 'position', String);
@@ -601,7 +648,7 @@ module.exports = function () {
601
648
  assert.argumentIsOptional(force, 'force', Boolean);
602
649
  assert.argumentIsOptional(echo, 'echo', Boolean);
603
650
 
604
- return Gateway.invoke(_this12._deleteTransactionEndpoint, { portfolio: portfolio, position: position, sequence: sequence, force: is.boolean(force) && force, echo: is.boolean(echo) && echo });
651
+ return Gateway.invoke(_this13._deleteTransactionEndpoint, { portfolio: portfolio, position: position, sequence: sequence, force: is.boolean(force) && force, echo: is.boolean(echo) && echo });
605
652
  });
606
653
  }
607
654
 
@@ -617,29 +664,29 @@ module.exports = function () {
617
664
  }, {
618
665
  key: 'readTransactions',
619
666
  value: function readTransactions(portfolio, position) {
620
- var _this13 = this;
667
+ var _this14 = this;
621
668
 
622
669
  return Promise.resolve().then(function () {
623
- checkStart.call(_this13);
670
+ checkStart.call(_this14);
624
671
 
625
672
  assert.argumentIsRequired(portfolio, 'portfolio', String);
626
673
  assert.argumentIsOptional(position, 'position', String);
627
674
 
628
- return Gateway.invoke(_this13._readTransactionsEndpoint, { portfolio: portfolio, position: position || '*' });
675
+ return Gateway.invoke(_this14._readTransactionsEndpoint, { portfolio: portfolio, position: position || '*' });
629
676
  });
630
677
  }
631
678
  }, {
632
679
  key: 'readTransactionsFormatted',
633
680
  value: function readTransactionsFormatted(portfolio, position) {
634
- var _this14 = this;
681
+ var _this15 = this;
635
682
 
636
683
  return Promise.resolve().then(function () {
637
- checkStart.call(_this14);
684
+ checkStart.call(_this15);
638
685
 
639
686
  assert.argumentIsRequired(portfolio, 'portfolio', String);
640
687
  assert.argumentIsOptional(position, 'position', String);
641
688
 
642
- return Gateway.invoke(_this14._readTransactionsReportEndpoint, { portfolio: portfolio, position: position || '*' });
689
+ return Gateway.invoke(_this15._readTransactionsReportEndpoint, { portfolio: portfolio, position: position || '*' });
643
690
  });
644
691
  }
645
692
 
@@ -1210,7 +1257,7 @@ module.exports = function () {
1210
1257
  return {
1211
1258
  JwtGateway: JwtGateway,
1212
1259
  PortfolioGateway: PortfolioGateway,
1213
- version: '1.2.3'
1260
+ version: '1.2.6'
1214
1261
  };
1215
1262
  }();
1216
1263
 
@@ -150,10 +150,9 @@ module.exports = (() => {
150
150
  .withVariableParameter('position', 'position', 'position', false);
151
151
  })
152
152
  .withBody('portfolio')
153
- .withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
154
153
  .withRequestInterceptor(RequestInterceptor.fromDelegate(updatePositionRequestInterceptor))
155
154
  .withRequestInterceptor(requestInterceptorToUse)
156
- .withResponseInterceptor(responseInterceptorForPositionDeserialization)
155
+ .withResponseInterceptor(responseInterceptorForPositionMutateDeserialization)
157
156
  .withErrorInterceptor(ErrorInterceptor.GENERAL)
158
157
  .endpoint;
159
158
 
@@ -238,6 +237,28 @@ module.exports = (() => {
238
237
  .withErrorInterceptor(ErrorInterceptor.GENERAL)
239
238
  .endpoint;
240
239
 
240
+ this._editTransactionEndpoint = EndpointBuilder.for('edit-transaction', 'edit transaction')
241
+ .withVerb(VerbType.POST)
242
+ .withProtocol(protocolType)
243
+ .withHost(host)
244
+ .withPort(port)
245
+ .withPathBuilder((pb) => {
246
+ pb.withLiteralParameter('portfolios', 'portfolios')
247
+ .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
248
+ .withLiteralParameter('positions', 'positions')
249
+ .withVariableParameter('position', 'position', 'position', false)
250
+ .withLiteralParameter('transactions', 'transactions')
251
+ .withVariableParameter('sequence', 'sequence', 'sequence', false)
252
+ })
253
+ .withQueryBuilder((qb) => {
254
+ qb.withVariableParameter('type', 'type', 'type', false, i => i.code);
255
+ })
256
+ .withBody('transaction')
257
+ .withRequestInterceptor(requestInterceptorToUse)
258
+ .withResponseInterceptor(responseInterceptorForPositionMutateDeserialization)
259
+ .withErrorInterceptor(ErrorInterceptor.GENERAL)
260
+ .endpoint;
261
+
241
262
  this._deleteTransactionEndpoint = EndpointBuilder.for('delete-transaction', 'delete transaction')
242
263
  .withVerb(VerbType.DELETE)
243
264
  .withProtocol(protocolType)
@@ -557,13 +578,49 @@ module.exports = (() => {
557
578
  });
558
579
  }
559
580
 
581
+ /**
582
+ * Edits a transaction.
583
+ *
584
+ * @public
585
+ * @param {Object} transaction
586
+ * @returns {Promise.<TransactionMutateResult>}
587
+ */
588
+ editTransaction(transaction) {
589
+ return Promise.resolve()
590
+ .then(() => {
591
+ checkStart.call(this);
592
+
593
+ assert.argumentIsRequired(transaction, 'transaction', Object);
594
+ assert.argumentIsRequired(transaction.portfolio, 'transaction.portfolio', String);
595
+ assert.argumentIsRequired(transaction.position, 'transaction.position', String);
596
+ assert.argumentIsRequired(transaction.sequence, 'transaction.sequence', Number);
597
+
598
+ let code;
599
+
600
+ if (is.string(transaction.type)) {
601
+ assert.argumentIsRequired(transaction.type.code, 'transaction.type.code', String);
602
+
603
+ code = transaction.type;
604
+ } else {
605
+ assert.argumentIsRequired(transaction.type, 'transaction.type', TransactionType, 'TransactionType');
606
+
607
+ code = transaction.type.code;
608
+ }
609
+
610
+
611
+ const schema = TransactionSchema.forCreate(Enum.fromCode(TransactionType, code));
612
+
613
+ return Gateway.invoke(this._editTransactionEndpoint, schema.schema.format(transaction));
614
+ });
615
+ }
616
+
560
617
  /**
561
618
  * Deletes a transaction.
562
619
  *
563
620
  * @public
564
621
  * @param {String} portfolio
565
622
  * @param {String} position
566
- * @param {Number} transaction
623
+ * @param {Number} sequence
567
624
  * @param {Boolean=} force
568
625
  * @param {Boolean=} echo
569
626
  * @returns {Promise.<TransactionMutateResult>}
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.3'
10
+ version: '1.2.6'
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.3",
3
+ "version": "1.2.6",
4
4
  "description": "JavaScript library for interfacing with Barchart's Portfolio API",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",