Update floExchangeAPI.js

This commit is contained in:
sairajzero 2022-10-07 23:01:09 +05:30
parent 7d09babea7
commit 87e6bc01de

View File

@ -579,60 +579,66 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result) }).then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}); });
} }
exchangeAPI.getBuyList = function (asset = null) { exchangeAPI.getBuyList = function (asset = null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch_api('/list-buyorders' + (asset ? "?asset=" + asset : "")) fetch_api('/list-buyorders' + (asset ? "?asset=" + asset : ""))
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}); });
} }
exchangeAPI.getSellList = function (asset = null) { exchangeAPI.getSellList = function (asset = null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch_api('/list-sellorders' + (asset ? "?asset=" + asset : "")) fetch_api('/list-sellorders' + (asset ? "?asset=" + asset : ""))
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}); });
} }
exchangeAPI.getTradeList = function (asset = null) { exchangeAPI.getTradeList = function (asset = null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch_api('/list-trades' + (asset ? "?asset=" + asset : "")) fetch_api('/list-trades' + (asset ? "?asset=" + asset : ""))
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}); });
} }
exchangeAPI.getRates = function (asset = null) { exchangeAPI.getRates = function (asset = null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch_api('/get-rates' + (asset ? "?asset=" + asset : "")) fetch_api('/get-rates' + (asset ? "?asset=" + asset : ""))
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}); });
} }
exchangeAPI.getRateHistory = function (asset, duration = null) { exchangeAPI.getRateHistory = function (asset, duration = null) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch_api('/rate-history?asset=' + asset + (duration ? '&duration=' + duration : "")) fetch_api('/rate-history?asset=' + asset + (duration ? '&duration=' + duration : ""))
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}); });
} }
@ -644,10 +650,11 @@
(floID && token ? "&" : "") + (floID && token ? "&" : "") +
(token ? "token=" + token : ""); (token ? "token=" + token : "");
fetch_api('/get-balance?' + queryStr) fetch_api('/get-balance?' + queryStr)
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}) })
} }
@ -656,10 +663,11 @@
if (!txid) if (!txid)
return reject(ExchangeError(ExchangeError.BAD_REQUEST_CODE, 'txid required', errorCode.MISSING_PARAMETER)); return reject(ExchangeError(ExchangeError.BAD_REQUEST_CODE, 'txid required', errorCode.MISSING_PARAMETER));
fetch_api('/get-transaction?txid=' + txid) fetch_api('/get-transaction?txid=' + txid)
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}) })
} }
@ -673,10 +681,11 @@
exchangeAPI.getLoginCode = function () { exchangeAPI.getLoginCode = function () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch_api('/get-login-code') fetch_api('/get-login-code')
.then(result => responseParse(result) .then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}) })
} }
@ -705,9 +714,9 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))})
.catch(error => reject(error)); .catch(error => reject(error));
}); });
} }
@ -741,10 +750,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error))) .catch(error => reject(error))
.catch(error => reject(error)); }).catch(error => reject(error));
}) })
} }
@ -768,10 +778,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -805,10 +816,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -843,10 +855,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -877,10 +890,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -923,10 +937,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -957,11 +972,12 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -987,10 +1003,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -1019,11 +1036,12 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -1051,10 +1069,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -1078,10 +1097,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result) }).then(result => {
responseParse(result)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -1109,10 +1129,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -1140,10 +1161,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -1171,10 +1193,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }
@ -1202,10 +1225,11 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(request) body: JSON.stringify(request)
}).then(result => responseParse(result, false) }).then(result => {
responseParse(result, false)
.then(result => resolve(result)) .then(result => resolve(result))
.catch(error => reject(error)))
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error))
}) })
} }