hollaex-node-lib 2.15.4 → 2.16.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 +2 -1
  2. package/kit.js +48 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ const client = new hollaex();
13
13
  ```
14
14
 
15
15
  You can pass custom `apiURL`, `wsURL` and `baseURL` of the HollaEx-Enabled exchange to connect to. `apiURL` is `https://api.hollaex.com` for HollaEx Pro and for your custom exchange it would be something like `https://myexchange.com/api`.
16
- `wsURL` is the websocket URL for the socket connection and you should pass your stream URL. For HollaEx Pro it is `wss://api.hollaex.com/stream` and for your exchange it would be something like `wss://myexchange.com/stream`.
16
+ `wsURL` is the websocket URL for the socket connection and you should pass your stream URL. For HollaEx Pro it is `wss://api.hollaex.com/stream` and for your exchange it would be something like `wss://myexchange.com/stream`. `baseURL` is not required and it is set by default to `/v2` unless you need to connect to an older version of HollaEx.
17
17
 
18
18
  You can also pass your `apiKey` and `apiSecret` generated from the HollaEx-Enabled exchange to use private requests that require authentication. For public endpoints `apiKey` and `apiSecret` are not required.
19
19
 
@@ -112,6 +112,7 @@ client
112
112
  | `getExchangeUserReferrer` | <ul><li>**userId**: The identifier of the user to filter by</li></ul> | Retrieve user's referer info by admin |
113
113
  | `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
114
  | `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
+ | `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 |
115
116
 
116
117
 
117
118
  ### Websocket
package/kit.js CHANGED
@@ -473,7 +473,7 @@ class HollaExKit {
473
473
  path += `&end_date=${sanitizeDate(opts.endDate)}`;
474
474
  }
475
475
 
476
- if (isString(opts.format)) {
476
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
477
477
  path += `&format=${opts.format}`;
478
478
  }
479
479
 
@@ -675,6 +675,44 @@ class HollaExKit {
675
675
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
676
676
  }
677
677
 
678
+ /**
679
+ * Retrieve price conversion
680
+ * @param {array} assets - Assets to convert
681
+ * @param {string} opts.quote - Quote coin to convert to
682
+ * @param {number} opts.amount - Amount to convert
683
+ * @return {object} A JSON object with conversion info
684
+ */
685
+ getOraclePrice(
686
+ assets,
687
+ opts = {
688
+ quote: null,
689
+ amount: null
690
+ }
691
+ ) {
692
+ const verb = 'GET';
693
+ let path = `${this.baseUrl}/oracle/prices?`;
694
+
695
+ if (isArray(assets)) {
696
+ path += `&assets=${assets}`;
697
+ }
698
+
699
+ if (isString(opts.quote)) {
700
+ path += `&quote=${opts.quote}`;
701
+ }
702
+
703
+ if (isNumber(opts.amount)) {
704
+ path += `&amount=${opts.amount}`;
705
+ }
706
+
707
+ const headers = generateHeaders(
708
+ this.headers,
709
+ this.apiSecret,
710
+ verb,
711
+ path,
712
+ this.apiExpiresAfter
713
+ );
714
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
715
+ }
678
716
 
679
717
  /**
680
718
  * Get admin exchange information
@@ -798,7 +836,7 @@ class HollaExKit {
798
836
  path += `&address=${opts.address}`;
799
837
  }
800
838
 
801
- if (isString(opts.format) && opts.format === 'csv') {
839
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
802
840
  path += `&format=${opts.format}`;
803
841
  }
804
842
 
@@ -916,7 +954,7 @@ class HollaExKit {
916
954
  path += `&waiting=${opts.waiting}`;
917
955
  }
918
956
 
919
- if (isString(opts.format) && opts.format === 'csv') {
957
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
920
958
  path += `&format=${opts.format}`;
921
959
  }
922
960
 
@@ -1374,6 +1412,7 @@ class HollaExKit {
1374
1412
  orderBy: null,
1375
1413
  order: null,
1376
1414
  startDate: null,
1415
+ endDate: null,
1377
1416
  format: null
1378
1417
  }
1379
1418
  ) {
@@ -1408,11 +1447,11 @@ class HollaExKit {
1408
1447
  path += `&start_date=${sanitizeDate(opts.startDate)}`;
1409
1448
  }
1410
1449
 
1411
- if (isDatetime(opts.startDate)) {
1412
- path += `&end_date=${sanitizeDate(opts.startDate)}`;
1450
+ if (isDatetime(opts.endDate)) {
1451
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
1413
1452
  }
1414
1453
 
1415
- if (isString(opts.format) && opts.format === 'csv') {
1454
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1416
1455
  path += `&format=${opts.format}`;
1417
1456
  }
1418
1457
 
@@ -1620,7 +1659,7 @@ class HollaExKit {
1620
1659
  path += `&end_date=${sanitizeDate(opts.endDate)}`;
1621
1660
  }
1622
1661
 
1623
- if (isString(opts.format) && opts.format === 'csv') {
1662
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1624
1663
  path += `&format=${opts.format}`;
1625
1664
  }
1626
1665
 
@@ -1914,7 +1953,7 @@ class HollaExKit {
1914
1953
  path += `&end_date=${sanitizeDate(opts.endDate)}`;
1915
1954
  }
1916
1955
 
1917
- if (isString(opts.format) && opts.format === 'csv') {
1956
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1918
1957
  path += `&format=${opts.format}`;
1919
1958
  }
1920
1959
 
@@ -2031,7 +2070,7 @@ class HollaExKit {
2031
2070
  path += `&end_date=${sanitizeDate(opts.endDate)}`;
2032
2071
  }
2033
2072
 
2034
- if (isString(opts.format) && opts.format === 'csv') {
2073
+ if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
2035
2074
  path += `&format=${opts.format}`;
2036
2075
  }
2037
2076
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hollaex-node-lib",
3
- "version": "2.15.4",
3
+ "version": "2.16.0",
4
4
  "description": "hollaex api and websocket library for nodejs",
5
5
  "main": "index.js",
6
6
  "dependencies": {