mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-21 16:52:04 -07:00
Merge pull request #166 from ethanmackie/master
Adding a getCurrencyInfo endpoint to bch-api in both v4 and v5 routes
This commit is contained in:
@@ -59,6 +59,7 @@ class UtilRoute {
|
||||
this.router.get('/validateAddress/:address', this.validateAddressSingle)
|
||||
this.router.post('/validateAddress', this.validateAddressBulk)
|
||||
this.router.post('/sweep', this.sweepWif)
|
||||
this.router.get('/getCurrencyInfo', this.getCurrencyInfo)
|
||||
|
||||
_this = this
|
||||
}
|
||||
@@ -67,6 +68,49 @@ class UtilRoute {
|
||||
return res.json({ status: 'util' })
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /util/getCurrencyInfo Get information about the currency.
|
||||
* @apiName getCurrencyInfo
|
||||
* @apiGroup Util
|
||||
* @apiDescription Returns an object containing information about the currency.
|
||||
*
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "https://api.fullstack.cash/v4/util/getCurrencyInfo" -H "accept: application/json"
|
||||
*
|
||||
*
|
||||
*/
|
||||
async getCurrencyInfo (req, res, next) {
|
||||
try {
|
||||
|
||||
const {
|
||||
BitboxHTTP,
|
||||
// username,
|
||||
// password,
|
||||
requestConfig
|
||||
} = routeUtils.setEnvVars()
|
||||
|
||||
requestConfig.data.id = 'getcurrencyinfo'
|
||||
requestConfig.data.method = 'getcurrencyinfo'
|
||||
|
||||
const response = await BitboxHTTP(requestConfig)
|
||||
|
||||
return res.json(response.data.result)
|
||||
} catch (err) {
|
||||
// Attempt to decode the error message.
|
||||
const { msg, status } = routeUtils.decodeError(err)
|
||||
if (msg) {
|
||||
res.status(status)
|
||||
return res.json({ error: msg })
|
||||
}
|
||||
|
||||
wlogger.error('Error in util.ts/getCurrencyInfo().', err)
|
||||
|
||||
res.status(500)
|
||||
return res.json({ error: util.inspect(err) })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /util/validateAddress/{address} Get information about single bitcoin cash address.
|
||||
* @apiName Information about single bitcoin cash address
|
||||
|
||||
@@ -39,6 +39,7 @@ class UtilRoute {
|
||||
this.router.get('/', this.root)
|
||||
this.router.get('/validateAddress/:address', this.validateAddressSingle)
|
||||
this.router.post('/validateAddress', this.validateAddressBulk)
|
||||
this.router.get('/getCurrencyInfo', this.getCurrencyInfo)
|
||||
// this.router.post('/sweep', this.sweepWif)
|
||||
|
||||
// _this = this
|
||||
@@ -48,6 +49,49 @@ class UtilRoute {
|
||||
return res.json({ status: 'util' })
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /util/getCurrencyInfo Get information about the currency.
|
||||
* @apiName getCurrencyInfo
|
||||
* @apiGroup Util
|
||||
* @apiDescription Returns an object containing information about the currency.
|
||||
*
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -X GET "https://api.fullstack.cash/v5/util/getCurrencyInfo" -H "accept: application/json"
|
||||
*
|
||||
*
|
||||
*/
|
||||
async getCurrencyInfo (req, res, next) {
|
||||
try {
|
||||
|
||||
const {
|
||||
BitboxHTTP,
|
||||
// username,
|
||||
// password,
|
||||
requestConfig
|
||||
} = routeUtils.setEnvVars()
|
||||
|
||||
requestConfig.data.id = 'getcurrencyinfo'
|
||||
requestConfig.data.method = 'getcurrencyinfo'
|
||||
|
||||
const response = await BitboxHTTP(requestConfig)
|
||||
|
||||
return res.json(response.data.result)
|
||||
} catch (err) {
|
||||
// Attempt to decode the error message.
|
||||
const { msg, status } = routeUtils.decodeError(err)
|
||||
if (msg) {
|
||||
res.status(status)
|
||||
return res.json({ error: msg })
|
||||
}
|
||||
|
||||
wlogger.error('Error in util.ts/getCurrencyInfo().', err)
|
||||
|
||||
res.status(500)
|
||||
return res.json({ error: util.inspect(err) })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /util/validateAddress/{address} Get information about single bitcoin cash address.
|
||||
* @apiName Information about single bitcoin cash address
|
||||
|
||||
Reference in New Issue
Block a user