hollaex-node-lib 2.14.1 → 2.15.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.
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 } = require('lodash');
7
+ const { each, union, isNumber, isString, isPlainObject, isBoolean, isObject, isArray } = require('lodash');
8
8
  class HollaExKit {
9
9
  constructor(
10
10
  opts = {
@@ -672,6 +672,1508 @@ class HollaExKit {
672
672
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
673
673
  }
674
674
 
675
+
676
+ /**
677
+ * Get admin exchange information
678
+ * @return {object} A json object with the admin exchange information
679
+ */
680
+ getExchangeInfo() {
681
+ const verb = 'GET';
682
+ const path = `${this.baseUrl}/admin/exchange`;
683
+ const headers = generateHeaders(
684
+ this.headers,
685
+ this.apiSecret,
686
+ verb,
687
+ path,
688
+ this.apiExpiresAfter
689
+ );
690
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
691
+ }
692
+
693
+ /**
694
+ * Retrieve list of the user's deposits by admin
695
+ * @param {object} opts - Optional parameters
696
+ * @param {number} opts.userId - The identifier of the user to filter by
697
+ * @param {string} opts.currency - The currency to filter by, pass undefined to receive data on all currencies
698
+ * @param {number} opts.limit - Amount of deposits per page. Maximum: 50. Default: 50
699
+ * @param {number} opts.page - Page of deposit data. Default: 1
700
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
701
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
702
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
703
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
704
+ * @param {boolean} opts.status - Confirmed status of the deposits to get. Leave blank to get all confirmed and unconfirmed deposits
705
+ * @param {boolean} opts.dismissed - Dismissed status of the deposits to get. Leave blank to get all dismissed and undismissed deposits
706
+ * @param {boolean} opts.rejected - Rejected status of the deposits to get. Leave blank to get all rejected and unrejected deposits
707
+ * @param {boolean} opts.processing - Processing status of the deposits to get. Leave blank to get all processing and unprocessing deposits
708
+ * @param {boolean} opts.waiting - Waiting status of the deposits to get. Leave blank to get all waiting and unwaiting deposits
709
+ * @param {string} opts.transactionId - Deposits with specific transaction ID.
710
+ * @param {string} opts.address - Deposits with specific address.
711
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
712
+ * @return {object} A JSON object with the keys count(total number of user's deposits) and data(array of deposits as objects with keys id(number), type(string), amount(number), transaction_id(string), currency(string), created_at(string), status(boolean), fee(number), dismissed(boolean), rejected(boolean), description(string))
713
+ */
714
+ getExchangeDeposits(
715
+ opts = {
716
+ userId: null,
717
+ currency: null,
718
+ limit: null,
719
+ page: null,
720
+ orderBy: null,
721
+ order: null,
722
+ startDate: null,
723
+ endDate: null,
724
+ status: null,
725
+ dismissed: null,
726
+ rejected: null,
727
+ processing: null,
728
+ waiting: null,
729
+ transactionId: null,
730
+ address: null,
731
+ format: null
732
+ }
733
+ ) {
734
+ const verb = 'GET';
735
+ let path = `${this.baseUrl}/admin/deposits?`;
736
+
737
+
738
+ if (isNumber(opts.userId)) {
739
+ path += `&user_id=${opts.userId}`;
740
+ }
741
+
742
+ if (isString(opts.currency)) {
743
+ path += `&currency=${opts.currency}`;
744
+ }
745
+
746
+ if (isNumber(opts.limit)) {
747
+ path += `&limit=${opts.limit}`;
748
+ }
749
+
750
+ if (isNumber(opts.page)) {
751
+ path += `&page=${opts.page}`;
752
+ }
753
+
754
+ if (isString(opts.orderBy)) {
755
+ path += `&order_by=${opts.orderBy}`;
756
+ }
757
+
758
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
759
+ path += `&order=${opts.order}`;
760
+ }
761
+
762
+ if (isDatetime(opts.startDate)) {
763
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
764
+ }
765
+
766
+ if (isDatetime(opts.endDate)) {
767
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
768
+ }
769
+
770
+ if (isBoolean(opts.status)) {
771
+ path += `&status=${opts.status}`;
772
+ }
773
+
774
+ if (isBoolean(opts.dismissed)) {
775
+ path += `&dismissed=${opts.dismissed}`;
776
+ }
777
+
778
+ if (isBoolean(opts.rejected)) {
779
+ path += `&rejected=${opts.rejected}`;
780
+ }
781
+
782
+ if (isBoolean(opts.processing)) {
783
+ path += `&processing=${opts.processing}`;
784
+ }
785
+
786
+ if (isBoolean(opts.waiting)) {
787
+ path += `&waiting=${opts.waiting}`;
788
+ }
789
+
790
+ if (isString(opts.transactionId)) {
791
+ path += `&transaction_id=${opts.transactionId}`;
792
+ }
793
+
794
+ if (isString(opts.address)) {
795
+ path += `&address=${opts.address}`;
796
+ }
797
+
798
+ if (isString(opts.format) && opts.format === 'csv') {
799
+ path += `&format=${opts.format}`;
800
+ }
801
+
802
+ const headers = generateHeaders(
803
+ this.headers,
804
+ this.apiSecret,
805
+ verb,
806
+ path,
807
+ this.apiExpiresAfter
808
+ );
809
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
810
+ }
811
+
812
+ /**
813
+ * Retrieve list of the user's withdrawals by admin
814
+ * @param {object} opts - Optional parameters
815
+ * @param {number} opts.userId - The identifier of the user to filter by
816
+ * @param {string} opts.currency - The currency to filter by, pass undefined to receive data on all currencies
817
+ * @param {boolean} opts.status - Confirmed status of the withdrawals to get. Leave blank to get all confirmed and unconfirmed withdrawals
818
+ * @param {boolean} opts.dismissed - Dismissed status of the withdrawals to get. Leave blank to get all dismissed and undismissed withdrawals
819
+ * @param {boolean} opts.rejected - Rejected status of the withdrawals to get. Leave blank to get all rejected and unrejected withdrawals
820
+ * @param {boolean} opts.processing - Processing status of the withdrawals to get. Leave blank to get all processing and unprocessing withdrawals
821
+ * @param {boolean} opts.waiting - Waiting status of the withdrawals to get. Leave blank to get all waiting and unwaiting withdrawals
822
+ * @param {number} opts.limit - Amount of withdrawals per page. Maximum: 50. Default: 50
823
+ * @param {number} opts.page - Page of withdrawal data. Default: 1
824
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
825
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
826
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
827
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
828
+ * @param {string} opts.transactionId - Withdrawals with specific transaction ID.
829
+ * @param {string} opts.address - Withdrawals with specific address.
830
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
831
+ * @return {object} A JSON object with the keys count(total number of user's withdrawals) and data(array of withdrawals as objects with keys id(number), type(string), amount(number), transaction_id(string), currency(string), created_at(string), status(boolean), fee(number), dismissed(boolean), rejected(boolean), description(string))
832
+ */
833
+ getExchangeWithdrawals(
834
+ opts = {
835
+ currency: null,
836
+ userId: null,
837
+ transactionId: null,
838
+ address: null,
839
+ limit: null,
840
+ page: null,
841
+ orderBy: null,
842
+ order: null,
843
+ startDate: null,
844
+ endDate: null,
845
+ status: null,
846
+ dismissed: null,
847
+ rejected: null,
848
+ processing: null,
849
+ waiting: null,
850
+ format: null
851
+ }
852
+ ) {
853
+ const verb = 'GET';
854
+ let path = `${this.baseUrl}/admin/withdrawals?`;
855
+
856
+ if (isString(opts.currency)) {
857
+ path += `&currency=${opts.currency}`;
858
+ }
859
+
860
+ if (isNumber(opts.userId)) {
861
+ path += `&user_id=${opts.userId}`;
862
+ }
863
+
864
+ if (isString(opts.transactionId)) {
865
+ path += `&transaction_id=${opts.transactionId}`;
866
+ }
867
+
868
+ if (isString(opts.address)) {
869
+ path += `&address=${opts.address}`;
870
+ }
871
+
872
+ if (isNumber(opts.limit)) {
873
+ path += `&limit=${opts.limit}`;
874
+ }
875
+
876
+ if (isNumber(opts.page)) {
877
+ path += `&page=${opts.page}`;
878
+ }
879
+
880
+ if (isString(opts.orderBy)) {
881
+ path += `&order_by=${opts.orderBy}`;
882
+ }
883
+
884
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
885
+ path += `&order=${opts.order}`;
886
+ }
887
+
888
+ if (isDatetime(opts.startDate)) {
889
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
890
+ }
891
+
892
+ if (isDatetime(opts.endDate)) {
893
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
894
+ }
895
+
896
+ if (isBoolean(opts.status)) {
897
+ path += `&status=${opts.status}`;
898
+ }
899
+
900
+ if (isBoolean(opts.dismissed)) {
901
+ path += `&dismissed=${opts.dismissed}`;
902
+ }
903
+
904
+ if (isBoolean(opts.rejected)) {
905
+ path += `&rejected=${opts.rejected}`;
906
+ }
907
+
908
+ if (isBoolean(opts.processing)) {
909
+ path += `&processing=${opts.processing}`;
910
+ }
911
+
912
+ if (isBoolean(opts.waiting)) {
913
+ path += `&waiting=${opts.waiting}`;
914
+ }
915
+
916
+ if (isString(opts.format) && opts.format === 'csv') {
917
+ path += `&format=${opts.format}`;
918
+ }
919
+
920
+ const headers = generateHeaders(
921
+ this.headers,
922
+ this.apiSecret,
923
+ verb,
924
+ path,
925
+ this.apiExpiresAfter
926
+ );
927
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
928
+ }
929
+
930
+ /**
931
+ * Retrieve admin's wallet balance
932
+ * @return {object} A JSON object with the keys updated_at(string), usdt_balance(number), usdt_pending(number), usdt_available(number), hex_balance, hex_pending, hex_available, eth_balance, eth_pending, eth_available, bch_balance, bch_pending, bch_available
933
+ */
934
+ getExchangeBalance() {
935
+ const verb = 'GET';
936
+ let path = `${this.baseUrl}/admin/balance`;
937
+ const headers = generateHeaders(
938
+ this.headers,
939
+ this.apiSecret,
940
+ verb,
941
+ path,
942
+ this.apiExpiresAfter
943
+ );
944
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
945
+ }
946
+
947
+ /**
948
+ * Transfer exchange asset by admin
949
+ * @param {number} senderId - The identifier of the sender
950
+ * @param {number} receiverId - The identifier of the receiver
951
+ * @param {string} currency - The currency to specify
952
+ * @param {number} amount - The amount to specify
953
+ * @param {string} opts.description - The description field
954
+ * @param {boolean} opts.email - The email field
955
+ * @return {object} A JSON object with transfer info
956
+ */
957
+ transferExchangeAsset(
958
+ senderId,
959
+ receiverId,
960
+ currency,
961
+ amount,
962
+ opts = {
963
+ description: null,
964
+ email: null
965
+ }
966
+ ) {
967
+ const verb = 'POST';
968
+ let path = `${this.baseUrl}/admin/transfer?`;
969
+ const data = {
970
+ sender_id: senderId,
971
+ receiver_id: receiverId,
972
+ currency,
973
+ amount
974
+ };
975
+
976
+
977
+ if (isString(opts.description)) {
978
+ data.description = opts.description;
979
+ }
980
+
981
+ if (isBoolean(opts.email)) {
982
+ data.email = opts.email;
983
+ }
984
+
985
+ const headers = generateHeaders(
986
+ this.headers,
987
+ this.apiSecret,
988
+ verb,
989
+ path,
990
+ this.apiExpiresAfter,
991
+ data
992
+ );
993
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
994
+ }
995
+
996
+ /**
997
+ * Create exchange deposit by admin
998
+ * @param {number} userId - The identifier of the user
999
+ * @param {string} currency - The currency to specify
1000
+ * @param {number} amount - The amount to specify
1001
+ * @param {string} opts.transactionId - deposit with specific transaction ID.
1002
+ * @param {boolean} opts.status - The status field to confirm the deposit
1003
+ * @param {boolean} opts.email - The email field
1004
+ * @param {number} opts.fee - The fee to specify
1005
+ * @return {object} A JSON object with deposit info
1006
+ */
1007
+ createExchangeDeposit(
1008
+ userId,
1009
+ currency,
1010
+ amount,
1011
+ opts = {
1012
+ transactionId: null,
1013
+ status: null,
1014
+ email: null,
1015
+ fee: null
1016
+ }
1017
+ ) {
1018
+ const verb = 'POST';
1019
+ let path = `${this.baseUrl}/admin/mint`;
1020
+ const data = {
1021
+ user_id: userId,
1022
+ currency,
1023
+ amount
1024
+ };
1025
+
1026
+
1027
+ if (isString(opts.transactionId)) {
1028
+ data.transaction_id = opts.transactionId;
1029
+ }
1030
+
1031
+ if (isBoolean(opts.status)) {
1032
+ data.status = opts.status;
1033
+ }
1034
+
1035
+ if (isBoolean(opts.email)) {
1036
+ data.email = opts.email;
1037
+ }
1038
+
1039
+ if (isNumber(opts.fee)) {
1040
+ data.fee = opts.fee;
1041
+ }
1042
+
1043
+ const headers = generateHeaders(
1044
+ this.headers,
1045
+ this.apiSecret,
1046
+ verb,
1047
+ path,
1048
+ this.apiExpiresAfter,
1049
+ data
1050
+ );
1051
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1052
+ }
1053
+
1054
+ /**
1055
+ * Update exchange deposit by admin
1056
+ * @param {string} transactionId - Deposits with specific transaction ID.
1057
+ * @param {boolean} opts.updatedTransactionId - Deposits with updated transaction id
1058
+ * @param {boolean} opts.updatedAddress - Deposits with updated address
1059
+ * @param {boolean} opts.status - Confirmed status of the deposits to set.
1060
+ * @param {boolean} opts.dismissed - Dismissed status of the deposits to set.
1061
+ * @param {boolean} opts.rejected - Rejected status of the deposits to set.
1062
+ * @param {boolean} opts.processing - Processing status of the deposits to set.
1063
+ * @param {boolean} opts.waiting - Waiting status of the deposits to set.
1064
+ * @param {boolean} opts.email - Email
1065
+ * @return {object} A JSON object with deposit info
1066
+ */
1067
+ updateExchangeDeposit(
1068
+ transactionId,
1069
+ opts = {
1070
+ updatedTransactionId: null,
1071
+ updatedAddress: null,
1072
+ status: null,
1073
+ rejected: null,
1074
+ dismissed: null,
1075
+ processing: null,
1076
+ waiting: null,
1077
+ email: null,
1078
+ description: null
1079
+ }
1080
+ ) {
1081
+ const verb = 'PUT';
1082
+ let path = `${this.baseUrl}/admin/mint?`;
1083
+ const data = {
1084
+ transaction_id: transactionId
1085
+ };
1086
+
1087
+ if (isString(opts.updatedTransactionId)) {
1088
+ data.updated_transaction_id = opts.updatedTransactionId;
1089
+ }
1090
+
1091
+ if (isString(opts.updatedAddress)) {
1092
+ data.updated_address = opts.updatedAddress;
1093
+ }
1094
+
1095
+ if (isBoolean(opts.status)) {
1096
+ data.status = opts.status;
1097
+ }
1098
+
1099
+ if (isBoolean(opts.rejected)) {
1100
+ data.rejected = opts.rejected;
1101
+ }
1102
+
1103
+ if (isBoolean(opts.dismissed)) {
1104
+ data.dismissed = opts.dismissed;
1105
+ }
1106
+
1107
+ if (isBoolean(opts.processing)) {
1108
+ data.processing = opts.processing;
1109
+ }
1110
+
1111
+ if (isBoolean(opts.waiting)) {
1112
+ data.waiting = opts.waiting;
1113
+ }
1114
+
1115
+ if (isBoolean(opts.email)) {
1116
+ data.email = opts.email;
1117
+ }
1118
+
1119
+ if (isString(opts.description)) {
1120
+ data.description = opts.description;
1121
+ }
1122
+
1123
+ const headers = generateHeaders(
1124
+ this.headers,
1125
+ this.apiSecret,
1126
+ verb,
1127
+ path,
1128
+ this.apiExpiresAfter,
1129
+ data
1130
+ );
1131
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1132
+
1133
+ }
1134
+
1135
+ /**
1136
+ * Create exchange withdrawal by admin
1137
+ * @param {number} userId - The identifier of the user
1138
+ * @param {string} currency - The currency to specify
1139
+ * @param {number} amount - The amount to specify
1140
+ * @param {string} opts.transactionId - Withdrawal with specific transaction ID.
1141
+ * @param {boolean} opts.status - The status field to confirm the withdrawal
1142
+ * @param {boolean} opts.email - The email field
1143
+ * @param {number} opts.fee - The fee to specify
1144
+ * @return {object} A JSON object with withdrawal info
1145
+ */
1146
+ createExchangeWithdrawal(
1147
+ userId,
1148
+ currency,
1149
+ amount,
1150
+ opts = {
1151
+ transactionId: null,
1152
+ status: null,
1153
+ email: null,
1154
+ fee: null
1155
+ }
1156
+ ) {
1157
+ const verb = 'POST';
1158
+ let path = `${this.baseUrl}/admin/burn?`;
1159
+ const data = {
1160
+ user_id: userId,
1161
+ currency,
1162
+ amount
1163
+ };
1164
+
1165
+
1166
+ if (isString(opts.transactionId)) {
1167
+ data.transaction_id = opts.transactionId;
1168
+ }
1169
+
1170
+ if (isBoolean(opts.status)) {
1171
+ data.status = opts.status;
1172
+ }
1173
+
1174
+ if (isBoolean(opts.email)) {
1175
+ data.email = opts.email;
1176
+ }
1177
+
1178
+ if (isNumber(opts.fee)) {
1179
+ data.fee = opts.fee;
1180
+ }
1181
+
1182
+ const headers = generateHeaders(
1183
+ this.headers,
1184
+ this.apiSecret,
1185
+ verb,
1186
+ path,
1187
+ this.apiExpiresAfter,
1188
+ data
1189
+ );
1190
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1191
+ }
1192
+
1193
+ /**
1194
+ * Update Exchange Withdrawal
1195
+ * @param {string} transactionId - Withdrawals with specific transaction ID.
1196
+ * @param {boolean} opts.updatedTransactionId - Withdrawals with updated transaction id
1197
+ * @param {boolean} opts.updatedAddress - Withdrawals with updated address
1198
+ * @param {boolean} opts.status - Confirmed status of the withdrawals to set.
1199
+ * @param {boolean} opts.dismissed - Dismissed status of the withdrawals to set.
1200
+ * @param {boolean} opts.rejected - Rejected status of the withdrawals to set.
1201
+ * @param {boolean} opts.processing - Processing status of the withdrawals to set.
1202
+ * @param {boolean} opts.waiting - Waiting status of the withdrawals to set.
1203
+ * @param {boolean} opts.email - Email
1204
+ * @return {object} A JSON object with withdrawal info
1205
+ */
1206
+ updateExchangeWithdrawal(
1207
+ transactionId,
1208
+ opts = {
1209
+ updatedTransactionId: null,
1210
+ updatedAddress: null,
1211
+ status: null,
1212
+ rejected: null,
1213
+ dismissed: null,
1214
+ processing: null,
1215
+ waiting: null,
1216
+ email: null,
1217
+ description: null
1218
+ }
1219
+ ) {
1220
+ const verb = 'PUT';
1221
+ let path = `${this.baseUrl}/admin/burn?`;
1222
+ const data = {
1223
+ transaction_id: transactionId
1224
+ };
1225
+
1226
+ if (isString(opts.updatedTransactionId)) {
1227
+ data.updated_transaction_id = opts.updatedTransactionId;
1228
+ }
1229
+
1230
+ if (isString(opts.updatedAddress)) {
1231
+ data.updated_address = opts.updatedAddress;
1232
+ }
1233
+
1234
+ if (isBoolean(opts.status)) {
1235
+ data.status = opts.status;
1236
+ }
1237
+
1238
+ if (isBoolean(opts.rejected)) {
1239
+ data.rejected = opts.rejected;
1240
+ }
1241
+
1242
+ if (isBoolean(opts.dismissed)) {
1243
+ data.dismissed = opts.dismissed;
1244
+ }
1245
+
1246
+ if (isBoolean(opts.processing)) {
1247
+ data.processing = opts.processing;
1248
+ }
1249
+
1250
+ if (isBoolean(opts.waiting)) {
1251
+ data.waiting = opts.waiting;
1252
+ }
1253
+
1254
+ if (isBoolean(opts.email)) {
1255
+ data.email = opts.email;
1256
+ }
1257
+
1258
+ if (isString(opts.description)) {
1259
+ data.description = opts.description;
1260
+ }
1261
+
1262
+ const headers = generateHeaders(
1263
+ this.headers,
1264
+ this.apiSecret,
1265
+ verb,
1266
+ path,
1267
+ this.apiExpiresAfter,
1268
+ data
1269
+ );
1270
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1271
+ }
1272
+
1273
+ /**
1274
+ * Check exchange deposit status
1275
+ * @param {number} userId - The identifier of the user
1276
+ * @param {string} currency - The currency to filter by, pass undefined to receive data on all currencies
1277
+ * @param {string} transactionId - Deposits with specific transaction ID.
1278
+ * @param {string} address - Deposits with specific address.
1279
+ * @param {string} network - The network info
1280
+ * @param {string} opts.isTestnet - The info on whether it's a testnet or not
1281
+ * @return {object} A JSON object with deposit status info
1282
+ */
1283
+ checkExchangeDepositStatus(
1284
+ currency,
1285
+ transactionId,
1286
+ address,
1287
+ network,
1288
+ opts = {
1289
+ isTestnet: null
1290
+ }
1291
+ ) {
1292
+ const verb = 'GET';
1293
+ let path = `${this.baseUrl}/admin/check-transaction?`;
1294
+
1295
+ if (isString(currency)) {
1296
+ path += `&currency=${currency}`;
1297
+ }
1298
+
1299
+ if (isString(transactionId)) {
1300
+ path += `&transaction_id=${transactionId}`;
1301
+ }
1302
+
1303
+ if (isString(address)) {
1304
+ path += `&address=${address}`;
1305
+ }
1306
+
1307
+ if (isString(network)) {
1308
+ path += `&network=${network}`;
1309
+ }
1310
+
1311
+ if (isBoolean(opts.isTestnet)) {
1312
+ path += `&is_testnet=${opts.isTestnet}`;
1313
+ }
1314
+ const headers = generateHeaders(
1315
+ this.headers,
1316
+ this.apiSecret,
1317
+ verb,
1318
+ path,
1319
+ this.apiExpiresAfter
1320
+ );
1321
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1322
+ }
1323
+
1324
+ /**
1325
+ * Set exchange fees by admin
1326
+ * @param {number} opts.userId - The identifier of the user
1327
+ * @return {object} A JSON object with message
1328
+ */
1329
+ settleExchangeFees(
1330
+ opts = {
1331
+ userId: null
1332
+ }
1333
+ ) {
1334
+ const verb = 'GET';
1335
+ let path = `${this.baseUrl}/admin/fees/settle`;
1336
+
1337
+ if (isNumber(opts.userId)) {
1338
+ path += `?user_id=${opts.userId}`;
1339
+ }
1340
+
1341
+ const headers = generateHeaders(
1342
+ this.headers,
1343
+ this.apiSecret,
1344
+ verb,
1345
+ path,
1346
+ this.apiExpiresAfter
1347
+ );
1348
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1349
+ }
1350
+
1351
+ /**
1352
+ * Retrieve user's trades by admin
1353
+ * @param {number} opts.userId - The identifier of the user
1354
+ * @param {string} opts.side - The order side (buy or side)
1355
+ * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50
1356
+ * @param {number} opts.page - Page of trades data. Default: 1
1357
+ * @param {string} opts.symbol - The symbol-pair to filter by, pass undefined to receive data on all currencies
1358
+ * @param {string} opts.orderBy - The field to trade data by e.g. amount, id.
1359
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1360
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1361
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1362
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
1363
+ * @return {object} A JSON object with trade info
1364
+ */
1365
+ getExchangeTrades(
1366
+ opts = {
1367
+ userId: null,
1368
+ limit: null,
1369
+ page: null,
1370
+ symbol: null,
1371
+ orderBy: null,
1372
+ order: null,
1373
+ startDate: null,
1374
+ startDate: null,
1375
+ format: null
1376
+ }
1377
+ ) {
1378
+ const verb = 'GET';
1379
+ let path = `${this.baseUrl}/admin/trades?`;
1380
+
1381
+ if (isNumber(opts.userId)) {
1382
+ path += `&user_id=${opts.userId}`;
1383
+ }
1384
+
1385
+ if (isNumber(opts.limit)) {
1386
+ path += `&limit=${opts.limit}`;
1387
+ }
1388
+
1389
+ if (isNumber(opts.page)) {
1390
+ path += `&page=${opts.page}`;
1391
+ }
1392
+
1393
+ if (isString(opts.symbol)) {
1394
+ path += `&symbol=${opts.symbol}`;
1395
+ }
1396
+
1397
+ if (isString(opts.orderBy)) {
1398
+ path += `&order_by=${opts.orderBy}`;
1399
+ }
1400
+
1401
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1402
+ path += `&order=${opts.order}`;
1403
+ }
1404
+
1405
+ if (isDatetime(opts.startDate)) {
1406
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1407
+ }
1408
+
1409
+ if (isDatetime(opts.startDate)) {
1410
+ path += `&end_date=${sanitizeDate(opts.startDate)}`;
1411
+ }
1412
+
1413
+ if (isString(opts.format) && opts.format === 'csv') {
1414
+ path += `&format=${opts.format}`;
1415
+ }
1416
+
1417
+ const headers = generateHeaders(
1418
+ this.headers,
1419
+ this.apiSecret,
1420
+ verb,
1421
+ path,
1422
+ this.apiExpiresAfter
1423
+ );
1424
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1425
+ }
1426
+
1427
+ /**
1428
+ * Retrieve user's orders by admin
1429
+ * @param {number} opts.userId - The identifier of the user
1430
+ * @param {string} opts.side - The order side (buy or side)
1431
+ * @param {string} opts.status - The order's status e.g open, filled, canceled etc
1432
+ * @param {boolean} opts.open - The info on whether the order is active or not
1433
+ * @param {string} opts.side - The order side (buy or side)
1434
+ * @param {number} opts.limit - Amount of orders per page. Maximum: 50. Default: 50
1435
+ * @param {number} opts.page - Page of order data. Default: 1
1436
+ * @param {string} opts.symbol - The symbol-pair to filter by, pass undefined to receive data on all currencies
1437
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1438
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1439
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1440
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1441
+ * @return {object} A JSON object with order info
1442
+ */
1443
+ getExchangeOrders(
1444
+ opts = {
1445
+ userId: null,
1446
+ side: null,
1447
+ status: null,
1448
+ open: null,
1449
+ limit: null,
1450
+ page: null,
1451
+ symbol: null,
1452
+ orderBy: null,
1453
+ order: null,
1454
+ startDate: null,
1455
+ endDate: null
1456
+ }
1457
+ ) {
1458
+ const verb = 'GET';
1459
+ let path = `${this.baseUrl}/admin/orders?`;
1460
+
1461
+ if (isNumber(opts.userId)) {
1462
+ path += `&user_id=${opts.userId}`;
1463
+ }
1464
+
1465
+ if (isString(opts.side) && (opts.side === 'buy' || opts.side === 'sell')) {
1466
+ path += `&side=${opts.side}`;
1467
+ }
1468
+
1469
+ if (isString(opts.status)) {
1470
+ path += `&status=${opts.status}`;
1471
+ }
1472
+
1473
+ if (isBoolean(opts.open)) {
1474
+ path += `&open=${opts.open}`;
1475
+ }
1476
+
1477
+ if (isNumber(opts.limit)) {
1478
+ path += `&limit=${opts.limit}`;
1479
+ }
1480
+
1481
+ if (isNumber(opts.page)) {
1482
+ path += `&page=${opts.page}`;
1483
+ }
1484
+
1485
+ if (isString(opts.symbol)) {
1486
+ path += `&symbol=${opts.symbol}`;
1487
+ }
1488
+
1489
+ if (isString(opts.orderBy)) {
1490
+ path += `&order_by=${opts.orderBy}`;
1491
+ }
1492
+
1493
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1494
+ path += `&order=${opts.order}`;
1495
+ }
1496
+
1497
+ if (isDatetime(opts.startDate)) {
1498
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1499
+ }
1500
+
1501
+ if (isDatetime(opts.endDate)) {
1502
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
1503
+ }
1504
+
1505
+ const headers = generateHeaders(
1506
+ this.headers,
1507
+ this.apiSecret,
1508
+ verb,
1509
+ path,
1510
+ this.apiExpiresAfter
1511
+ );
1512
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1513
+ }
1514
+
1515
+ /**
1516
+ * Cancel user's order by order id
1517
+ * @param {number} userId - The identifier of the user
1518
+ * @param {string} orderId - The identifier of the order
1519
+ * @return {object} A JSON object with message
1520
+ */
1521
+ cancelExchangeUserOrder(userId, orderId) {
1522
+ const verb = 'DELETE';
1523
+ let path = `${this.baseUrl}/admin/order?`;
1524
+
1525
+ if (isString(orderId)) {
1526
+ path += `&order_id=${orderId}`;
1527
+ }
1528
+
1529
+ if (isNumber(userId)) {
1530
+ path += `&user_id=${userId}`;
1531
+ }
1532
+ const headers = generateHeaders(
1533
+ this.headers,
1534
+ this.apiSecret,
1535
+ verb,
1536
+ path,
1537
+ this.apiExpiresAfter
1538
+ );
1539
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1540
+ }
1541
+
1542
+ /**
1543
+ * Retrieve list of the user info by admin
1544
+ * @param {object} opts - Optional parameters
1545
+ * @param {number} opts.userId - The identifier of the user to filter by
1546
+ * @param {string} opts.search - The search text to filter by, pass undefined to receive data on all fields
1547
+ * @param {boolean} opts.pending - The pending field to filter by, pass undefined to receive all data
1548
+ * @param {string} opts.pendingType - Th pending type info to filter by, pass undefined to receive data
1549
+ * @param {number} opts.limit - Amount of users per page. Maximum: 50. Default: 50
1550
+ * @param {number} opts.page - Page of user data. Default: 1
1551
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1552
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1553
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1554
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1555
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
1556
+ * @return {object} A JSON object with user data
1557
+ */
1558
+ getExchangeUsers(
1559
+ opts = {
1560
+ userId: null,
1561
+ search: null,
1562
+ type: null,
1563
+ pending: null,
1564
+ pendingType: null,
1565
+ limit: null,
1566
+ page: null,
1567
+ orderBy: null,
1568
+ order: null,
1569
+ startDate: null,
1570
+ endDate: null,
1571
+ format: null
1572
+ }
1573
+ ) {
1574
+ const verb = 'GET';
1575
+ let path = `${this.baseUrl}/admin/users?`;
1576
+
1577
+ if (isNumber(opts.userId)) {
1578
+ path += `&id=${opts.userId}`;
1579
+ }
1580
+
1581
+ if (isString(opts.search)) {
1582
+ path += `&search=${opts.search}`;
1583
+ }
1584
+
1585
+ if (isString(opts.type)) {
1586
+ path += `&type=${opts.type}`;
1587
+ }
1588
+
1589
+ if (isBoolean(opts.pending)) {
1590
+ path += `&pending=${opts.pending}`;
1591
+ }
1592
+
1593
+ if (isString(opts.pendingType) && (opts.pendingType === 'id' ||opts.pendingType === 'bank')) {
1594
+ path += `&pending_type=${opts.pendingType}`;
1595
+ }
1596
+
1597
+ if (isNumber(opts.limit)) {
1598
+ path += `&limit=${opts.limit}`;
1599
+ }
1600
+
1601
+ if (isNumber(opts.page)) {
1602
+ path += `&page=${opts.page}`;
1603
+ }
1604
+
1605
+ if (isString(opts.orderBy)) {
1606
+ path += `&order_by=${opts.orderBy}`;
1607
+ }
1608
+
1609
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1610
+ path += `&order=${opts.order}`;
1611
+ }
1612
+
1613
+ if (isDatetime(opts.startDate)) {
1614
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1615
+ }
1616
+
1617
+ if (isDatetime(opts.endDate)) {
1618
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
1619
+ }
1620
+
1621
+ if (isString(opts.format) && opts.format === 'csv') {
1622
+ path += `&format=${opts.format}`;
1623
+ }
1624
+
1625
+ const headers = generateHeaders(
1626
+ this.headers,
1627
+ this.apiSecret,
1628
+ verb,
1629
+ path,
1630
+ this.apiExpiresAfter
1631
+ );
1632
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1633
+ }
1634
+
1635
+ /**
1636
+ * Create exchange user
1637
+ * @param {string} email - The mail address for the user
1638
+ * @param {string} password - The password for the user
1639
+ * @return {object} A JSON object with message
1640
+ */
1641
+ createExchangeUser(email, password) {
1642
+ const verb = 'POST';
1643
+ let path = `${this.baseUrl}/admin/user`;
1644
+ const data = {
1645
+ email,
1646
+ password
1647
+ };
1648
+
1649
+ const headers = generateHeaders(
1650
+ this.headers,
1651
+ this.apiSecret,
1652
+ verb,
1653
+ path,
1654
+ this.apiExpiresAfter,
1655
+ data
1656
+ );
1657
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1658
+ }
1659
+
1660
+ /**
1661
+ * Update exchange user
1662
+ * @param {number} userId - The identifier of the user to filter by
1663
+ * @param {object} opts.meta - The field to update user meta info
1664
+ * @param {boolean} opts.overwrite - the field to set overwrite option along with meta object
1665
+ * @param {string} opts.role - The field to update user role ('admin', 'supervisor', 'support', 'kyc', 'communicator', 'user')
1666
+ * @param {string} opts.note - The field to update user note
1667
+ * @param {number} opts.verification_level - The field to set user's verification level
1668
+ * @return {object} A JSON object with user data
1669
+ */
1670
+ updateExchangeUser(
1671
+ userId,
1672
+ opts = {
1673
+ role: null,
1674
+ meta: null,
1675
+ overwrite: null,
1676
+ discount: null,
1677
+ note: null,
1678
+ verification_level: null
1679
+ },
1680
+
1681
+ ) {
1682
+ if (isString(opts.role)
1683
+ && ['admin', 'supervisor', 'support', 'kyc', 'communicator', 'user'].includes(opts.role)) {
1684
+
1685
+ const verb = 'PUT';
1686
+ let path = `${this.baseUrl}/admin/user/role`;
1687
+
1688
+ if (isNumber(userId)) {
1689
+ path += `?user_id=${userId}`;
1690
+ }
1691
+ const data = {
1692
+ role: opts.role
1693
+ };
1694
+
1695
+ const headers = generateHeaders(
1696
+ this.headers,
1697
+ this.apiSecret,
1698
+ verb,
1699
+ path,
1700
+ this.apiExpiresAfter,
1701
+ data
1702
+ );
1703
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1704
+ }
1705
+
1706
+ if(isObject(opts.meta)){
1707
+ const verb = 'PUT';
1708
+ let path = `${this.baseUrl}/admin/user/meta`;
1709
+
1710
+ if (isNumber(userId)) {
1711
+ path += `?user_id=${userId}`;
1712
+ }
1713
+
1714
+ const data = {
1715
+ meta: opts.meta,
1716
+ ...(isBoolean(opts.overwrite) && { overwrite: opts.overwrite }),
1717
+ };
1718
+
1719
+ const headers = generateHeaders(
1720
+ this.headers,
1721
+ this.apiSecret,
1722
+ verb,
1723
+ path,
1724
+ this.apiExpiresAfter,
1725
+ data
1726
+ );
1727
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1728
+ }
1729
+
1730
+ if(isNumber(opts.discount) && opts.discount <= 100 && opts.discount >= 0){
1731
+ const verb = 'PUT';
1732
+ let path = `${this.baseUrl}/admin/user/discount`;
1733
+
1734
+ if (isNumber(userId)) {
1735
+ path += `?user_id=${userId}`;
1736
+ }
1737
+
1738
+ const data = {
1739
+ discount: opts.discount
1740
+ };
1741
+
1742
+ const headers = generateHeaders(
1743
+ this.headers,
1744
+ this.apiSecret,
1745
+ verb,
1746
+ path,
1747
+ this.apiExpiresAfter,
1748
+ data
1749
+ );
1750
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1751
+ }
1752
+
1753
+ if(isString(opts.note)){
1754
+ const verb = 'PUT';
1755
+ let path = `${this.baseUrl}/admin/user/note`;
1756
+
1757
+ if (isNumber(userId)) {
1758
+ path += `?user_id=${userId}`;
1759
+ }
1760
+
1761
+ const data = {
1762
+ note: opts.note
1763
+ };
1764
+
1765
+ const headers = generateHeaders(
1766
+ this.headers,
1767
+ this.apiSecret,
1768
+ verb,
1769
+ path,
1770
+ this.apiExpiresAfter,
1771
+ data
1772
+ );
1773
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1774
+ }
1775
+
1776
+ if(isNumber(opts.verification_level)){
1777
+ const verb = 'POST';
1778
+ let path = `${this.baseUrl}/admin/upgrade-user`;
1779
+
1780
+ const data = {
1781
+ user_id: userId,
1782
+ verification_level: opts.verification_level
1783
+ };
1784
+
1785
+ const headers = generateHeaders(
1786
+ this.headers,
1787
+ this.apiSecret,
1788
+ verb,
1789
+ path,
1790
+ this.apiExpiresAfter,
1791
+ data
1792
+ );
1793
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1794
+ }
1795
+
1796
+ }
1797
+
1798
+ /**
1799
+ * Create wallet for exchange user
1800
+ * @param {number} userId - The identifier of the user
1801
+ * @param {string} crypto - The coin for the wallet e.g btc, eth
1802
+ * @param {string} opts.network - The network info
1803
+ * @return {object} A JSON object with message
1804
+ */
1805
+ createExchangeUserWallet(
1806
+ userId,
1807
+ crypto,
1808
+ opts= {
1809
+ network: null
1810
+ }
1811
+ ) {
1812
+ const verb = 'POST';
1813
+ let path = `${this.baseUrl}/admin/user/wallet`;
1814
+ const data = {
1815
+ user_id: userId,
1816
+ crypto
1817
+ };
1818
+
1819
+ if (isString(opts.network)) {
1820
+ data.network = opts.network;
1821
+ }
1822
+
1823
+ const headers = generateHeaders(
1824
+ this.headers,
1825
+ this.apiSecret,
1826
+ verb,
1827
+ path,
1828
+ this.apiExpiresAfter,
1829
+ data
1830
+ );
1831
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1832
+ }
1833
+
1834
+ /**
1835
+ * Retrieve users' wallets by admin
1836
+ * @param {object} opts - Optional parameters
1837
+ * @param {number} opts.userId - The identifier of the user to filter by
1838
+ * @param {number} opts.limit - Amount of users per page. Maximum: 50. Default: 50
1839
+ * @param {string} opts.currency - The currency to filter by
1840
+ * @param {number} opts.page - Page of user data. Default: 1
1841
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1842
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1843
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1844
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1845
+ * @param {string} opts.address - Address of crypto
1846
+ * @param {boolean} opts.isValid - Specify whether or not wallet is valid
1847
+ * @param {string} opts.network - Crypto network of currency
1848
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
1849
+ * @return {object} A JSON object with user data
1850
+ *
1851
+ */
1852
+ getExchangeUserWallet(
1853
+ opts = {
1854
+ userId: null,
1855
+ limit: null,
1856
+ page: null,
1857
+ currency: null,
1858
+ orderBy: null,
1859
+ order: null,
1860
+ startDate: null,
1861
+ endDate: null,
1862
+ address: null,
1863
+ isValid: null,
1864
+ network: null,
1865
+ format: null
1866
+ }
1867
+ ) {
1868
+ const verb = 'GET';
1869
+ let path = `${this.baseUrl}/admin/user/wallet?`;
1870
+
1871
+ if (isNumber(opts.userId)) {
1872
+ path += `&user_id=${opts.userId}`;
1873
+ }
1874
+
1875
+ if (isString(opts.currency)) {
1876
+ path += `&currency=${opts.currency}`;
1877
+ }
1878
+
1879
+ if (isString(opts.address)) {
1880
+ path += `&address=${opts.address}`;
1881
+ }
1882
+
1883
+ if (isString(opts.network)) {
1884
+ path += `&network=${opts.network}`;
1885
+ }
1886
+
1887
+ if (isBoolean(opts.isValid)) {
1888
+ path += `&is_valid=${opts.isValid}`;
1889
+ }
1890
+
1891
+ if (isNumber(opts.limit)) {
1892
+ path += `&limit=${opts.limit}`;
1893
+ }
1894
+
1895
+ if (isNumber(opts.page)) {
1896
+ path += `&page=${opts.page}`;
1897
+ }
1898
+
1899
+ if (isString(opts.orderBy)) {
1900
+ path += `&order_by=${opts.orderBy}`;
1901
+ }
1902
+
1903
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1904
+ path += `&order=${opts.order}`;
1905
+ }
1906
+
1907
+ if (isDatetime(opts.startDate)) {
1908
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1909
+ }
1910
+
1911
+ if (isDatetime(opts.endDate)) {
1912
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
1913
+ }
1914
+
1915
+ if (isString(opts.format) && opts.format === 'csv') {
1916
+ path += `&format=${opts.format}`;
1917
+ }
1918
+
1919
+ const headers = generateHeaders(
1920
+ this.headers,
1921
+ this.apiSecret,
1922
+ verb,
1923
+ path,
1924
+ this.apiExpiresAfter
1925
+ );
1926
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1927
+ }
1928
+
1929
+ /**
1930
+ * Retrieve user's login info by admin
1931
+ * @param {number} userId - The identifier of the user
1932
+ * @return {object} A JSON object with user balance
1933
+ */
1934
+ getExchangeUserBalance(userId) {
1935
+ const verb = 'GET';
1936
+ let path = `${this.baseUrl}/admin/user/balance?user_id=${userId}`;
1937
+
1938
+ const headers = generateHeaders(
1939
+ this.headers,
1940
+ this.apiSecret,
1941
+ verb,
1942
+ path,
1943
+ this.apiExpiresAfter
1944
+ );
1945
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1946
+ }
1947
+
1948
+ /**
1949
+ * Create bank account for user by admin
1950
+ * @param {number} userId - The identifier of the user
1951
+ * @param {object} bankAccount - Array of objects with bank account info
1952
+ * @return {object} A JSON object with bank account info
1953
+ */
1954
+ createExchangeUserBank(userId, bankAccount) {
1955
+ const verb = 'POST';
1956
+ let path = `${this.baseUrl}/admin/user/bank`;
1957
+
1958
+ if (isNumber(userId)) {
1959
+ path += `?id=${userId}`;
1960
+ }
1961
+
1962
+ const data = {
1963
+ bank_account: bankAccount
1964
+ };
1965
+
1966
+ const headers = generateHeaders(
1967
+ this.headers,
1968
+ this.apiSecret,
1969
+ verb,
1970
+ path,
1971
+ this.apiExpiresAfter,
1972
+ data
1973
+ );
1974
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1975
+
1976
+ }
1977
+
1978
+ /**
1979
+ * Retrieve user's login info by admin
1980
+ * @param {number} opts.userId - The identifier of the user
1981
+ * @param {number} opts.limit - Amount of logins per page. Maximum: 50. Default: 50
1982
+ * @param {number} opts.page - Page of referral data. Default: 1
1983
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1984
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1985
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1986
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1987
+ * @return {object} A JSON object with login info
1988
+ */
1989
+ getExchangeUserLogins(
1990
+ opts = {
1991
+ userId: null,
1992
+ limit: null,
1993
+ page: null,
1994
+ orderBy: null,
1995
+ order: null,
1996
+ startDate: null,
1997
+ endDate: null,
1998
+ format: null
1999
+ }
2000
+ ) {
2001
+ const verb = 'GET';
2002
+ let path = `${this.baseUrl}/admin/logins?`;
2003
+
2004
+ if (isNumber(opts.userId)) {
2005
+ path += `&user_id=${opts.userId}`;
2006
+ }
2007
+
2008
+ if (isNumber(opts.limit)) {
2009
+ path += `&limit=${opts.limit}`;
2010
+ }
2011
+
2012
+ if (isNumber(opts.page)) {
2013
+ path += `&page=${opts.page}`;
2014
+ }
2015
+
2016
+ if (isString(opts.orderBy)) {
2017
+ path += `&order_by=${opts.orderBy}`;
2018
+ }
2019
+
2020
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2021
+ path += `&order=${opts.order}`;
2022
+ }
2023
+
2024
+ if (isDatetime(opts.startDate)) {
2025
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
2026
+ }
2027
+
2028
+ if (isDatetime(opts.endDate)) {
2029
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
2030
+ }
2031
+
2032
+ if (isString(opts.format) && opts.format === 'csv') {
2033
+ path += `&format=${opts.format}`;
2034
+ }
2035
+
2036
+ const headers = generateHeaders(
2037
+ this.headers,
2038
+ this.apiSecret,
2039
+ verb,
2040
+ path,
2041
+ this.apiExpiresAfter
2042
+ );
2043
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2044
+ }
2045
+
2046
+ /**
2047
+ * Deactivate exchange user account by admin
2048
+ * @param {number} userId - The identifier of the user to deactivate their exchange account
2049
+ * @return {object} A JSON object with message
2050
+ */
2051
+ deactivateExchangeUser(userId) {
2052
+ const verb = 'POST';
2053
+ let path = `${this.baseUrl}/admin/user/activate`;
2054
+ const data = {
2055
+ user_id: userId,
2056
+ activated: false
2057
+ };
2058
+
2059
+ const headers = generateHeaders(
2060
+ this.headers,
2061
+ this.apiSecret,
2062
+ verb,
2063
+ path,
2064
+ this.apiExpiresAfter,
2065
+ data
2066
+ );
2067
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2068
+ }
2069
+
2070
+ /**
2071
+ * Deactivate user otp by admin
2072
+ * @param {number} userId - The identifier of the user to deactivate their otp
2073
+ * @return {object} A JSON object with message
2074
+ */
2075
+ deactivateExchangeUserOtp(userId) {
2076
+ const verb = 'POST';
2077
+ let path = `${this.baseUrl}/admin/deactivate-otp`;
2078
+ const data = {
2079
+ user_id: userId
2080
+ };
2081
+
2082
+ const headers = generateHeaders(
2083
+ this.headers,
2084
+ this.apiSecret,
2085
+ verb,
2086
+ path,
2087
+ this.apiExpiresAfter,
2088
+ data
2089
+ );
2090
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2091
+ }
2092
+
2093
+ /**
2094
+ * Retrieve user's referrals info by admin
2095
+ * @param {number} userId - The identifier of the user to filter by
2096
+ * @param {number} opts.limit - Amount of referrals per page. Maximum: 50. Default: 50
2097
+ * @param {number} opts.page - Page of referral data. Default: 1
2098
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
2099
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
2100
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
2101
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
2102
+ * @return {object} A JSON object with referral info
2103
+ */
2104
+ getExchangeUserReferrals(
2105
+ userId = null,
2106
+ opts = {
2107
+ limit: null,
2108
+ page: null,
2109
+ orderBy: null,
2110
+ order: null,
2111
+ startDate: null,
2112
+ endDate: null
2113
+ }
2114
+ ) {
2115
+ const verb = 'GET';
2116
+ let path = `${this.baseUrl}/admin/user/affiliation?`;
2117
+
2118
+
2119
+ if (isNumber(userId)) {
2120
+ path += `&user_id=${userId}`;
2121
+ }
2122
+
2123
+ if (isNumber(opts.limit)) {
2124
+ path += `&limit=${opts.limit}`;
2125
+ }
2126
+
2127
+ if (isNumber(opts.page)) {
2128
+ path += `&page=${opts.page}`;
2129
+ }
2130
+
2131
+ if (isString(opts.orderBy)) {
2132
+ path += `&order_by=${opts.orderBy}`;
2133
+ }
2134
+
2135
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2136
+ path += `&order=${opts.order}`;
2137
+ }
2138
+
2139
+ if (isDatetime(opts.startDate)) {
2140
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
2141
+ }
2142
+
2143
+ if (isDatetime(opts.endDate)) {
2144
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
2145
+ }
2146
+
2147
+
2148
+ const headers = generateHeaders(
2149
+ this.headers,
2150
+ this.apiSecret,
2151
+ verb,
2152
+ path,
2153
+ this.apiExpiresAfter
2154
+ );
2155
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2156
+ }
2157
+
2158
+ /**
2159
+ * Retrieve user's referer info by admin
2160
+ * @param {number} userId - The identifier of the user to filter by
2161
+ * @return {object} A JSON object with referrer info
2162
+ */
2163
+ getExchangeUserReferrer(userId) {
2164
+ const verb = 'GET';
2165
+ let path = `${this.baseUrl}/admin/user/referer?user_id=${userId}`;
2166
+ const headers = generateHeaders(
2167
+ this.headers,
2168
+ this.apiSecret,
2169
+ verb,
2170
+ path,
2171
+ this.apiExpiresAfter
2172
+ );
2173
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2174
+ }
2175
+
2176
+
675
2177
  /**
676
2178
  * Connect to hollaEx websocket and listen to an event
677
2179
  * @param {array} events - The events to listen to
@@ -816,6 +2318,8 @@ class HollaExKit {
816
2318
  case 'usertrade':
817
2319
  case 'wallet':
818
2320
  case 'deposit':
2321
+ case 'withdrawal':
2322
+ case 'admin':
819
2323
  this.ws.send(
820
2324
  JSON.stringify({
821
2325
  op: 'subscribe',
@@ -868,6 +2372,8 @@ class HollaExKit {
868
2372
  case 'order':
869
2373
  case 'wallet':
870
2374
  case 'deposit':
2375
+ case 'withdrawal':
2376
+ case 'admin':
871
2377
  this.ws.send(
872
2378
  JSON.stringify({
873
2379
  op: 'unsubscribe',