hollaex-node-lib 2.14.1 → 2.15.1

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,1507 @@ 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
+ format: null
1375
+ }
1376
+ ) {
1377
+ const verb = 'GET';
1378
+ let path = `${this.baseUrl}/admin/trades?`;
1379
+
1380
+ if (isNumber(opts.userId)) {
1381
+ path += `&user_id=${opts.userId}`;
1382
+ }
1383
+
1384
+ if (isNumber(opts.limit)) {
1385
+ path += `&limit=${opts.limit}`;
1386
+ }
1387
+
1388
+ if (isNumber(opts.page)) {
1389
+ path += `&page=${opts.page}`;
1390
+ }
1391
+
1392
+ if (isString(opts.symbol)) {
1393
+ path += `&symbol=${opts.symbol}`;
1394
+ }
1395
+
1396
+ if (isString(opts.orderBy)) {
1397
+ path += `&order_by=${opts.orderBy}`;
1398
+ }
1399
+
1400
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1401
+ path += `&order=${opts.order}`;
1402
+ }
1403
+
1404
+ if (isDatetime(opts.startDate)) {
1405
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1406
+ }
1407
+
1408
+ if (isDatetime(opts.startDate)) {
1409
+ path += `&end_date=${sanitizeDate(opts.startDate)}`;
1410
+ }
1411
+
1412
+ if (isString(opts.format) && opts.format === 'csv') {
1413
+ path += `&format=${opts.format}`;
1414
+ }
1415
+
1416
+ const headers = generateHeaders(
1417
+ this.headers,
1418
+ this.apiSecret,
1419
+ verb,
1420
+ path,
1421
+ this.apiExpiresAfter
1422
+ );
1423
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1424
+ }
1425
+
1426
+ /**
1427
+ * Retrieve user's orders by admin
1428
+ * @param {number} opts.userId - The identifier of the user
1429
+ * @param {string} opts.side - The order side (buy or side)
1430
+ * @param {string} opts.status - The order's status e.g open, filled, canceled etc
1431
+ * @param {boolean} opts.open - The info on whether the order is active or not
1432
+ * @param {string} opts.side - The order side (buy or side)
1433
+ * @param {number} opts.limit - Amount of orders per page. Maximum: 50. Default: 50
1434
+ * @param {number} opts.page - Page of order data. Default: 1
1435
+ * @param {string} opts.symbol - The symbol-pair to filter by, pass undefined to receive data on all currencies
1436
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1437
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1438
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1439
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1440
+ * @return {object} A JSON object with order info
1441
+ */
1442
+ getExchangeOrders(
1443
+ opts = {
1444
+ userId: null,
1445
+ side: null,
1446
+ status: null,
1447
+ open: null,
1448
+ limit: null,
1449
+ page: null,
1450
+ symbol: null,
1451
+ orderBy: null,
1452
+ order: null,
1453
+ startDate: null,
1454
+ endDate: null
1455
+ }
1456
+ ) {
1457
+ const verb = 'GET';
1458
+ let path = `${this.baseUrl}/admin/orders?`;
1459
+
1460
+ if (isNumber(opts.userId)) {
1461
+ path += `&user_id=${opts.userId}`;
1462
+ }
1463
+
1464
+ if (isString(opts.side) && (opts.side === 'buy' || opts.side === 'sell')) {
1465
+ path += `&side=${opts.side}`;
1466
+ }
1467
+
1468
+ if (isString(opts.status)) {
1469
+ path += `&status=${opts.status}`;
1470
+ }
1471
+
1472
+ if (isBoolean(opts.open)) {
1473
+ path += `&open=${opts.open}`;
1474
+ }
1475
+
1476
+ if (isNumber(opts.limit)) {
1477
+ path += `&limit=${opts.limit}`;
1478
+ }
1479
+
1480
+ if (isNumber(opts.page)) {
1481
+ path += `&page=${opts.page}`;
1482
+ }
1483
+
1484
+ if (isString(opts.symbol)) {
1485
+ path += `&symbol=${opts.symbol}`;
1486
+ }
1487
+
1488
+ if (isString(opts.orderBy)) {
1489
+ path += `&order_by=${opts.orderBy}`;
1490
+ }
1491
+
1492
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1493
+ path += `&order=${opts.order}`;
1494
+ }
1495
+
1496
+ if (isDatetime(opts.startDate)) {
1497
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1498
+ }
1499
+
1500
+ if (isDatetime(opts.endDate)) {
1501
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
1502
+ }
1503
+
1504
+ const headers = generateHeaders(
1505
+ this.headers,
1506
+ this.apiSecret,
1507
+ verb,
1508
+ path,
1509
+ this.apiExpiresAfter
1510
+ );
1511
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1512
+ }
1513
+
1514
+ /**
1515
+ * Cancel user's order by order id
1516
+ * @param {number} userId - The identifier of the user
1517
+ * @param {string} orderId - The identifier of the order
1518
+ * @return {object} A JSON object with message
1519
+ */
1520
+ cancelExchangeUserOrder(userId, orderId) {
1521
+ const verb = 'DELETE';
1522
+ let path = `${this.baseUrl}/admin/order?`;
1523
+
1524
+ if (isString(orderId)) {
1525
+ path += `&order_id=${orderId}`;
1526
+ }
1527
+
1528
+ if (isNumber(userId)) {
1529
+ path += `&user_id=${userId}`;
1530
+ }
1531
+ const headers = generateHeaders(
1532
+ this.headers,
1533
+ this.apiSecret,
1534
+ verb,
1535
+ path,
1536
+ this.apiExpiresAfter
1537
+ );
1538
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1539
+ }
1540
+
1541
+ /**
1542
+ * Retrieve list of the user info by admin
1543
+ * @param {object} opts - Optional parameters
1544
+ * @param {number} opts.userId - The identifier of the user to filter by
1545
+ * @param {string} opts.search - The search text to filter by, pass undefined to receive data on all fields
1546
+ * @param {boolean} opts.pending - The pending field to filter by, pass undefined to receive all data
1547
+ * @param {string} opts.pendingType - Th pending type info to filter by, pass undefined to receive data
1548
+ * @param {number} opts.limit - Amount of users per page. Maximum: 50. Default: 50
1549
+ * @param {number} opts.page - Page of user data. Default: 1
1550
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1551
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1552
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1553
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1554
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
1555
+ * @return {object} A JSON object with user data
1556
+ */
1557
+ getExchangeUsers(
1558
+ opts = {
1559
+ userId: null,
1560
+ search: null,
1561
+ type: null,
1562
+ pending: null,
1563
+ pendingType: null,
1564
+ limit: null,
1565
+ page: null,
1566
+ orderBy: null,
1567
+ order: null,
1568
+ startDate: null,
1569
+ endDate: null,
1570
+ format: null
1571
+ }
1572
+ ) {
1573
+ const verb = 'GET';
1574
+ let path = `${this.baseUrl}/admin/users?`;
1575
+
1576
+ if (isNumber(opts.userId)) {
1577
+ path += `&id=${opts.userId}`;
1578
+ }
1579
+
1580
+ if (isString(opts.search)) {
1581
+ path += `&search=${opts.search}`;
1582
+ }
1583
+
1584
+ if (isString(opts.type)) {
1585
+ path += `&type=${opts.type}`;
1586
+ }
1587
+
1588
+ if (isBoolean(opts.pending)) {
1589
+ path += `&pending=${opts.pending}`;
1590
+ }
1591
+
1592
+ if (isString(opts.pendingType) && (opts.pendingType === 'id' ||opts.pendingType === 'bank')) {
1593
+ path += `&pending_type=${opts.pendingType}`;
1594
+ }
1595
+
1596
+ if (isNumber(opts.limit)) {
1597
+ path += `&limit=${opts.limit}`;
1598
+ }
1599
+
1600
+ if (isNumber(opts.page)) {
1601
+ path += `&page=${opts.page}`;
1602
+ }
1603
+
1604
+ if (isString(opts.orderBy)) {
1605
+ path += `&order_by=${opts.orderBy}`;
1606
+ }
1607
+
1608
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1609
+ path += `&order=${opts.order}`;
1610
+ }
1611
+
1612
+ if (isDatetime(opts.startDate)) {
1613
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1614
+ }
1615
+
1616
+ if (isDatetime(opts.endDate)) {
1617
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
1618
+ }
1619
+
1620
+ if (isString(opts.format) && opts.format === 'csv') {
1621
+ path += `&format=${opts.format}`;
1622
+ }
1623
+
1624
+ const headers = generateHeaders(
1625
+ this.headers,
1626
+ this.apiSecret,
1627
+ verb,
1628
+ path,
1629
+ this.apiExpiresAfter
1630
+ );
1631
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1632
+ }
1633
+
1634
+ /**
1635
+ * Create exchange user
1636
+ * @param {string} email - The mail address for the user
1637
+ * @param {string} password - The password for the user
1638
+ * @return {object} A JSON object with message
1639
+ */
1640
+ createExchangeUser(email, password) {
1641
+ const verb = 'POST';
1642
+ let path = `${this.baseUrl}/admin/user`;
1643
+ const data = {
1644
+ email,
1645
+ password
1646
+ };
1647
+
1648
+ const headers = generateHeaders(
1649
+ this.headers,
1650
+ this.apiSecret,
1651
+ verb,
1652
+ path,
1653
+ this.apiExpiresAfter,
1654
+ data
1655
+ );
1656
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1657
+ }
1658
+
1659
+ /**
1660
+ * Update exchange user
1661
+ * @param {number} userId - The identifier of the user to filter by
1662
+ * @param {object} opts.meta - The field to update user meta info
1663
+ * @param {boolean} opts.overwrite - the field to set overwrite option along with meta object
1664
+ * @param {string} opts.role - The field to update user role ('admin', 'supervisor', 'support', 'kyc', 'communicator', 'user')
1665
+ * @param {string} opts.note - The field to update user note
1666
+ * @param {number} opts.verification_level - The field to set user's verification level
1667
+ * @return {object} A JSON object with user data
1668
+ */
1669
+ updateExchangeUser(
1670
+ userId,
1671
+ opts = {
1672
+ role: null,
1673
+ meta: null,
1674
+ overwrite: null,
1675
+ discount: null,
1676
+ note: null,
1677
+ verification_level: null
1678
+ },
1679
+
1680
+ ) {
1681
+ if (isString(opts.role)
1682
+ && ['admin', 'supervisor', 'support', 'kyc', 'communicator', 'user'].includes(opts.role)) {
1683
+
1684
+ const verb = 'PUT';
1685
+ let path = `${this.baseUrl}/admin/user/role`;
1686
+
1687
+ if (isNumber(userId)) {
1688
+ path += `?user_id=${userId}`;
1689
+ }
1690
+ const data = {
1691
+ role: opts.role
1692
+ };
1693
+
1694
+ const headers = generateHeaders(
1695
+ this.headers,
1696
+ this.apiSecret,
1697
+ verb,
1698
+ path,
1699
+ this.apiExpiresAfter,
1700
+ data
1701
+ );
1702
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1703
+ }
1704
+
1705
+ if(isObject(opts.meta)){
1706
+ const verb = 'PUT';
1707
+ let path = `${this.baseUrl}/admin/user/meta`;
1708
+
1709
+ if (isNumber(userId)) {
1710
+ path += `?user_id=${userId}`;
1711
+ }
1712
+
1713
+ const data = {
1714
+ meta: opts.meta,
1715
+ ...(isBoolean(opts.overwrite) && { overwrite: opts.overwrite }),
1716
+ };
1717
+
1718
+ const headers = generateHeaders(
1719
+ this.headers,
1720
+ this.apiSecret,
1721
+ verb,
1722
+ path,
1723
+ this.apiExpiresAfter,
1724
+ data
1725
+ );
1726
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1727
+ }
1728
+
1729
+ if(isNumber(opts.discount) && opts.discount <= 100 && opts.discount >= 0){
1730
+ const verb = 'PUT';
1731
+ let path = `${this.baseUrl}/admin/user/discount`;
1732
+
1733
+ if (isNumber(userId)) {
1734
+ path += `?user_id=${userId}`;
1735
+ }
1736
+
1737
+ const data = {
1738
+ discount: opts.discount
1739
+ };
1740
+
1741
+ const headers = generateHeaders(
1742
+ this.headers,
1743
+ this.apiSecret,
1744
+ verb,
1745
+ path,
1746
+ this.apiExpiresAfter,
1747
+ data
1748
+ );
1749
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1750
+ }
1751
+
1752
+ if(isString(opts.note)){
1753
+ const verb = 'PUT';
1754
+ let path = `${this.baseUrl}/admin/user/note`;
1755
+
1756
+ if (isNumber(userId)) {
1757
+ path += `?user_id=${userId}`;
1758
+ }
1759
+
1760
+ const data = {
1761
+ note: opts.note
1762
+ };
1763
+
1764
+ const headers = generateHeaders(
1765
+ this.headers,
1766
+ this.apiSecret,
1767
+ verb,
1768
+ path,
1769
+ this.apiExpiresAfter,
1770
+ data
1771
+ );
1772
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1773
+ }
1774
+
1775
+ if(isNumber(opts.verification_level)){
1776
+ const verb = 'POST';
1777
+ let path = `${this.baseUrl}/admin/upgrade-user`;
1778
+
1779
+ const data = {
1780
+ user_id: userId,
1781
+ verification_level: opts.verification_level
1782
+ };
1783
+
1784
+ const headers = generateHeaders(
1785
+ this.headers,
1786
+ this.apiSecret,
1787
+ verb,
1788
+ path,
1789
+ this.apiExpiresAfter,
1790
+ data
1791
+ );
1792
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1793
+ }
1794
+
1795
+ }
1796
+
1797
+ /**
1798
+ * Create wallet for exchange user
1799
+ * @param {number} userId - The identifier of the user
1800
+ * @param {string} crypto - The coin for the wallet e.g btc, eth
1801
+ * @param {string} opts.network - The network info
1802
+ * @return {object} A JSON object with message
1803
+ */
1804
+ createExchangeUserWallet(
1805
+ userId,
1806
+ crypto,
1807
+ opts= {
1808
+ network: null
1809
+ }
1810
+ ) {
1811
+ const verb = 'POST';
1812
+ let path = `${this.baseUrl}/admin/user/wallet`;
1813
+ const data = {
1814
+ user_id: userId,
1815
+ crypto
1816
+ };
1817
+
1818
+ if (isString(opts.network)) {
1819
+ data.network = opts.network;
1820
+ }
1821
+
1822
+ const headers = generateHeaders(
1823
+ this.headers,
1824
+ this.apiSecret,
1825
+ verb,
1826
+ path,
1827
+ this.apiExpiresAfter,
1828
+ data
1829
+ );
1830
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1831
+ }
1832
+
1833
+ /**
1834
+ * Retrieve users' wallets by admin
1835
+ * @param {object} opts - Optional parameters
1836
+ * @param {number} opts.userId - The identifier of the user to filter by
1837
+ * @param {number} opts.limit - Amount of users per page. Maximum: 50. Default: 50
1838
+ * @param {string} opts.currency - The currency to filter by
1839
+ * @param {number} opts.page - Page of user data. Default: 1
1840
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1841
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1842
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1843
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1844
+ * @param {string} opts.address - Address of crypto
1845
+ * @param {boolean} opts.isValid - Specify whether or not wallet is valid
1846
+ * @param {string} opts.network - Crypto network of currency
1847
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
1848
+ * @return {object} A JSON object with user data
1849
+ *
1850
+ */
1851
+ getExchangeUserWallet(
1852
+ opts = {
1853
+ userId: null,
1854
+ limit: null,
1855
+ page: null,
1856
+ currency: null,
1857
+ orderBy: null,
1858
+ order: null,
1859
+ startDate: null,
1860
+ endDate: null,
1861
+ address: null,
1862
+ isValid: null,
1863
+ network: null,
1864
+ format: null
1865
+ }
1866
+ ) {
1867
+ const verb = 'GET';
1868
+ let path = `${this.baseUrl}/admin/user/wallet?`;
1869
+
1870
+ if (isNumber(opts.userId)) {
1871
+ path += `&user_id=${opts.userId}`;
1872
+ }
1873
+
1874
+ if (isString(opts.currency)) {
1875
+ path += `&currency=${opts.currency}`;
1876
+ }
1877
+
1878
+ if (isString(opts.address)) {
1879
+ path += `&address=${opts.address}`;
1880
+ }
1881
+
1882
+ if (isString(opts.network)) {
1883
+ path += `&network=${opts.network}`;
1884
+ }
1885
+
1886
+ if (isBoolean(opts.isValid)) {
1887
+ path += `&is_valid=${opts.isValid}`;
1888
+ }
1889
+
1890
+ if (isNumber(opts.limit)) {
1891
+ path += `&limit=${opts.limit}`;
1892
+ }
1893
+
1894
+ if (isNumber(opts.page)) {
1895
+ path += `&page=${opts.page}`;
1896
+ }
1897
+
1898
+ if (isString(opts.orderBy)) {
1899
+ path += `&order_by=${opts.orderBy}`;
1900
+ }
1901
+
1902
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1903
+ path += `&order=${opts.order}`;
1904
+ }
1905
+
1906
+ if (isDatetime(opts.startDate)) {
1907
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
1908
+ }
1909
+
1910
+ if (isDatetime(opts.endDate)) {
1911
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
1912
+ }
1913
+
1914
+ if (isString(opts.format) && opts.format === 'csv') {
1915
+ path += `&format=${opts.format}`;
1916
+ }
1917
+
1918
+ const headers = generateHeaders(
1919
+ this.headers,
1920
+ this.apiSecret,
1921
+ verb,
1922
+ path,
1923
+ this.apiExpiresAfter
1924
+ );
1925
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1926
+ }
1927
+
1928
+ /**
1929
+ * Retrieve user's login info by admin
1930
+ * @param {number} userId - The identifier of the user
1931
+ * @return {object} A JSON object with user balance
1932
+ */
1933
+ getExchangeUserBalance(userId) {
1934
+ const verb = 'GET';
1935
+ let path = `${this.baseUrl}/admin/user/balance?user_id=${userId}`;
1936
+
1937
+ const headers = generateHeaders(
1938
+ this.headers,
1939
+ this.apiSecret,
1940
+ verb,
1941
+ path,
1942
+ this.apiExpiresAfter
1943
+ );
1944
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
1945
+ }
1946
+
1947
+ /**
1948
+ * Create bank account for user by admin
1949
+ * @param {number} userId - The identifier of the user
1950
+ * @param {object} bankAccount - Array of objects with bank account info
1951
+ * @return {object} A JSON object with bank account info
1952
+ */
1953
+ createExchangeUserBank(userId, bankAccount) {
1954
+ const verb = 'POST';
1955
+ let path = `${this.baseUrl}/admin/user/bank`;
1956
+
1957
+ if (isNumber(userId)) {
1958
+ path += `?id=${userId}`;
1959
+ }
1960
+
1961
+ const data = {
1962
+ bank_account: bankAccount
1963
+ };
1964
+
1965
+ const headers = generateHeaders(
1966
+ this.headers,
1967
+ this.apiSecret,
1968
+ verb,
1969
+ path,
1970
+ this.apiExpiresAfter,
1971
+ data
1972
+ );
1973
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1974
+
1975
+ }
1976
+
1977
+ /**
1978
+ * Retrieve user's login info by admin
1979
+ * @param {number} opts.userId - The identifier of the user
1980
+ * @param {number} opts.limit - Amount of logins per page. Maximum: 50. Default: 50
1981
+ * @param {number} opts.page - Page of referral data. Default: 1
1982
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
1983
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
1984
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
1985
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
1986
+ * @return {object} A JSON object with login info
1987
+ */
1988
+ getExchangeUserLogins(
1989
+ opts = {
1990
+ userId: null,
1991
+ limit: null,
1992
+ page: null,
1993
+ orderBy: null,
1994
+ order: null,
1995
+ startDate: null,
1996
+ endDate: null,
1997
+ format: null
1998
+ }
1999
+ ) {
2000
+ const verb = 'GET';
2001
+ let path = `${this.baseUrl}/admin/logins?`;
2002
+
2003
+ if (isNumber(opts.userId)) {
2004
+ path += `&user_id=${opts.userId}`;
2005
+ }
2006
+
2007
+ if (isNumber(opts.limit)) {
2008
+ path += `&limit=${opts.limit}`;
2009
+ }
2010
+
2011
+ if (isNumber(opts.page)) {
2012
+ path += `&page=${opts.page}`;
2013
+ }
2014
+
2015
+ if (isString(opts.orderBy)) {
2016
+ path += `&order_by=${opts.orderBy}`;
2017
+ }
2018
+
2019
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2020
+ path += `&order=${opts.order}`;
2021
+ }
2022
+
2023
+ if (isDatetime(opts.startDate)) {
2024
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
2025
+ }
2026
+
2027
+ if (isDatetime(opts.endDate)) {
2028
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
2029
+ }
2030
+
2031
+ if (isString(opts.format) && opts.format === 'csv') {
2032
+ path += `&format=${opts.format}`;
2033
+ }
2034
+
2035
+ const headers = generateHeaders(
2036
+ this.headers,
2037
+ this.apiSecret,
2038
+ verb,
2039
+ path,
2040
+ this.apiExpiresAfter
2041
+ );
2042
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2043
+ }
2044
+
2045
+ /**
2046
+ * Deactivate exchange user account by admin
2047
+ * @param {number} userId - The identifier of the user to deactivate their exchange account
2048
+ * @return {object} A JSON object with message
2049
+ */
2050
+ deactivateExchangeUser(userId) {
2051
+ const verb = 'POST';
2052
+ let path = `${this.baseUrl}/admin/user/activate`;
2053
+ const data = {
2054
+ user_id: userId,
2055
+ activated: false
2056
+ };
2057
+
2058
+ const headers = generateHeaders(
2059
+ this.headers,
2060
+ this.apiSecret,
2061
+ verb,
2062
+ path,
2063
+ this.apiExpiresAfter,
2064
+ data
2065
+ );
2066
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2067
+ }
2068
+
2069
+ /**
2070
+ * Deactivate user otp by admin
2071
+ * @param {number} userId - The identifier of the user to deactivate their otp
2072
+ * @return {object} A JSON object with message
2073
+ */
2074
+ deactivateExchangeUserOtp(userId) {
2075
+ const verb = 'POST';
2076
+ let path = `${this.baseUrl}/admin/deactivate-otp`;
2077
+ const data = {
2078
+ user_id: userId
2079
+ };
2080
+
2081
+ const headers = generateHeaders(
2082
+ this.headers,
2083
+ this.apiSecret,
2084
+ verb,
2085
+ path,
2086
+ this.apiExpiresAfter,
2087
+ data
2088
+ );
2089
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2090
+ }
2091
+
2092
+ /**
2093
+ * Retrieve user's referrals info by admin
2094
+ * @param {number} userId - The identifier of the user to filter by
2095
+ * @param {number} opts.limit - Amount of referrals per page. Maximum: 50. Default: 50
2096
+ * @param {number} opts.page - Page of referral data. Default: 1
2097
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
2098
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
2099
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
2100
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
2101
+ * @return {object} A JSON object with referral info
2102
+ */
2103
+ getExchangeUserReferrals(
2104
+ userId = null,
2105
+ opts = {
2106
+ limit: null,
2107
+ page: null,
2108
+ orderBy: null,
2109
+ order: null,
2110
+ startDate: null,
2111
+ endDate: null
2112
+ }
2113
+ ) {
2114
+ const verb = 'GET';
2115
+ let path = `${this.baseUrl}/admin/user/affiliation?`;
2116
+
2117
+
2118
+ if (isNumber(userId)) {
2119
+ path += `&user_id=${userId}`;
2120
+ }
2121
+
2122
+ if (isNumber(opts.limit)) {
2123
+ path += `&limit=${opts.limit}`;
2124
+ }
2125
+
2126
+ if (isNumber(opts.page)) {
2127
+ path += `&page=${opts.page}`;
2128
+ }
2129
+
2130
+ if (isString(opts.orderBy)) {
2131
+ path += `&order_by=${opts.orderBy}`;
2132
+ }
2133
+
2134
+ if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2135
+ path += `&order=${opts.order}`;
2136
+ }
2137
+
2138
+ if (isDatetime(opts.startDate)) {
2139
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
2140
+ }
2141
+
2142
+ if (isDatetime(opts.endDate)) {
2143
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
2144
+ }
2145
+
2146
+
2147
+ const headers = generateHeaders(
2148
+ this.headers,
2149
+ this.apiSecret,
2150
+ verb,
2151
+ path,
2152
+ this.apiExpiresAfter
2153
+ );
2154
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2155
+ }
2156
+
2157
+ /**
2158
+ * Retrieve user's referer info by admin
2159
+ * @param {number} userId - The identifier of the user to filter by
2160
+ * @return {object} A JSON object with referrer info
2161
+ */
2162
+ getExchangeUserReferrer(userId) {
2163
+ const verb = 'GET';
2164
+ let path = `${this.baseUrl}/admin/user/referer?user_id=${userId}`;
2165
+ const headers = generateHeaders(
2166
+ this.headers,
2167
+ this.apiSecret,
2168
+ verb,
2169
+ path,
2170
+ this.apiExpiresAfter
2171
+ );
2172
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2173
+ }
2174
+
2175
+
675
2176
  /**
676
2177
  * Connect to hollaEx websocket and listen to an event
677
2178
  * @param {array} events - The events to listen to
@@ -816,6 +2317,8 @@ class HollaExKit {
816
2317
  case 'usertrade':
817
2318
  case 'wallet':
818
2319
  case 'deposit':
2320
+ case 'withdrawal':
2321
+ case 'admin':
819
2322
  this.ws.send(
820
2323
  JSON.stringify({
821
2324
  op: 'subscribe',
@@ -868,6 +2371,8 @@ class HollaExKit {
868
2371
  case 'order':
869
2372
  case 'wallet':
870
2373
  case 'deposit':
2374
+ case 'withdrawal':
2375
+ case 'admin':
871
2376
  this.ws.send(
872
2377
  JSON.stringify({
873
2378
  op: 'unsubscribe',