xts-interactive-api-ip 0.0.0-stage → 3.0.3

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.
@@ -0,0 +1,1006 @@
1
+ var config = require('./config/app/config.json'),
2
+ settings = require('./config/app/settings.json'),
3
+ request = require('./request'),
4
+ logger = require('./logger'),
5
+ CustomError = require('./customError');
6
+
7
+ module.exports = class XTSInteractive {
8
+ /**
9
+ * Constructs an XTSInteractive instance to enable data transfer via restful API's.
10
+ *
11
+ * @constructor
12
+ *
13
+ * @param {String} url
14
+ * url parameter is used to connect to the particular server.
15
+ *
16
+ * @param {String} localIP
17
+ * localIP parameter is used to bind the outgoing requests to a specific local IP address.
18
+ *
19
+ */
20
+ constructor(url, localIP) {
21
+ this.url =
22
+ url === undefined ? config.url + '/interactive' : url + '/interactive';
23
+ this.localIP = localIP;
24
+ this.responseTypes = { success: 'success', failure: 'failure' };
25
+ logger.init();
26
+ this.isLoggedIn = false;
27
+ }
28
+
29
+ /**
30
+ * set the token value by providing the token in the input
31
+ *
32
+ * @param {string} token
33
+ * token parameter will be generated after successful login and will be used in other private API's
34
+ *
35
+ */
36
+ set token(token) {
37
+ this._token = token;
38
+ }
39
+
40
+ /**
41
+ * Returns the token generated after successful logIn
42
+ *
43
+ *
44
+ * @return
45
+ * the value of token generated after successful logIn
46
+ */
47
+ get token() {
48
+ return this._token;
49
+ }
50
+
51
+ /**
52
+ * set the userID value by providing the userID in the input
53
+ *
54
+ * @param {string} userID
55
+ * userID for the particular user
56
+ */
57
+ set userID(userID) {
58
+ this._userID = userID;
59
+ }
60
+
61
+ /**
62
+ * Returns userID for the particular user
63
+ *
64
+ *
65
+ * @return
66
+ * the userID for the particular user
67
+ */
68
+ get userID() {
69
+ return this._userID;
70
+ }
71
+
72
+ /**
73
+ * set the source value by providing the source in the input
74
+ *
75
+ * @param {string} source
76
+ * source used by the particular user
77
+ */
78
+ set source(source) {
79
+ this._source = source;
80
+ }
81
+
82
+ /**
83
+ * Returns source used by the particular user
84
+ *
85
+ *
86
+ * @return
87
+ * the userID used by the particular user
88
+ */
89
+ get source() {
90
+ return this._source;
91
+ }
92
+
93
+ /**
94
+ * set the url value by providing the url in the input
95
+ *
96
+ * @param {string} url
97
+ * url parameter is used to connect to the particular server.
98
+ */
99
+ set url(url) {
100
+ this._url = url;
101
+ }
102
+
103
+ /**
104
+ * Returns url used to connect to the particular server.
105
+ *
106
+ *
107
+ * @return
108
+ * the url used to connect to the particular server.
109
+ */
110
+ get url() {
111
+ return this._url;
112
+ }
113
+
114
+ /**
115
+ * set the localIP value by providing the localIP in the input
116
+ *
117
+ * @param {string} localIP
118
+ * localIP parameter is used to bind the outgoing requests to a specific local IP address.
119
+ */
120
+ set localIP(localIP) {
121
+ this._localIP = localIP;
122
+ }
123
+
124
+ /**
125
+ * Returns localIP used to bind the outgoing requests.
126
+ *
127
+ *
128
+ * @return
129
+ * the localIP used to bind the outgoing requests to a specific local IP address.
130
+ */
131
+ get localIP() {
132
+ return this._localIP;
133
+ }
134
+
135
+ /**
136
+ * set the enums value obtained after successful LogIn.
137
+ *
138
+ * @param {Object} enums
139
+ * sets the enums value obtained after successful LogIn.
140
+ */
141
+ set enums(enums) {
142
+ this._enums = enums;
143
+ }
144
+
145
+ /**
146
+ * Returns enums value obtained after successful LogIn.
147
+ *
148
+ * @return
149
+ * enums value obtained after successful LogIn.
150
+ */
151
+ get enums() {
152
+ return this._enums;
153
+ }
154
+
155
+ /**
156
+ * LogIn API of the application provides functionality of logIn into the application
157
+ *
158
+ * @param {Object} reqObject request object.
159
+ *
160
+ * @param {string} reqObject.secretKey
161
+ * secret key that after generate application on dashboard
162
+ *
163
+ * @param {string} reqObject.appKey
164
+ * app key that after generate application on dashboard
165
+ *
166
+ * @param {string} reqObject.source
167
+ * source used by the particular user.
168
+ *
169
+ */
170
+ async logIn(reqObject) {
171
+ try {
172
+ var response = await request.processRequest(
173
+ 'POST',
174
+ this.url + settings.restApi.session,
175
+ {},
176
+ reqObject,
177
+ this.localIP
178
+ );
179
+ this.enums = response.result.enums;
180
+ this.clientCodes = response.result.clientCodes;
181
+ this.exchangeSegmentArray = response.result.exchangeSegmentArray;
182
+ this.token = response.result.token;
183
+ this.userID = response.result.userID;
184
+ this.isInvestorClient = response.result.isInvestorClient;
185
+ this.isOneTouchUser = response.result.isOneTouchUser;
186
+ this.isLoggedIn = true;
187
+
188
+ return response;
189
+ } catch (error) {
190
+ let customError = new CustomError(
191
+ error.message,
192
+ error.stack,
193
+ error.statusCode
194
+ );
195
+ return customError;
196
+ }
197
+ }
198
+
199
+ /**
200
+ * Logout API of the application provides functionality of logOut from the application
201
+ *
202
+ */
203
+ async logOut() {
204
+ try {
205
+ await this.checkLoggedIn();
206
+ let response = await request.processRequest(
207
+ 'DELETE',
208
+ this.url + settings.restApi.session,
209
+ { authorization: this.token },
210
+ null,
211
+ this.localIP
212
+ );
213
+ return response;
214
+ } catch (error) {
215
+ let customError = new CustomError(
216
+ error.message,
217
+ error.stack,
218
+ error.statusCode
219
+ );
220
+ return customError;
221
+ }
222
+ }
223
+
224
+ /**
225
+ * getProfile API of the application provides functionality of getting profile details from the application
226
+ *
227
+ */
228
+ async getProfile(reqObject) {
229
+ try {
230
+ await this.checkLoggedIn();
231
+ let response = null;
232
+ if (reqObject == null) {
233
+ response = await request.processRequest(
234
+ 'GET',
235
+ this.url + settings.restApi.profile,
236
+ { authorization: this.token },
237
+ null,
238
+ this.localIP
239
+ );
240
+ } else {
241
+ response = await request.processRequest(
242
+ 'GET',
243
+ this.url +
244
+ settings.restApi.profile +
245
+ '?clientID=' +
246
+ reqObject.clientID,
247
+ { authorization: this.token },
248
+ null,
249
+ this.localIP
250
+ );
251
+ }
252
+ return response;
253
+ } catch (error) {
254
+ let customError = new CustomError(
255
+ error.message,
256
+ error.stack,
257
+ error.statusCode
258
+ );
259
+ return customError;
260
+ }
261
+ }
262
+
263
+ /**
264
+ * getBalance API of the application provides functionality of getting balance details from the application
265
+ *
266
+ */
267
+ async getBalance(reqObject) {
268
+ try {
269
+ let response = null;
270
+ await this.checkLoggedIn();
271
+ if (reqObject == null)
272
+ response = await request.processRequest(
273
+ 'GET',
274
+ this.url + settings.restApi.balance,
275
+ { authorization: this.token },
276
+ null,
277
+ this.localIP
278
+ );
279
+ else
280
+ response = await request.processRequest(
281
+ 'GET',
282
+ this.url +
283
+ settings.restApi.balance +
284
+ '?clientID=' +
285
+ reqObject.clientID,
286
+ { authorization: this.token },
287
+ null,
288
+ this.localIP
289
+ );
290
+ return response;
291
+ } catch (error) {
292
+ let customError = new CustomError(
293
+ error.message,
294
+ error.stack,
295
+ error.statusCode
296
+ );
297
+ return customError;
298
+ }
299
+ }
300
+
301
+ /**
302
+ * getHoldings API of the application provides functionality of getting holding details from the application
303
+ *
304
+ */
305
+ async getHoldings(reqObject) {
306
+ try {
307
+ let response = null;
308
+ await this.checkLoggedIn();
309
+ if (reqObject == null)
310
+ response = await request.processRequest(
311
+ 'GET',
312
+ this.url + settings.restApi.holding,
313
+ { authorization: this.token },
314
+ null,
315
+ this.localIP
316
+ );
317
+ else
318
+ response = await request.processRequest(
319
+ 'GET',
320
+ this.url +
321
+ settings.restApi.holding +
322
+ '?clientID=' +
323
+ reqObject.clientID,
324
+ { authorization: this.token },
325
+ null,
326
+ this.localIP
327
+ );
328
+ return response;
329
+ } catch (error) {
330
+ let customError = new CustomError(
331
+ error.message,
332
+ error.stack,
333
+ error.statusCode
334
+ );
335
+ return customError;
336
+ }
337
+ }
338
+
339
+ /**
340
+ * getPositions API of the application provides functionality of getting postion details from the application
341
+ *
342
+ * @param {Object} reqObject request object.
343
+ *
344
+ * @param {string} reqObject.dayOrNet
345
+ * dayOrNet parameter for getting the day or Net positions respectively
346
+ */
347
+ async getPositions(reqObject) {
348
+ try {
349
+ await this.checkLoggedIn();
350
+ let response = await request.processRequest(
351
+ 'GET',
352
+ this.url +
353
+ settings.restApi.position +
354
+ '?dayOrNet=' +
355
+ reqObject.dayOrNet +
356
+ '&clientID=' +
357
+ reqObject.clientID,
358
+ { authorization: this.token },
359
+ null,
360
+ this.localIP
361
+ );
362
+ return response;
363
+ } catch (error) {
364
+ let customError = new CustomError(
365
+ error.message,
366
+ error.stack,
367
+ error.statusCode
368
+ );
369
+ return customError;
370
+ }
371
+ }
372
+
373
+ /**
374
+ * positionConversion API of the application provides functionality of converting position details in the application
375
+ *
376
+ * @param {Object} reqObject request object.
377
+ *
378
+ * @param {string} reqObject.appOrderID
379
+ * appOrderID of the particular order
380
+ *
381
+ * @param {string} reqObject.executionID
382
+ * executionID of the particular order
383
+ *
384
+ * @param {string} reqObject.oldProductType
385
+ * oldProductType of the particular order
386
+ *
387
+ * @param {string} reqObject.newProductType
388
+ * newProductType of the particular order
389
+ *
390
+ */
391
+ async positionConversion(reqObject) {
392
+ try {
393
+ await this.checkLoggedIn();
394
+ let response = await request.processRequest(
395
+ 'PUT',
396
+ this.url + settings.restApi.convert,
397
+ { authorization: this.token },
398
+ reqObject,
399
+ this.localIP
400
+ );
401
+ return response;
402
+ } catch (error) {
403
+ let customError = new CustomError(
404
+ error.message,
405
+ error.stack,
406
+ error.statusCode
407
+ );
408
+ return customError;
409
+ }
410
+ }
411
+
412
+ // {
413
+ // "exchangeSegment":"NSECM",
414
+ // "exchangeInstrumentID" :22,
415
+ // "productType":"NRML",
416
+ // "squreoffMode":"DayWise",
417
+ // "positionSquareOffQuantityType" : "ExactQty",
418
+ // "squareOffQtyValue":5
419
+ // }
420
+
421
+ /**
422
+ * squareOff API of the application provides functionality of squaringOff the order in the application
423
+ *
424
+ * @param {Object} reqObject request object.
425
+ *
426
+ * @param {string} reqObject.exchangeSegment
427
+ * exchangeSegment of the instrument used for placing the order
428
+ *
429
+ * @param {number} reqObject.exchangeInstrumentID
430
+ * exchangeInstrumentID of the instrument used for placing the order
431
+ *
432
+ * @param {string} reqObject.productType
433
+ * productType of the particular order
434
+ *
435
+ * @param {number} reqObject.squareoffMode
436
+ * squreoffMode used for the particular order.
437
+ *
438
+ * @param {string} reqObject.positionSquareOffQuantityType
439
+ * squreoffMode used for the particular order.
440
+ *
441
+ * @param {number} reqObject.squareOffQtyValue
442
+ * squreoffMode used for the particular order.
443
+ *
444
+ *
445
+ */
446
+ // async squareOff(reqObject) {
447
+ // try {
448
+ // await this.checkLoggedIn();
449
+ // let response = await request.processRequest(
450
+ // 'PUT',
451
+ // this.url + settings.restApi.squareoff,
452
+ // { authorization: this.token },
453
+ // reqObject
454
+ // );
455
+ // return response;
456
+ // } catch (error) {
457
+ // let customError = new CustomError(
458
+ // error.message,
459
+ // error.stack,
460
+ // error.statusCode
461
+ // );
462
+ // return customError;
463
+ // }
464
+ // }
465
+
466
+ // {
467
+ // "exchangeSegment":"NSECM",
468
+ // "exchangeInstrumentID":22,
469
+ // "productType":"MIS",
470
+ // "orderType":"LIMIT",
471
+ // "orderSide":"BUY",
472
+ // "timeInForce":"DAY",
473
+ // "disclosedQuantity":0,
474
+ // "orderQuantity":20,
475
+ // "limitPrice":1500.00,
476
+ // "stopPrice":1600.00,
477
+ // "orderUniqueIdentifier":"454845"
478
+ // }
479
+
480
+ /**
481
+ * placeOrder API of the application provides functionality of placing the order in the application
482
+ *
483
+ * @param {Object} reqObject request object.
484
+ *
485
+ * @param {string} reqObject.exchangeSegment
486
+ * exchangeSegment of the instrument used for placing the order
487
+ *
488
+ * @param {number} reqObject.exchangeInstrumentID
489
+ * exchangeInstrumentID of the instrument used for placing the order
490
+ *
491
+ * @param {string} reqObject.productType
492
+ * productType of the particular order
493
+ *
494
+ * @param {string} reqObject.orderType
495
+ * orderType of the particular order.
496
+ *
497
+ * @param {string} reqObject.orderSide
498
+ * orderSide of the particular order.
499
+ *
500
+ * @param {string} reqObject.timeInForce
501
+ * timeInForce of the particular order.
502
+ *
503
+ * @param {number} reqObject.disclosedQuantity
504
+ * disclosedQuantity of the particular order.
505
+ *
506
+ * @param {number} reqObject.orderQuantity
507
+ * orderQuantity of the particular order.
508
+ *
509
+ * @param {number} reqObject.limitPrice
510
+ * limitPrice of the particular order.
511
+ *
512
+ * @param {number} reqObject.stopPrice
513
+ * stopPrice of the particular order.
514
+ *
515
+ * @param {string} reqObject.orderUniqueIdentifier
516
+ * orderUniqueIdentifier of the particular order.
517
+ */
518
+ async placeOrder(reqObject) {
519
+ try {
520
+ await this.checkLoggedIn();
521
+ let response = await request.processRequest(
522
+ 'POST',
523
+ this.url + settings.restApi.orders,
524
+ { authorization: this.token },
525
+ reqObject,
526
+ this.localIP
527
+ );
528
+ return response;
529
+ } catch (error) {
530
+ let customError = new CustomError(
531
+ error.message,
532
+ error.stack,
533
+ error.statusCode
534
+ );
535
+ return customError;
536
+ }
537
+ }
538
+
539
+ // {
540
+ // "appOrderID" :1991237756,
541
+ // "modifiedProductType" :"NRML",
542
+ // "modifiedOrderType" :"LIMIT",
543
+ // "modifiedOrderQuantity" :100,
544
+ // "modifiedDisclosedQuantity":0,
545
+ // "modifiedLimitPrice" :300,
546
+ // "modifiedStopPrice":300,
547
+ // "modifiedTimeInForce":"DAY",
548
+ // "modifiedOrderExpiryDate":"Feb 18 2019 15:15:00",
549
+ // "orderUniqueIdentifier":"5656"
550
+ // }
551
+
552
+ /**
553
+ * modify order API of the application provides functionality of modifing the order in the application
554
+ *
555
+ * @param {Object} reqObject request object.
556
+ *
557
+ * @param {number} reqObject.appOrderID
558
+ * appOrderID of the particular order
559
+ *
560
+ * @param {string} reqObject.modifiedProductType
561
+ * modifiedProductType of the particular order
562
+ *
563
+ * @param {string} reqObject.modifiedOrderType
564
+ * modifiedOrderType of the particular order
565
+ *
566
+ * @param {number} reqObject.modifiedOrderQuantity
567
+ * modifiedOrderQuantity of the particular order.
568
+ *
569
+ * @param {number} reqObject.modifiedDisclosedQuantity
570
+ * modifiedDisclosedQuantity of the particular order.
571
+ *
572
+ * @param {number} reqObject.modifiedLimitPrice
573
+ * modifiedLimitPrice of the particular order.
574
+ *
575
+ * @param {number} reqObject.modifiedStopPrice
576
+ * modifiedStopPrice of the particular order.
577
+ *
578
+ * @param {string} reqObject.modifiedTimeInForce
579
+ * modifiedTimeInForce of the particular order.
580
+ *
581
+ * @param {string} reqObject.orderUniqueIdentifier
582
+ * orderUniqueIdentifier of the particular order.
583
+ */
584
+ async modifyOrder(reqObject) {
585
+ try {
586
+ await this.checkLoggedIn();
587
+ let response = await request.processRequest(
588
+ 'PUT',
589
+ this.url + settings.restApi.orders,
590
+ { authorization: this.token },
591
+ reqObject,
592
+ this.localIP
593
+ );
594
+ return response;
595
+ } catch (error) {
596
+ let customError = new CustomError(
597
+ error.message,
598
+ error.stack,
599
+ error.statusCode
600
+ );
601
+ return customError;
602
+ }
603
+ }
604
+
605
+ //?appOrderID=1828071433&orderUniqueIdentifier=155151
606
+ /**
607
+ * cancel order API of the application provides functionality of canceling the order in the application
608
+ *
609
+ * @param {Object} reqObject request object.
610
+ *
611
+ * @param {string} reqObject.appOrderID
612
+ * appOrderID of the particular order
613
+ *
614
+ * @param {string} reqObject.orderUniqueIdentifier
615
+ * orderUniqueIdentifier of the particular order.
616
+ */
617
+ async cancelOrder(reqObject) {
618
+ try {
619
+ await this.checkLoggedIn();
620
+ let response = await request.processRequest(
621
+ 'DELETE',
622
+ this.url +
623
+ settings.restApi.orders +
624
+ '?appOrderID=' +
625
+ reqObject.appOrderID +
626
+ '&orderUniqueIdentifier=' +
627
+ reqObject.orderUniqueIdentifier +
628
+ '&clientID=' +
629
+ reqObject.clientID,
630
+ { authorization: this.token },
631
+ null,
632
+ this.localIP
633
+ );
634
+ return response;
635
+ } catch (error) {
636
+ let customError = new CustomError(
637
+ error.message,
638
+ error.stack,
639
+ error.statusCode
640
+ );
641
+ return customError;
642
+ }
643
+ }
644
+
645
+ // {
646
+ // "exchangeSegment": "NSECM",
647
+ // "exchangeInstrumentID": 22,
648
+ // "orderSide": "BUY",
649
+ // "orderQuantity": 2,
650
+ // "disclosedQuantity": 2,
651
+ // "limitPrice": 2054,
652
+ // "stopPrice": 2054,
653
+ // "orderUniqueIdentifier":"454845"
654
+ // }
655
+
656
+ /**
657
+ * placeCoverOrder API of the application provides functionality of placing the cover order in the application
658
+ *
659
+ * @param {Object} reqObject request object.
660
+ *
661
+ * @param {string} reqObject.exchangeSegment
662
+ * exchangeSegment of the instrument used for placing the order
663
+ *
664
+ * @param {number} reqObject.exchangeInstrumentID
665
+ * exchangeInstrumentID of the instrument used for placing the order
666
+ *
667
+ * @param {string} reqObject.orderSide
668
+ * orderSide of the particular order.
669
+ *
670
+ * @param {number} reqObject.orderQuantity
671
+ * orderQuantity of the particular order.
672
+ *
673
+ * @param {number} reqObject.disclosedQuantity
674
+ * disclosedQuantity of the particular order.
675
+ *
676
+ * @param {number} reqObject.limitPrice
677
+ * limitPrice of the particular order.
678
+ *
679
+ * @param {number} reqObject.stopPrice
680
+ * stopPrice of the particular order.
681
+ *
682
+ * @param {string} reqObject.orderUniqueIdentifier
683
+ * orderUniqueIdentifier of the particular order.
684
+ *
685
+ */
686
+ async placeCoverOrder(reqObject) {
687
+ try {
688
+ await this.checkLoggedIn();
689
+ let response = await request.processRequest(
690
+ 'POST',
691
+ this.url + settings.restApi.cover,
692
+ { authorization: this.token },
693
+ reqObject,
694
+ this.localIP
695
+ );
696
+ return response;
697
+ } catch (error) {
698
+ let customError = new CustomError(
699
+ error.message,
700
+ error.stack,
701
+ error.statusCode
702
+ );
703
+ return customError;
704
+ }
705
+ }
706
+
707
+ // {
708
+ // "appOrderID": "2426016103"
709
+ // }
710
+
711
+ /**
712
+ * exitCoverOrder API of the application provides functionality of exiting the cover order in the application
713
+ *
714
+ * @param {Object} reqObject request object.
715
+ *
716
+ * @param {string} reqObject.appOrderID
717
+ * appOrderID of the particular order
718
+ *
719
+ */
720
+ async exitCoverOrder(reqObject) {
721
+ try {
722
+ await this.checkLoggedIn();
723
+ let response = await request.processRequest(
724
+ 'PUT',
725
+ this.url + settings.restApi.cover,
726
+ { authorization: this.token },
727
+ reqObject,
728
+ this.localIP
729
+ );
730
+ return response;
731
+ } catch (error) {
732
+ let customError = new CustomError(
733
+ error.message,
734
+ error.stack,
735
+ error.statusCode
736
+ );
737
+ return customError;
738
+ }
739
+ }
740
+
741
+ /**
742
+ * getOrderBook API of the application provides functionality of getting the list of orders present in the orderBook
743
+ *
744
+ */
745
+ async getOrderBook(reqObject) {
746
+ try {
747
+ await this.checkLoggedIn();
748
+ let response = null;
749
+ response = await request.processRequest(
750
+ 'GET',
751
+ this.url + settings.restApi.orders,
752
+ { authorization: this.token },
753
+ null,
754
+ this.localIP
755
+ );
756
+ // to get order history
757
+
758
+ // to get order book
759
+ return response;
760
+ } catch (error) {
761
+ let customError = new CustomError(
762
+ error.message,
763
+ error.stack,
764
+ error.statusCode
765
+ );
766
+ return customError;
767
+ }
768
+ }
769
+
770
+ /**
771
+ * getTradeBook API of the application provides functionality of getting the list of orders present in the orderBook
772
+ *
773
+ */
774
+ async getTradeBook(reqObject) {
775
+ try {
776
+ await this.checkLoggedIn();
777
+ let response = null;
778
+ if (reqObject == null)
779
+ response = await request.processRequest(
780
+ 'GET',
781
+ this.url + settings.restApi.trade,
782
+ { authorization: this.token },
783
+ null,
784
+ this.localIP
785
+ );
786
+ else
787
+ response = await request.processRequest(
788
+ 'GET',
789
+ this.url + settings.restApi.trade + '?clientID=' + reqObject.clientID,
790
+ { authorization: this.token },
791
+ null,
792
+ this.localIP
793
+ );
794
+ return response;
795
+ } catch (error) {
796
+ let customError = new CustomError(
797
+ error.message,
798
+ error.stack,
799
+ error.statusCode
800
+ );
801
+ return customError;
802
+ }
803
+ }
804
+
805
+ //?appOrderID=344566
806
+ /**
807
+ * getOrderHistory API of the application provides functionality of getting the order history in the application
808
+ *
809
+ * @param {string} appOrderID
810
+ * appOrderID of the particular order
811
+ *
812
+ */
813
+ async getOrderHistory(appOrderID) {
814
+ try {
815
+ await this.checkLoggedIn();
816
+ let response = await request.processRequest(
817
+ 'GET',
818
+ this.url + settings.restApi.orders + '?appOrderID=' + appOrderID,
819
+ { authorization: this.token },
820
+ null,
821
+ this.localIP
822
+ );
823
+ return response;
824
+ } catch (error) {
825
+ let customError = new CustomError(
826
+ error.message,
827
+ error.stack,
828
+ error.statusCode
829
+ );
830
+ return customError;
831
+ }
832
+ }
833
+
834
+ /**
835
+ * get Enums APIs of the application provides functionality of get enums separately
836
+ *
837
+ */
838
+ async getEnums(reqObject) {
839
+ try {
840
+ let response = null;
841
+ response = await request.processRequest(
842
+ 'GET',
843
+ this.url + settings.restApi.enums + '?userID=' + reqObject.userID,
844
+ { authorization: this.token },
845
+ null,
846
+ this.localIP
847
+ );
848
+ return response;
849
+ } catch (error) {
850
+ let customError = new CustomError(
851
+ error.message,
852
+ error.stack,
853
+ error.statusCode
854
+ );
855
+ return customError;
856
+ }
857
+ }
858
+
859
+ async bracketOrder(reqObject) {
860
+ try {
861
+ let response = null;
862
+ response = await request.processRequest(
863
+ 'POST',
864
+ this.url + settings.restApi.bracketOrder,
865
+ { authorization: this.token },
866
+ reqObject,
867
+ this.localIP
868
+ );
869
+ return response;
870
+ } catch (error) {
871
+ let customError = new CustomError(
872
+ error.message,
873
+ error.stack,
874
+ error.statusCode
875
+ );
876
+ return customError;
877
+ }
878
+ }
879
+
880
+ async cancelBracketOrder(reqObject) {
881
+ try {
882
+ let response = null;
883
+ response = await request.processRequest(
884
+ 'DELETE',
885
+ this.url +
886
+ settings.restApi.bracketOrder +
887
+ '?boEntryOrderId=' +
888
+ reqObject.boEntryOrderId,
889
+ { authorization: this.token },
890
+ null,
891
+ this.localIP
892
+ );
893
+ return response;
894
+ } catch (error) {
895
+ let customError = new CustomError(
896
+ error.message,
897
+ error.stack,
898
+ error.statusCode
899
+ );
900
+ return customError;
901
+ }
902
+ }
903
+
904
+ async modifyBracketOrder(reqObject) {
905
+ try {
906
+ let response = null;
907
+ response = await request.processRequest(
908
+ 'PUT',
909
+ this.url + settings.restApi.bracketOrder,
910
+ { authorization: this.token },
911
+ reqObject,
912
+ this.localIP
913
+ );
914
+ return response;
915
+ } catch (error) {
916
+ let customError = new CustomError(
917
+ error.message,
918
+ error.stack,
919
+ error.statusCode
920
+ );
921
+ return customError;
922
+ }
923
+ }
924
+ /**
925
+ * get exchange Message APIs of the application provides functionality of exchange brodcast,news message
926
+ *
927
+ */
928
+ async exchangeMessage(reqObject) {
929
+ try {
930
+ let response = null;
931
+ response = await request.processRequest(
932
+ 'GET',
933
+ this.url +
934
+ settings.restApi.message +
935
+ '?exchangeSegment=' +
936
+ reqObject.exchangeSegment,
937
+ { authorization: this.token },
938
+ null,
939
+ this.localIP
940
+ );
941
+ return response;
942
+ } catch (error) {
943
+ let customError = new CustomError(
944
+ error.message,
945
+ error.stack,
946
+ error.statusCode
947
+ );
948
+ return customError;
949
+ }
950
+ }
951
+
952
+ /**
953
+ * get exchange status APIs of the application provides functionality of status of exchange
954
+ *
955
+ */
956
+ async exchangeStatus(reqObject) {
957
+ try {
958
+ let response = null;
959
+ response = await request.processRequest(
960
+ 'GET',
961
+ this.url + settings.restApi.status + '?userID=' + reqObject.userID,
962
+ { authorization: this.token },
963
+ null,
964
+ this.localIP
965
+ );
966
+ return response;
967
+ } catch (error) {
968
+ let customError = new CustomError(
969
+ error.message,
970
+ error.stack,
971
+ error.statusCode
972
+ );
973
+ return customError;
974
+ }
975
+ }
976
+
977
+ //add exchange status APIs
978
+
979
+ async checkLoggedIn() {
980
+ if (this.isLoggedIn) {
981
+ return true;
982
+ } else {
983
+ throw {
984
+ message: 'Login is Required',
985
+ stack: 'login is mandatory',
986
+ statusCode: 404,
987
+ };
988
+ }
989
+ }
990
+
991
+ async checkClientCodes(reqObject) {
992
+ if (this.isInvestorClient) {
993
+ return true;
994
+ } else {
995
+ if (reqObject == null || reqObject.clientID == undefined) {
996
+ throw {
997
+ message: 'ClientCode is Required',
998
+ stack: 'clientCode is mandatory',
999
+ statusCode: 404,
1000
+ };
1001
+ } else {
1002
+ return true;
1003
+ }
1004
+ }
1005
+ }
1006
+ };