@barchart/portfolio-client-js 1.2.4 → 1.2.5
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/example/example.js +57 -10
- package/lib/gateway/PortfolioGateway.js +58 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/example/example.js
CHANGED
|
@@ -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,6 +583,45 @@ 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', String);
|
|
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
|
*
|
|
@@ -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
|
|
640
|
+
var _this13 = this;
|
|
594
641
|
|
|
595
642
|
return Promise.resolve().then(function () {
|
|
596
|
-
checkStart.call(
|
|
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(
|
|
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
|
|
667
|
+
var _this14 = this;
|
|
621
668
|
|
|
622
669
|
return Promise.resolve().then(function () {
|
|
623
|
-
checkStart.call(
|
|
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(
|
|
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
|
|
681
|
+
var _this15 = this;
|
|
635
682
|
|
|
636
683
|
return Promise.resolve().then(function () {
|
|
637
|
-
checkStart.call(
|
|
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(
|
|
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.
|
|
1260
|
+
version: '1.2.5'
|
|
1214
1261
|
};
|
|
1215
1262
|
}();
|
|
1216
1263
|
|
|
@@ -237,6 +237,28 @@ module.exports = (() => {
|
|
|
237
237
|
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
238
238
|
.endpoint;
|
|
239
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
|
+
|
|
240
262
|
this._deleteTransactionEndpoint = EndpointBuilder.for('delete-transaction', 'delete transaction')
|
|
241
263
|
.withVerb(VerbType.DELETE)
|
|
242
264
|
.withProtocol(protocolType)
|
|
@@ -556,6 +578,42 @@ module.exports = (() => {
|
|
|
556
578
|
});
|
|
557
579
|
}
|
|
558
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', String);
|
|
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
|
+
|
|
559
617
|
/**
|
|
560
618
|
* Deletes a transaction.
|
|
561
619
|
*
|
package/lib/index.js
CHANGED