hollaex-node-lib 2.17.0 → 2.18.0

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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/kit.js +370 -172
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -79,6 +79,9 @@ client
79
79
  | `createOrder` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li><li>**side** (_enum_=[`buy`, `sell`]): Order side</li><li>**size**: Size of order to place</li><li>**type**: (_enum_=[`market`, `limit`] Order type</li><li>**price**: (_required if limit order type_) Order price</li><li>**opts**: Object with additional params</li><li>**opts.stop**: (_optional_) Stop price for order</li><li>**opts.meta**: (_optional_) Object with additional meta configurations</li><li>**opts.meta.post_only**: (_optional_, _default_=`false`) Make post only order </li><li>**opts.meta.note**: (_optional_) Custom note for order</li></ul> | Create a new order |
80
80
  | `cancelOrder` | <ul><li>**orderId**: HollaEx Network order ID</li></ul> | Cancel a specific order with its ID |
81
81
  | `cancelAllOrders` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Cancel all the active orders of a user, filtered by currency pair symbol |
82
+ | `getMiniCharts` | <ul><li>**assets**: The list of assets to get the mini charts for</li><li>**opts.from**: (_optional_) Start Date</li><li>**opts.to**: (_optional_) End Date</li><li>**opts.quote**: (_optional_) Quote asset to receive prices based on</li></ul> | Get trade history HOLCV for all pairs |
83
+ | `getQuickTradeQuote` | <ul><li>**spending_currency**: Currency symbol of the spending currency</li><li>**receiving_currency**: Currency symbol of the receiving currency</li><li>**opts.spending_amount**: (_optional_) Spending amount</li><li>**opts.receiving_amount**: (_optional_) Receiving amount</li></ul> | Get Quick Trade Quote |
84
+ | `executeOrder` | <ul><li>**token**: Token</li></ul> | Execute Order |
82
85
 
83
86
  ### Available admin functions:
84
87
 
@@ -113,6 +116,7 @@ client
113
116
  | `sendExchangeUserEmail` | <ul><li>**userId**: The identifier of the user</li><li>**mailType**: The mail type for the email payload</li><li>**data**: The content of the mail</li></ul> | Send email to exchange user account by admin |
114
117
  | `sendRawEmail` | <ul><li>**receivers**: The array of emails to send mail</li><li>**html**: The stringified html content</li><li>**opts.title**: The title of the mail</li><li>**opts.text**: The text of the mail</li></ul> | Send email to users with custom html by admin |
115
118
  | `getOraclePrice` | <ul><li>**assets**: Assets to convert</li><li>**opts.quote**: Quote coin to convert to</li><li>**opts.amount**: Amount to convert</li></ul> | Retrieve price conversion |
119
+ | `getExchangeUserBalances` | <ul><li>**opts.userId**: The identifier of the user to filter by</li><li>**opts.currency**: The currency to filter by, pass undefined to receive data on all currencies</li><li>**opts.format**: Custom format of data set. Enum: ['all', 'csv']</li></ul> | Retrieve user's balances by admin |
116
120
 
117
121
 
118
122
  ### Websocket
package/kit.js CHANGED
@@ -4,7 +4,7 @@ const WebSocket = require('ws');
4
4
  const moment = require('moment');
5
5
  const { createRequest, createSignature, generateHeaders, isDatetime, sanitizeDate } = require('./utils');
6
6
  const { setWsHeartbeat } = require('ws-heartbeat/client');
7
- const { each, union, isNumber, isString, isPlainObject, isBoolean, isObject } = require('lodash');
7
+ const { each, union, isNumber, isString, isPlainObject, isBoolean, isObject, isArray } = require('lodash');
8
8
  class HollaExKit {
9
9
  constructor(
10
10
  opts = {
@@ -207,64 +207,67 @@ class HollaExKit {
207
207
  }
208
208
  ) {
209
209
  const verb = 'GET';
210
- let path = `${this.baseUrl}/user/deposits?`;
210
+ let path = `${this.baseUrl}/user/deposits`;
211
+ let params = '?'
211
212
 
212
213
  if (isString(opts.currency)) {
213
- path += `&currency=${opts.currency}`;
214
+ params += `&currency=${opts.currency}`;
214
215
  }
215
216
 
216
217
  if (isNumber(opts.limit)) {
217
- path += `&limit=${opts.limit}`;
218
+ params += `&limit=${opts.limit}`;
218
219
  }
219
220
 
220
221
  if (isNumber(opts.page)) {
221
- path += `&page=${opts.page}`;
222
+ params += `&page=${opts.page}`;
222
223
  }
223
224
 
224
225
  if (isString(opts.orderBy)) {
225
- path += `&order_by=${opts.orderBy}`;
226
+ params += `&order_by=${opts.orderBy}`;
226
227
  }
227
228
 
228
229
  if (isString(opts.order)) {
229
- path += `&order=${opts.order}`;
230
+ params += `&order=${opts.order}`;
230
231
  }
231
232
 
232
233
  if (isDatetime(opts.startDate)) {
233
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
234
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
234
235
  }
235
236
 
236
237
  if (isDatetime(opts.endDate)) {
237
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
238
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
238
239
  }
239
240
 
240
241
  if (isString(opts.address)) {
241
- path += `&address=${opts.address}`;
242
+ params += `&address=${opts.address}`;
242
243
  }
243
244
 
244
245
  if (isString(opts.transactionId)) {
245
- path += `&transaction_id=${opts.transactionId}`;
246
+ params += `&transaction_id=${opts.transactionId}`;
246
247
  }
247
248
 
248
249
  if (isBoolean(opts.status)) {
249
- path += `&status=${opts.status}`;
250
+ params += `&status=${opts.status}`;
250
251
  }
251
252
 
252
253
  if (isBoolean(opts.dismissed)) {
253
- path += `&dismissed=${opts.dismissed}`;
254
+ params += `&dismissed=${opts.dismissed}`;
254
255
  }
255
256
 
256
257
  if (isBoolean(opts.rejected)) {
257
- path += `&rejected=${opts.rejected}`;
258
+ params += `&rejected=${opts.rejected}`;
258
259
  }
259
260
 
260
261
  if (isBoolean(opts.processing)) {
261
- path += `&processing=${opts.processing}`;
262
+ params += `&processing=${opts.processing}`;
262
263
  }
263
264
 
264
265
  if (isBoolean(opts.waiting)) {
265
- path += `&waiting=${opts.waiting}`;
266
+ params += `&waiting=${opts.waiting}`;
266
267
  }
267
268
 
269
+ if (params.length > 1) path += params;
270
+
268
271
  const headers = generateHeaders(
269
272
  this.headers,
270
273
  this.apiSecret,
@@ -314,64 +317,65 @@ class HollaExKit {
314
317
  }
315
318
  ) {
316
319
  const verb = 'GET';
317
- let path = `${this.baseUrl}/user/withdrawals?`;
320
+ let path = `${this.baseUrl}/user/withdrawals`;
321
+ let params = '?'
318
322
 
319
323
  if (isString(opts.currency)) {
320
- path += `&currency=${opts.currency}`;
324
+ params += `&currency=${opts.currency}`;
321
325
  }
322
326
 
323
327
  if (isNumber(opts.limit)) {
324
- path += `&limit=${opts.limit}`;
328
+ params += `&limit=${opts.limit}`;
325
329
  }
326
330
 
327
331
  if (isNumber(opts.page)) {
328
- path += `&page=${opts.page}`;
332
+ params += `&page=${opts.page}`;
329
333
  }
330
334
 
331
335
  if (isString(opts.orderBy)) {
332
- path += `&order_by=${opts.orderBy}`;
336
+ params += `&order_by=${opts.orderBy}`;
333
337
  }
334
338
 
335
339
  if (isString(opts.order)) {
336
- path += `&order=${opts.order}`;
340
+ params += `&order=${opts.order}`;
337
341
  }
338
342
 
339
343
  if (isDatetime(opts.startDate)) {
340
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
344
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
341
345
  }
342
346
 
343
347
  if (isDatetime(opts.endDate)) {
344
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
348
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
345
349
  }
346
350
 
347
351
  if (isString(opts.address)) {
348
- path += `&address=${opts.address}`;
352
+ params += `&address=${opts.address}`;
349
353
  }
350
354
 
351
355
  if (isString(opts.transactionId)) {
352
- path += `&transaction_id=${opts.transactionId}`;
356
+ params += `&transaction_id=${opts.transactionId}`;
353
357
  }
354
358
 
355
359
  if (isBoolean(opts.status)) {
356
- path += `&status=${opts.status}`;
360
+ params += `&status=${opts.status}`;
357
361
  }
358
362
 
359
363
  if (isBoolean(opts.dismissed)) {
360
- path += `&dismissed=${opts.dismissed}`;
364
+ params += `&dismissed=${opts.dismissed}`;
361
365
  }
362
366
 
363
367
  if (isBoolean(opts.rejected)) {
364
- path += `&rejected=${opts.rejected}`;
368
+ params += `&rejected=${opts.rejected}`;
365
369
  }
366
370
 
367
371
  if (isBoolean(opts.processing)) {
368
- path += `&processing=${opts.processing}`;
372
+ params += `&processing=${opts.processing}`;
369
373
  }
370
374
 
371
375
  if (isBoolean(opts.waiting)) {
372
- path += `&waiting=${opts.waiting}`;
376
+ params += `&waiting=${opts.waiting}`;
373
377
  }
374
-
378
+ if (params.length > 1) path += params;
375
379
  const headers = generateHeaders(
376
380
  this.headers,
377
381
  this.apiSecret,
@@ -443,40 +447,43 @@ class HollaExKit {
443
447
  }
444
448
  ) {
445
449
  const verb = 'GET';
446
- let path = `${this.baseUrl}/user/trades?`;
450
+ let path = `${this.baseUrl}/user/trades`;
451
+ let params = '?';
447
452
 
448
453
  if (isString(opts.symbol)) {
449
- path += `&symbol=${opts.symbol}`;
454
+ params += `&symbol=${opts.symbol}`;
450
455
  }
451
456
 
452
457
  if (isNumber(opts.limit)) {
453
- path += `&limit=${opts.limit}`;
458
+ params += `&limit=${opts.limit}`;
454
459
  }
455
460
 
456
461
  if (isNumber(opts.page)) {
457
- path += `&page=${opts.page}`;
462
+ params += `&page=${opts.page}`;
458
463
  }
459
464
 
460
465
  if (isString(opts.orderBy)) {
461
- path += `&order_by=${opts.orderBy}`;
466
+ params += `&order_by=${opts.orderBy}`;
462
467
  }
463
468
 
464
469
  if (isString(opts.order)) {
465
- path += `&order=${opts.order}`;
470
+ params += `&order=${opts.order}`;
466
471
  }
467
472
 
468
473
  if (isDatetime(opts.startDate)) {
469
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
474
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
470
475
  }
471
476
 
472
477
  if (isDatetime(opts.endDate)) {
473
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
478
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
474
479
  }
475
480
 
476
481
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
477
- path += `&format=${opts.format}`;
482
+ params += `&format=${opts.format}`;
478
483
  }
479
484
 
485
+ if (params.length > 1) path += params;
486
+
480
487
  const headers = generateHeaders(
481
488
  this.headers,
482
489
  this.apiSecret,
@@ -534,48 +541,51 @@ class HollaExKit {
534
541
  }
535
542
  ) {
536
543
  const verb = 'GET';
537
- let path = `${this.baseUrl}/orders?`;
544
+ let path = `${this.baseUrl}/orders`;
545
+ let params = '?';
538
546
 
539
547
  if (isString(opts.symbol)) {
540
- path += `&symbol=${opts.symbol}`;
548
+ params += `&symbol=${opts.symbol}`;
541
549
  }
542
550
 
543
551
  if (isString(opts.side) && (opts.side.toLowerCase() === 'buy' || opts.side.toLowerCase() === 'sell')) {
544
- path += `&side=${opts.side}`;
552
+ params += `&side=${opts.side}`;
545
553
  }
546
554
 
547
555
  if (isString(opts.status)) {
548
- path += `&status=${opts.status}`;
556
+ params += `&status=${opts.status}`;
549
557
  }
550
558
 
551
559
  if (isBoolean(opts.open)) {
552
- path += `&open=${opts.open}`;
560
+ params += `&open=${opts.open}`;
553
561
  }
554
562
 
555
563
  if (isNumber(opts.limit)) {
556
- path += `&limit=${opts.limit}`;
564
+ params += `&limit=${opts.limit}`;
557
565
  }
558
566
 
559
567
  if (isNumber(opts.page)) {
560
- path += `&page=${opts.page}`;
568
+ params += `&page=${opts.page}`;
561
569
  }
562
570
 
563
571
  if (isString(opts.orderBy)) {
564
- path += `&order_by=${opts.orderBy}`;
572
+ params += `&order_by=${opts.orderBy}`;
565
573
  }
566
574
 
567
575
  if (isString(opts.order)) {
568
- path += `&order=${opts.order}`;
576
+ params += `&order=${opts.order}`;
569
577
  }
570
578
 
571
579
  if (isDatetime(opts.startDate)) {
572
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
580
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
573
581
  }
574
582
 
575
583
  if (isDatetime(opts.endDate)) {
576
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
584
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
577
585
  }
578
586
 
587
+ if (params.length > 1) path += params;
588
+
579
589
  const headers = generateHeaders(
580
590
  this.headers,
581
591
  this.apiSecret,
@@ -690,19 +700,21 @@ class HollaExKit {
690
700
  }
691
701
  ) {
692
702
  const verb = 'GET';
693
- let path = `${this.baseUrl}/oracle/prices?`;
703
+ let path = `${this.baseUrl}/oracle/prices`;
704
+ let params = '?';
694
705
 
695
706
  if (isArray(assets)) {
696
- path += `&assets=${assets}`;
707
+ params += `&assets=${assets}`;
697
708
  }
698
709
 
699
710
  if (isString(opts.quote)) {
700
- path += `&quote=${opts.quote}`;
711
+ params += `&quote=${opts.quote}`;
701
712
  }
702
713
 
703
714
  if (isNumber(opts.amount)) {
704
- path += `&amount=${opts.amount}`;
715
+ params += `&amount=${opts.amount}`;
705
716
  }
717
+ if (params.length > 1) path += params;
706
718
 
707
719
  const headers = generateHeaders(
708
720
  this.headers,
@@ -714,6 +726,126 @@ class HollaExKit {
714
726
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
715
727
  }
716
728
 
729
+
730
+ /**
731
+ * Get trade history HOLCV for all pairs
732
+ * @param {array} assets - The list of assets to get the mini charts for
733
+ * @param {string} opts.from - Start Date
734
+ * @param {string} opts.to - End data
735
+ * @param {string} opts.quote - Quote asset to receive prices based on
736
+ * @return {object} A JSON object with trade history info
737
+ */
738
+ getMiniCharts(
739
+ assets,
740
+ opts = {
741
+ from: null,
742
+ to: null,
743
+ quote: null,
744
+ }
745
+ ) {
746
+ const verb = 'GET';
747
+ let path = `${this.baseUrl}/minicharts`;
748
+ let params = '?';
749
+
750
+ if (isArray(assets)) {
751
+ params += `&assets=${opts.assets}`;
752
+ }
753
+
754
+ if (isString(opts.from)) {
755
+ params += `&from=${opts.from}`;
756
+ }
757
+
758
+ if (isString(opts.to)) {
759
+ params += `&to=${opts.to}`;
760
+ }
761
+
762
+ if (isString(opts.quote)) {
763
+ params += `&quote=${opts.quote}`;
764
+ }
765
+
766
+ if (params.length > 1) path += params;
767
+
768
+ const headers = generateHeaders(
769
+ this.headers,
770
+ this.apiSecret,
771
+ verb,
772
+ path,
773
+ this.apiExpiresAfter
774
+ );
775
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
776
+ }
777
+
778
+ /**
779
+ * Get Quick Trade Quote
780
+ * @param {string} spending_currency - Currency symbol of the spending currency
781
+ * @param {string} receiving_currency - Currency symbol of the receiving currency
782
+ * @param {string} opts.spending_amount - Spending amount
783
+ * @param {string} opts.receiving_amount - Receiving amount
784
+ */
785
+ getQuickTradeQuote(
786
+ spending_currency,
787
+ receiving_currency,
788
+ opts = {
789
+ spending_amount: null,
790
+ receiving_amount: null,
791
+ }
792
+ ) {
793
+ const verb = 'GET';
794
+ let path = `${this.baseUrl}/quick-trade`;
795
+ let params = '?';
796
+
797
+ if (isString(spending_currency)) {
798
+ params += `&spending_currency=${spending_currency}`;
799
+ }
800
+
801
+ if (isString(receiving_currency)) {
802
+ params += `&receiving_currency=${receiving_currency}`;
803
+ }
804
+
805
+ if (isString(opts.spending_amount)) {
806
+ params += `&spending_amount=${opts.spending_amount}`;
807
+ }
808
+
809
+ if (isString(opts.receiving_amount)) {
810
+ params += `&receiving_amount=${opts.receiving_amount}`;
811
+ }
812
+
813
+ if (params.length > 1) path += params;
814
+
815
+ const headers = generateHeaders(
816
+ this.headers,
817
+ this.apiSecret,
818
+ verb,
819
+ path,
820
+ this.apiExpiresAfter
821
+ );
822
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
823
+ }
824
+
825
+ /**
826
+ * Execute Order
827
+ * @param {string} token - Token
828
+ */
829
+ executeOrder(
830
+ token
831
+ ) {
832
+ const verb = 'POST';
833
+ let path = `${this.baseUrl}/order/execute`;
834
+ const data = {
835
+ token
836
+ };
837
+
838
+ const headers = generateHeaders(
839
+ this.headers,
840
+ this.apiSecret,
841
+ verb,
842
+ path,
843
+ this.apiExpiresAfter,
844
+ data
845
+ );
846
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
847
+ }
848
+
717
849
  /**
718
850
  * Get admin exchange information
719
851
  * @return {object} A json object with the admin exchange information
@@ -773,73 +905,75 @@ class HollaExKit {
773
905
  }
774
906
  ) {
775
907
  const verb = 'GET';
776
- let path = `${this.baseUrl}/admin/deposits?`;
777
-
908
+ let path = `${this.baseUrl}/admin/deposits`;
909
+ let params = '?';
778
910
 
779
911
  if (isNumber(opts.userId)) {
780
- path += `&user_id=${opts.userId}`;
912
+ params += `&user_id=${opts.userId}`;
781
913
  }
782
914
 
783
915
  if (isString(opts.currency)) {
784
- path += `&currency=${opts.currency}`;
916
+ params += `&currency=${opts.currency}`;
785
917
  }
786
918
 
787
919
  if (isNumber(opts.limit)) {
788
- path += `&limit=${opts.limit}`;
920
+ params += `&limit=${opts.limit}`;
789
921
  }
790
922
 
791
923
  if (isNumber(opts.page)) {
792
- path += `&page=${opts.page}`;
924
+ params += `&page=${opts.page}`;
793
925
  }
794
926
 
795
927
  if (isString(opts.orderBy)) {
796
- path += `&order_by=${opts.orderBy}`;
928
+ params += `&order_by=${opts.orderBy}`;
797
929
  }
798
930
 
799
931
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
800
- path += `&order=${opts.order}`;
932
+ params += `&order=${opts.order}`;
801
933
  }
802
934
 
803
935
  if (isDatetime(opts.startDate)) {
804
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
936
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
805
937
  }
806
938
 
807
939
  if (isDatetime(opts.endDate)) {
808
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
940
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
809
941
  }
810
942
 
811
943
  if (isBoolean(opts.status)) {
812
- path += `&status=${opts.status}`;
944
+ params += `&status=${opts.status}`;
813
945
  }
814
946
 
815
947
  if (isBoolean(opts.dismissed)) {
816
- path += `&dismissed=${opts.dismissed}`;
948
+ params += `&dismissed=${opts.dismissed}`;
817
949
  }
818
950
 
819
951
  if (isBoolean(opts.rejected)) {
820
- path += `&rejected=${opts.rejected}`;
952
+ params += `&rejected=${opts.rejected}`;
821
953
  }
822
954
 
823
955
  if (isBoolean(opts.processing)) {
824
- path += `&processing=${opts.processing}`;
956
+ params += `&processing=${opts.processing}`;
825
957
  }
826
958
 
827
959
  if (isBoolean(opts.waiting)) {
828
- path += `&waiting=${opts.waiting}`;
960
+ params += `&waiting=${opts.waiting}`;
829
961
  }
830
962
 
831
963
  if (isString(opts.transactionId)) {
832
- path += `&transaction_id=${opts.transactionId}`;
964
+ params += `&transaction_id=${opts.transactionId}`;
833
965
  }
834
966
 
835
967
  if (isString(opts.address)) {
836
- path += `&address=${opts.address}`;
968
+ params += `&address=${opts.address}`;
837
969
  }
838
970
 
839
971
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
840
- path += `&format=${opts.format}`;
972
+ params += `&format=${opts.format}`;
841
973
  }
842
974
 
975
+ if (params.length > 1) path += params;
976
+
843
977
  const headers = generateHeaders(
844
978
  this.headers,
845
979
  this.apiSecret,
@@ -892,72 +1026,74 @@ class HollaExKit {
892
1026
  }
893
1027
  ) {
894
1028
  const verb = 'GET';
895
- let path = `${this.baseUrl}/admin/withdrawals?`;
1029
+ let path = `${this.baseUrl}/admin/withdrawals`;
1030
+ let params = '?';
896
1031
 
897
1032
  if (isString(opts.currency)) {
898
- path += `&currency=${opts.currency}`;
1033
+ params += `&currency=${opts.currency}`;
899
1034
  }
900
1035
 
901
1036
  if (isNumber(opts.userId)) {
902
- path += `&user_id=${opts.userId}`;
1037
+ params += `&user_id=${opts.userId}`;
903
1038
  }
904
1039
 
905
1040
  if (isString(opts.transactionId)) {
906
- path += `&transaction_id=${opts.transactionId}`;
1041
+ params += `&transaction_id=${opts.transactionId}`;
907
1042
  }
908
1043
 
909
1044
  if (isString(opts.address)) {
910
- path += `&address=${opts.address}`;
1045
+ params += `&address=${opts.address}`;
911
1046
  }
912
1047
 
913
1048
  if (isNumber(opts.limit)) {
914
- path += `&limit=${opts.limit}`;
1049
+ params += `&limit=${opts.limit}`;
915
1050
  }
916
1051
 
917
1052
  if (isNumber(opts.page)) {
918
- path += `&page=${opts.page}`;
1053
+ params += `&page=${opts.page}`;
919
1054
  }
920
1055
 
921
1056
  if (isString(opts.orderBy)) {
922
- path += `&order_by=${opts.orderBy}`;
1057
+ params += `&order_by=${opts.orderBy}`;
923
1058
  }
924
1059
 
925
1060
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
926
- path += `&order=${opts.order}`;
1061
+ params += `&order=${opts.order}`;
927
1062
  }
928
1063
 
929
1064
  if (isDatetime(opts.startDate)) {
930
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
1065
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
931
1066
  }
932
1067
 
933
1068
  if (isDatetime(opts.endDate)) {
934
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
1069
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
935
1070
  }
936
1071
 
937
1072
  if (isBoolean(opts.status)) {
938
- path += `&status=${opts.status}`;
1073
+ params += `&status=${opts.status}`;
939
1074
  }
940
1075
 
941
1076
  if (isBoolean(opts.dismissed)) {
942
- path += `&dismissed=${opts.dismissed}`;
1077
+ params += `&dismissed=${opts.dismissed}`;
943
1078
  }
944
1079
 
945
1080
  if (isBoolean(opts.rejected)) {
946
- path += `&rejected=${opts.rejected}`;
1081
+ params += `&rejected=${opts.rejected}`;
947
1082
  }
948
1083
 
949
1084
  if (isBoolean(opts.processing)) {
950
- path += `&processing=${opts.processing}`;
1085
+ params += `&processing=${opts.processing}`;
951
1086
  }
952
1087
 
953
1088
  if (isBoolean(opts.waiting)) {
954
- path += `&waiting=${opts.waiting}`;
1089
+ params += `&waiting=${opts.waiting}`;
955
1090
  }
956
1091
 
957
1092
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
958
- path += `&format=${opts.format}`;
1093
+ params += `&format=${opts.format}`;
959
1094
  }
960
1095
 
1096
+ if (params.length > 1) path += params;
961
1097
  const headers = generateHeaders(
962
1098
  this.headers,
963
1099
  this.apiSecret,
@@ -1006,7 +1142,7 @@ class HollaExKit {
1006
1142
  }
1007
1143
  ) {
1008
1144
  const verb = 'POST';
1009
- let path = `${this.baseUrl}/admin/transfer?`;
1145
+ let path = `${this.baseUrl}/admin/transfer`;
1010
1146
  const data = {
1011
1147
  sender_id: senderId,
1012
1148
  receiver_id: receiverId,
@@ -1120,7 +1256,7 @@ class HollaExKit {
1120
1256
  }
1121
1257
  ) {
1122
1258
  const verb = 'PUT';
1123
- let path = `${this.baseUrl}/admin/mint?`;
1259
+ let path = `${this.baseUrl}/admin/mint`;
1124
1260
  const data = {
1125
1261
  transaction_id: transactionId
1126
1262
  };
@@ -1196,7 +1332,7 @@ class HollaExKit {
1196
1332
  }
1197
1333
  ) {
1198
1334
  const verb = 'POST';
1199
- let path = `${this.baseUrl}/admin/burn?`;
1335
+ let path = `${this.baseUrl}/admin/burn`;
1200
1336
  const data = {
1201
1337
  user_id: userId,
1202
1338
  currency,
@@ -1259,7 +1395,7 @@ class HollaExKit {
1259
1395
  }
1260
1396
  ) {
1261
1397
  const verb = 'PUT';
1262
- let path = `${this.baseUrl}/admin/burn?`;
1398
+ let path = `${this.baseUrl}/admin/burn`;
1263
1399
  const data = {
1264
1400
  transaction_id: transactionId
1265
1401
  };
@@ -1331,27 +1467,31 @@ class HollaExKit {
1331
1467
  }
1332
1468
  ) {
1333
1469
  const verb = 'GET';
1334
- let path = `${this.baseUrl}/admin/check-transaction?`;
1335
-
1470
+ let path = `${this.baseUrl}/admin/check-transaction`;
1471
+ let params = '?';
1472
+
1336
1473
  if (isString(currency)) {
1337
- path += `&currency=${currency}`;
1474
+ params += `&currency=${currency}`;
1338
1475
  }
1339
1476
 
1340
1477
  if (isString(transactionId)) {
1341
- path += `&transaction_id=${transactionId}`;
1478
+ params += `&transaction_id=${transactionId}`;
1342
1479
  }
1343
1480
 
1344
1481
  if (isString(address)) {
1345
- path += `&address=${address}`;
1482
+ params += `&address=${address}`;
1346
1483
  }
1347
1484
 
1348
1485
  if (isString(network)) {
1349
- path += `&network=${network}`;
1486
+ params += `&network=${network}`;
1350
1487
  }
1351
1488
 
1352
1489
  if (isBoolean(opts.isTestnet)) {
1353
- path += `&is_testnet=${opts.isTestnet}`;
1490
+ params += `&is_testnet=${opts.isTestnet}`;
1354
1491
  }
1492
+
1493
+ if (params.length > 1) path += params;
1494
+
1355
1495
  const headers = generateHeaders(
1356
1496
  this.headers,
1357
1497
  this.apiSecret,
@@ -1417,43 +1557,46 @@ class HollaExKit {
1417
1557
  }
1418
1558
  ) {
1419
1559
  const verb = 'GET';
1420
- let path = `${this.baseUrl}/admin/trades?`;
1560
+ let path = `${this.baseUrl}/admin/trades`;
1561
+ let params = '?';
1421
1562
 
1422
1563
  if (isNumber(opts.userId)) {
1423
- path += `&user_id=${opts.userId}`;
1564
+ params += `&user_id=${opts.userId}`;
1424
1565
  }
1425
1566
 
1426
1567
  if (isNumber(opts.limit)) {
1427
- path += `&limit=${opts.limit}`;
1568
+ params += `&limit=${opts.limit}`;
1428
1569
  }
1429
1570
 
1430
1571
  if (isNumber(opts.page)) {
1431
- path += `&page=${opts.page}`;
1572
+ params += `&page=${opts.page}`;
1432
1573
  }
1433
1574
 
1434
1575
  if (isString(opts.symbol)) {
1435
- path += `&symbol=${opts.symbol}`;
1576
+ params += `&symbol=${opts.symbol}`;
1436
1577
  }
1437
1578
 
1438
1579
  if (isString(opts.orderBy)) {
1439
- path += `&order_by=${opts.orderBy}`;
1580
+ params += `&order_by=${opts.orderBy}`;
1440
1581
  }
1441
1582
 
1442
1583
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1443
- path += `&order=${opts.order}`;
1584
+ params += `&order=${opts.order}`;
1444
1585
  }
1445
1586
 
1446
1587
  if (isDatetime(opts.startDate)) {
1447
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
1588
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
1448
1589
  }
1449
1590
 
1450
1591
  if (isDatetime(opts.endDate)) {
1451
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
1592
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
1452
1593
  }
1453
1594
 
1454
1595
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1455
- path += `&format=${opts.format}`;
1596
+ params += `&format=${opts.format}`;
1456
1597
  }
1598
+
1599
+ if (params.length > 1) path += params;
1457
1600
 
1458
1601
  const headers = generateHeaders(
1459
1602
  this.headers,
@@ -1497,52 +1640,55 @@ class HollaExKit {
1497
1640
  }
1498
1641
  ) {
1499
1642
  const verb = 'GET';
1500
- let path = `${this.baseUrl}/admin/orders?`;
1643
+ let path = `${this.baseUrl}/admin/orders`;
1644
+ let params = '?';
1501
1645
 
1502
1646
  if (isNumber(opts.userId)) {
1503
- path += `&user_id=${opts.userId}`;
1647
+ params += `&user_id=${opts.userId}`;
1504
1648
  }
1505
1649
 
1506
1650
  if (isString(opts.side) && (opts.side === 'buy' || opts.side === 'sell')) {
1507
- path += `&side=${opts.side}`;
1651
+ params += `&side=${opts.side}`;
1508
1652
  }
1509
1653
 
1510
1654
  if (isString(opts.status)) {
1511
- path += `&status=${opts.status}`;
1655
+ params += `&status=${opts.status}`;
1512
1656
  }
1513
1657
 
1514
1658
  if (isBoolean(opts.open)) {
1515
- path += `&open=${opts.open}`;
1659
+ params += `&open=${opts.open}`;
1516
1660
  }
1517
1661
 
1518
1662
  if (isNumber(opts.limit)) {
1519
- path += `&limit=${opts.limit}`;
1663
+ params += `&limit=${opts.limit}`;
1520
1664
  }
1521
1665
 
1522
1666
  if (isNumber(opts.page)) {
1523
- path += `&page=${opts.page}`;
1667
+ params += `&page=${opts.page}`;
1524
1668
  }
1525
1669
 
1526
1670
  if (isString(opts.symbol)) {
1527
- path += `&symbol=${opts.symbol}`;
1671
+ params += `&symbol=${opts.symbol}`;
1528
1672
  }
1529
1673
 
1530
1674
  if (isString(opts.orderBy)) {
1531
- path += `&order_by=${opts.orderBy}`;
1675
+ params += `&order_by=${opts.orderBy}`;
1532
1676
  }
1533
1677
 
1534
1678
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1535
- path += `&order=${opts.order}`;
1679
+ params += `&order=${opts.order}`;
1536
1680
  }
1537
1681
 
1538
1682
  if (isDatetime(opts.startDate)) {
1539
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
1683
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
1540
1684
  }
1541
1685
 
1542
1686
  if (isDatetime(opts.endDate)) {
1543
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
1687
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
1544
1688
  }
1545
1689
 
1690
+ if (params.length > 1) path += params;
1691
+
1546
1692
  const headers = generateHeaders(
1547
1693
  this.headers,
1548
1694
  this.apiSecret,
@@ -1561,15 +1707,18 @@ class HollaExKit {
1561
1707
  */
1562
1708
  cancelExchangeUserOrder(userId, orderId) {
1563
1709
  const verb = 'DELETE';
1564
- let path = `${this.baseUrl}/admin/order?`;
1710
+ let path = `${this.baseUrl}/admin/order`;
1711
+ let params = '?';
1565
1712
 
1566
1713
  if (isString(orderId)) {
1567
- path += `&order_id=${orderId}`;
1714
+ params += `&order_id=${orderId}`;
1568
1715
  }
1569
1716
 
1570
1717
  if (isNumber(userId)) {
1571
- path += `&user_id=${userId}`;
1718
+ params += `&user_id=${userId}`;
1572
1719
  }
1720
+
1721
+ if (params.length > 1) path += params;
1573
1722
  const headers = generateHeaders(
1574
1723
  this.headers,
1575
1724
  this.apiSecret,
@@ -1613,55 +1762,57 @@ class HollaExKit {
1613
1762
  }
1614
1763
  ) {
1615
1764
  const verb = 'GET';
1616
- let path = `${this.baseUrl}/admin/users?`;
1765
+ let path = `${this.baseUrl}/admin/users`;
1766
+ let params = '?';
1617
1767
 
1618
1768
  if (isNumber(opts.userId)) {
1619
- path += `&id=${opts.userId}`;
1769
+ params += `&id=${opts.userId}`;
1620
1770
  }
1621
1771
 
1622
1772
  if (isString(opts.search)) {
1623
- path += `&search=${opts.search}`;
1773
+ params += `&search=${opts.search}`;
1624
1774
  }
1625
1775
 
1626
1776
  if (isString(opts.type)) {
1627
- path += `&type=${opts.type}`;
1777
+ params += `&type=${opts.type}`;
1628
1778
  }
1629
1779
 
1630
1780
  if (isBoolean(opts.pending)) {
1631
- path += `&pending=${opts.pending}`;
1781
+ params += `&pending=${opts.pending}`;
1632
1782
  }
1633
1783
 
1634
1784
  if (isString(opts.pendingType) && (opts.pendingType === 'id' ||opts.pendingType === 'bank')) {
1635
- path += `&pending_type=${opts.pendingType}`;
1785
+ params += `&pending_type=${opts.pendingType}`;
1636
1786
  }
1637
1787
 
1638
1788
  if (isNumber(opts.limit)) {
1639
- path += `&limit=${opts.limit}`;
1789
+ params += `&limit=${opts.limit}`;
1640
1790
  }
1641
1791
 
1642
1792
  if (isNumber(opts.page)) {
1643
- path += `&page=${opts.page}`;
1793
+ params += `&page=${opts.page}`;
1644
1794
  }
1645
1795
 
1646
1796
  if (isString(opts.orderBy)) {
1647
- path += `&order_by=${opts.orderBy}`;
1797
+ params += `&order_by=${opts.orderBy}`;
1648
1798
  }
1649
1799
 
1650
1800
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1651
- path += `&order=${opts.order}`;
1801
+ params += `&order=${opts.order}`;
1652
1802
  }
1653
1803
 
1654
1804
  if (isDatetime(opts.startDate)) {
1655
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
1805
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
1656
1806
  }
1657
1807
 
1658
1808
  if (isDatetime(opts.endDate)) {
1659
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
1809
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
1660
1810
  }
1661
1811
 
1662
1812
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1663
- path += `&format=${opts.format}`;
1813
+ params += `&format=${opts.format}`;
1664
1814
  }
1815
+ if (params.length > 1) path += params;
1665
1816
 
1666
1817
  const headers = generateHeaders(
1667
1818
  this.headers,
@@ -1907,55 +2058,58 @@ class HollaExKit {
1907
2058
  }
1908
2059
  ) {
1909
2060
  const verb = 'GET';
1910
- let path = `${this.baseUrl}/admin/user/wallet?`;
2061
+ let path = `${this.baseUrl}/admin/user/wallet`;
2062
+ let params = '?';
1911
2063
 
1912
2064
  if (isNumber(opts.userId)) {
1913
- path += `&user_id=${opts.userId}`;
2065
+ params += `&user_id=${opts.userId}`;
1914
2066
  }
1915
2067
 
1916
2068
  if (isString(opts.currency)) {
1917
- path += `&currency=${opts.currency}`;
2069
+ params += `&currency=${opts.currency}`;
1918
2070
  }
1919
2071
 
1920
2072
  if (isString(opts.address)) {
1921
- path += `&address=${opts.address}`;
2073
+ params += `&address=${opts.address}`;
1922
2074
  }
1923
2075
 
1924
2076
  if (isString(opts.network)) {
1925
- path += `&network=${opts.network}`;
2077
+ params += `&network=${opts.network}`;
1926
2078
  }
1927
2079
 
1928
2080
  if (isBoolean(opts.isValid)) {
1929
- path += `&is_valid=${opts.isValid}`;
2081
+ params += `&is_valid=${opts.isValid}`;
1930
2082
  }
1931
2083
 
1932
2084
  if (isNumber(opts.limit)) {
1933
- path += `&limit=${opts.limit}`;
2085
+ params += `&limit=${opts.limit}`;
1934
2086
  }
1935
2087
 
1936
2088
  if (isNumber(opts.page)) {
1937
- path += `&page=${opts.page}`;
2089
+ params += `&page=${opts.page}`;
1938
2090
  }
1939
2091
 
1940
2092
  if (isString(opts.orderBy)) {
1941
- path += `&order_by=${opts.orderBy}`;
2093
+ params += `&order_by=${opts.orderBy}`;
1942
2094
  }
1943
2095
 
1944
2096
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1945
- path += `&order=${opts.order}`;
2097
+ params += `&order=${opts.order}`;
1946
2098
  }
1947
2099
 
1948
2100
  if (isDatetime(opts.startDate)) {
1949
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
2101
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
1950
2102
  }
1951
2103
 
1952
2104
  if (isDatetime(opts.endDate)) {
1953
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
2105
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
1954
2106
  }
1955
2107
 
1956
2108
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1957
- path += `&format=${opts.format}`;
2109
+ params += `&format=${opts.format}`;
1958
2110
  }
2111
+
2112
+ if (params.length > 1) path += params;
1959
2113
 
1960
2114
  const headers = generateHeaders(
1961
2115
  this.headers,
@@ -2040,40 +2194,43 @@ class HollaExKit {
2040
2194
  }
2041
2195
  ) {
2042
2196
  const verb = 'GET';
2043
- let path = `${this.baseUrl}/admin/logins?`;
2197
+ let path = `${this.baseUrl}/admin/logins`;
2198
+ let params = '?';
2044
2199
 
2045
2200
  if (isNumber(opts.userId)) {
2046
- path += `&user_id=${opts.userId}`;
2201
+ params += `&user_id=${opts.userId}`;
2047
2202
  }
2048
2203
 
2049
2204
  if (isNumber(opts.limit)) {
2050
- path += `&limit=${opts.limit}`;
2205
+ params += `&limit=${opts.limit}`;
2051
2206
  }
2052
2207
 
2053
2208
  if (isNumber(opts.page)) {
2054
- path += `&page=${opts.page}`;
2209
+ params += `&page=${opts.page}`;
2055
2210
  }
2056
2211
 
2057
2212
  if (isString(opts.orderBy)) {
2058
- path += `&order_by=${opts.orderBy}`;
2213
+ params += `&order_by=${opts.orderBy}`;
2059
2214
  }
2060
2215
 
2061
2216
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2062
- path += `&order=${opts.order}`;
2217
+ params += `&order=${opts.order}`;
2063
2218
  }
2064
2219
 
2065
2220
  if (isDatetime(opts.startDate)) {
2066
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
2221
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
2067
2222
  }
2068
2223
 
2069
2224
  if (isDatetime(opts.endDate)) {
2070
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
2225
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
2071
2226
  }
2072
2227
 
2073
2228
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
2074
- path += `&format=${opts.format}`;
2229
+ params += `&format=${opts.format}`;
2075
2230
  }
2076
2231
 
2232
+ if (params.length > 1) path += params;
2233
+
2077
2234
  const headers = generateHeaders(
2078
2235
  this.headers,
2079
2236
  this.apiSecret,
@@ -2154,36 +2311,38 @@ class HollaExKit {
2154
2311
  }
2155
2312
  ) {
2156
2313
  const verb = 'GET';
2157
- let path = `${this.baseUrl}/admin/user/affiliation?`;
2158
-
2314
+ let path = `${this.baseUrl}/admin/user/affiliation`;
2315
+ let params = '?';
2159
2316
 
2160
2317
  if (isNumber(userId)) {
2161
- path += `&user_id=${userId}`;
2318
+ params += `&user_id=${userId}`;
2162
2319
  }
2163
2320
 
2164
2321
  if (isNumber(opts.limit)) {
2165
- path += `&limit=${opts.limit}`;
2322
+ params += `&limit=${opts.limit}`;
2166
2323
  }
2167
2324
 
2168
2325
  if (isNumber(opts.page)) {
2169
- path += `&page=${opts.page}`;
2326
+ params += `&page=${opts.page}`;
2170
2327
  }
2171
2328
 
2172
2329
  if (isString(opts.orderBy)) {
2173
- path += `&order_by=${opts.orderBy}`;
2330
+ params += `&order_by=${opts.orderBy}`;
2174
2331
  }
2175
2332
 
2176
2333
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2177
- path += `&order=${opts.order}`;
2334
+ params += `&order=${opts.order}`;
2178
2335
  }
2179
2336
 
2180
2337
  if (isDatetime(opts.startDate)) {
2181
- path += `&start_date=${sanitizeDate(opts.startDate)}`;
2338
+ params += `&start_date=${sanitizeDate(opts.startDate)}`;
2182
2339
  }
2183
2340
 
2184
2341
  if (isDatetime(opts.endDate)) {
2185
- path += `&end_date=${sanitizeDate(opts.endDate)}`;
2342
+ params += `&end_date=${sanitizeDate(opts.endDate)}`;
2186
2343
  }
2344
+
2345
+ if (params.length > 1) path += params;
2187
2346
 
2188
2347
 
2189
2348
  const headers = generateHeaders(
@@ -2279,7 +2438,46 @@ class HollaExKit {
2279
2438
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2280
2439
  }
2281
2440
 
2282
-
2441
+ /**
2442
+ * Retrieve user's balances by admin
2443
+ * @param {number} opts.userId - The identifier of the user to filter by
2444
+ * @param {number} opts.currency - The currency to filter by, pass undefined to receive data on all currencies
2445
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
2446
+ * @return {object} A JSON object with referral info
2447
+ */
2448
+ getExchangeUserBalances(
2449
+ opts = {
2450
+ userId: null,
2451
+ currency: null,
2452
+ format: null
2453
+ }
2454
+ ) {
2455
+ const verb = 'GET';
2456
+ let path = `${this.baseUrl}/admin/balances?`;
2457
+
2458
+
2459
+ if (isNumber(opts.userId)) {
2460
+ path += `&user_id=${opts.userId}`;
2461
+ }
2462
+
2463
+ if (isString(opts.currency)) {
2464
+ path += `&currency=${opts.currency}`;
2465
+ }
2466
+
2467
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
2468
+ path += `&format=${opts.format}`;
2469
+ }
2470
+
2471
+ const headers = generateHeaders(
2472
+ this.headers,
2473
+ this.apiSecret,
2474
+ verb,
2475
+ path,
2476
+ this.apiExpiresAfter
2477
+ );
2478
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2479
+ }
2480
+
2283
2481
  /**
2284
2482
  * Connect to hollaEx websocket and listen to an event
2285
2483
  * @param {array} events - The events to listen to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hollaex-node-lib",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "hollaex api and websocket library for nodejs",
5
5
  "main": "index.js",
6
6
  "dependencies": {