@barchart/portfolio-client-js 1.1.24 → 1.1.27
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.html +1 -1
- package/example/example.js +6 -13
- package/lib/gateway/PortfolioGateway.js +9 -25
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/example/example.html
CHANGED
package/example/example.js
CHANGED
|
@@ -179,11 +179,11 @@ module.exports = function () {
|
|
|
179
179
|
|
|
180
180
|
_this._createPortfolioEndpoint = EndpointBuilder.for('create-portfolio', 'create portfolio').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
181
181
|
pb.withLiteralParameter('portfolios', 'portfolios');
|
|
182
|
-
}).withBody('portfolio').withRequestInterceptor(RequestInterceptor.fromDelegate(createPortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
182
|
+
}).withBody('portfolio').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(RequestInterceptor.fromDelegate(createPortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
183
183
|
|
|
184
184
|
_this._updatePortfolioEndpoint = EndpointBuilder.for('update-portfolio', 'update portfolio').withVerb(VerbType.PUT).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
185
185
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
|
|
186
|
-
}).withBody('portfolio').withRequestInterceptor(RequestInterceptor.fromDelegate(updatePortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
186
|
+
}).withBody('portfolio').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(RequestInterceptor.fromDelegate(updatePortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
187
187
|
|
|
188
188
|
_this._deletePortfolioEndpoint = EndpointBuilder.for('delete-portfolio', 'delete portfolios').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
189
189
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
|
|
@@ -201,10 +201,6 @@ module.exports = function () {
|
|
|
201
201
|
qb.withVariableParameter('frame', 'frame', 'frame', true).withVariableParameter('periods', 'periods', 'periods', true);
|
|
202
202
|
}).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionSummaryDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
203
203
|
|
|
204
|
-
_this._deletePortfoliosEndpoint = EndpointBuilder.for('delete-portfolio', 'delete portfolios').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
205
|
-
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
|
|
206
|
-
}).withRequestInterceptor(requestInterceptorToUse).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
|
|
207
|
-
|
|
208
204
|
_this._readTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
|
|
209
205
|
pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
|
|
210
206
|
}).withQueryBuilder(function (qb) {
|
|
@@ -474,8 +470,7 @@ module.exports = function () {
|
|
|
474
470
|
|
|
475
471
|
code = transaction.type;
|
|
476
472
|
} else {
|
|
477
|
-
assert.argumentIsRequired(transaction.type, 'transaction.type',
|
|
478
|
-
assert.argumentIsRequired(transaction.type.code, 'transaction.type.code', String);
|
|
473
|
+
assert.argumentIsRequired(transaction.type, 'transaction.type', TransactionType, 'TransactionType');
|
|
479
474
|
|
|
480
475
|
code = transaction.type.code;
|
|
481
476
|
}
|
|
@@ -636,9 +631,7 @@ module.exports = function () {
|
|
|
636
631
|
};
|
|
637
632
|
|
|
638
633
|
var updatePortfolioRequestInterceptor = function updatePortfolioRequestInterceptor(request) {
|
|
639
|
-
return FailureReason.validateSchema(PortfolioSchema.UPDATE, request.data
|
|
640
|
-
request.data = request.data.portfolioData;
|
|
641
|
-
|
|
634
|
+
return FailureReason.validateSchema(PortfolioSchema.UPDATE, request.data).then(function () {
|
|
642
635
|
return Promise.resolve(request);
|
|
643
636
|
}).catch(function (e) {
|
|
644
637
|
console.error('Error serializing data to create a portfolio', e);
|
|
@@ -651,7 +644,7 @@ module.exports = function () {
|
|
|
651
644
|
try {
|
|
652
645
|
return JSON.parse(response.data, PortfolioSchema.CLIENT.schema.getReviver());
|
|
653
646
|
} catch (e) {
|
|
654
|
-
console.log('Error deserializing
|
|
647
|
+
console.log('Error deserializing portfolios', e);
|
|
655
648
|
}
|
|
656
649
|
});
|
|
657
650
|
|
|
@@ -1011,7 +1004,7 @@ module.exports = function () {
|
|
|
1011
1004
|
return {
|
|
1012
1005
|
JwtGateway: JwtGateway,
|
|
1013
1006
|
PortfolioGateway: PortfolioGateway,
|
|
1014
|
-
version: '1.1.
|
|
1007
|
+
version: '1.1.27'
|
|
1015
1008
|
};
|
|
1016
1009
|
}();
|
|
1017
1010
|
|
|
@@ -77,6 +77,7 @@ module.exports = (() => {
|
|
|
77
77
|
pb.withLiteralParameter('portfolios', 'portfolios');
|
|
78
78
|
})
|
|
79
79
|
.withBody('portfolio')
|
|
80
|
+
.withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
|
|
80
81
|
.withRequestInterceptor(RequestInterceptor.fromDelegate(createPortfolioRequestInterceptor))
|
|
81
82
|
.withRequestInterceptor(requestInterceptorToUse)
|
|
82
83
|
.withResponseInterceptor(responseInterceptorForPortfolioDeserialization)
|
|
@@ -93,6 +94,7 @@ module.exports = (() => {
|
|
|
93
94
|
.withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
|
|
94
95
|
})
|
|
95
96
|
.withBody('portfolio')
|
|
97
|
+
.withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
|
|
96
98
|
.withRequestInterceptor(RequestInterceptor.fromDelegate(updatePortfolioRequestInterceptor))
|
|
97
99
|
.withRequestInterceptor(requestInterceptorToUse)
|
|
98
100
|
.withResponseInterceptor(responseInterceptorForPortfolioDeserialization)
|
|
@@ -153,21 +155,6 @@ module.exports = (() => {
|
|
|
153
155
|
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
154
156
|
.endpoint;
|
|
155
157
|
|
|
156
|
-
this._deletePortfoliosEndpoint = EndpointBuilder.for('delete-portfolio', 'delete portfolios')
|
|
157
|
-
.withVerb(VerbType.DELETE)
|
|
158
|
-
.withProtocol(protocolType)
|
|
159
|
-
.withHost(host)
|
|
160
|
-
.withPort(port)
|
|
161
|
-
.withPathBuilder((pb) => {
|
|
162
|
-
pb.withLiteralParameter('portfolios', 'portfolios')
|
|
163
|
-
.withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
|
|
164
|
-
.withLiteralParameter('positions', 'positions')
|
|
165
|
-
.withVariableParameter('position', 'position', 'position', false);
|
|
166
|
-
})
|
|
167
|
-
.withRequestInterceptor(requestInterceptorToUse)
|
|
168
|
-
.withErrorInterceptor(ErrorInterceptor.GENERAL)
|
|
169
|
-
.endpoint;
|
|
170
|
-
|
|
171
158
|
this._readTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions')
|
|
172
159
|
.withVerb(VerbType.GET)
|
|
173
160
|
.withProtocol(protocolType)
|
|
@@ -456,8 +443,7 @@ module.exports = (() => {
|
|
|
456
443
|
|
|
457
444
|
code = transaction.type;
|
|
458
445
|
} else {
|
|
459
|
-
assert.argumentIsRequired(transaction.type, 'transaction.type',
|
|
460
|
-
assert.argumentIsRequired(transaction.type.code, 'transaction.type.code', String);
|
|
446
|
+
assert.argumentIsRequired(transaction.type, 'transaction.type', TransactionType, 'TransactionType');
|
|
461
447
|
|
|
462
448
|
code = transaction.type.code;
|
|
463
449
|
}
|
|
@@ -588,8 +574,9 @@ module.exports = (() => {
|
|
|
588
574
|
|
|
589
575
|
const createPortfolioRequestInterceptor = (request) => {
|
|
590
576
|
return FailureReason.validateSchema(PortfolioSchema.CREATE, request.data)
|
|
591
|
-
.then(() =>
|
|
592
|
-
|
|
577
|
+
.then(() => {
|
|
578
|
+
return Promise.resolve(request)
|
|
579
|
+
}).catch(e => {
|
|
593
580
|
console.error('Error serializing data to create a portfolio', e);
|
|
594
581
|
|
|
595
582
|
return Promise.reject();
|
|
@@ -597,13 +584,10 @@ module.exports = (() => {
|
|
|
597
584
|
};
|
|
598
585
|
|
|
599
586
|
const updatePortfolioRequestInterceptor = (request) => {
|
|
600
|
-
return FailureReason.validateSchema(PortfolioSchema.UPDATE, request.data
|
|
587
|
+
return FailureReason.validateSchema(PortfolioSchema.UPDATE, request.data)
|
|
601
588
|
.then(() => {
|
|
602
|
-
request.data = request.data.portfolioData;
|
|
603
|
-
|
|
604
589
|
return Promise.resolve(request);
|
|
605
|
-
})
|
|
606
|
-
.catch(e => {
|
|
590
|
+
}).catch(e => {
|
|
607
591
|
console.error('Error serializing data to create a portfolio', e);
|
|
608
592
|
|
|
609
593
|
return Promise.reject();
|
|
@@ -614,7 +598,7 @@ module.exports = (() => {
|
|
|
614
598
|
try {
|
|
615
599
|
return JSON.parse(response.data, PortfolioSchema.CLIENT.schema.getReviver());
|
|
616
600
|
} catch (e) {
|
|
617
|
-
console.log('Error deserializing
|
|
601
|
+
console.log('Error deserializing portfolios', e);
|
|
618
602
|
}
|
|
619
603
|
});
|
|
620
604
|
|
package/lib/index.js
CHANGED