-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include get endpoints for abe support
- Loading branch information
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import log from '../lib/log'; | ||
import { | ||
showFiatAssets, | ||
showCryptoAssets, | ||
getPurchaseDetailByPurchaseId, | ||
submitPurchase, | ||
getPurchaseHistory | ||
} from '../services/assetService'; | ||
|
||
async function getFiatAssets(req, res) { | ||
try { | ||
const value = await showFiatAssets(); | ||
res.json(value); | ||
} catch (error) { | ||
log.error(error); | ||
res.sendStatus(404); | ||
} | ||
} | ||
|
||
async function getCryptoAssets(req, res) { | ||
try { | ||
const value = await showCryptoAssets(); | ||
res.json(value); | ||
} catch (error) { | ||
log.error(error); | ||
res.sendStatus(404); | ||
} | ||
} | ||
|
||
async function getPurchaseDetailsByPurchaseId(req, res) { | ||
try { | ||
let { purchaseid } = req.params; | ||
purchaseid = purchaseid ?? req.query.purchaseid; | ||
const value = await getPurchaseDetailByPurchaseId(purchaseid); | ||
res.json(value); | ||
} catch (error) { | ||
log.error(error); | ||
res.sendStatus(404); | ||
} | ||
} | ||
|
||
async function sendPurchase(req, res) { | ||
try { | ||
let { purchaseid } = req.params; | ||
purchaseid = purchaseid ?? req.query.purchaseid; | ||
|
||
let { providerid } = req.params; | ||
providerid = providerid ?? req.query.providerid; | ||
|
||
const value = await submitPurchase(purchaseid, providerid); | ||
res.json(value); | ||
} catch (error) { | ||
log.error(error); | ||
res.sendStatus(404); | ||
} | ||
} | ||
|
||
async function getAllPurchase(req, res) { | ||
try { | ||
let { zelid } = req.params; | ||
zelid = zelid ?? req.query.zelid; | ||
|
||
const value = await getPurchaseHistory(zelid); | ||
res.json(value); | ||
} catch (error) { | ||
log.error(error); | ||
res.sendStatus(404); | ||
} | ||
} | ||
|
||
export default { | ||
getFiatAssets, | ||
getCryptoAssets, | ||
getPurchaseDetailsByPurchaseId, | ||
sendPurchase, | ||
getAllPurchase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import axios from 'axios'; | ||
|
||
export async function showFiatAssets () { | ||
try { | ||
const response = await axios.get('https://abe.zelcore.io/v1/purchase/sellassets'); | ||
return response.data; | ||
} catch(error) { | ||
console.log(error); | ||
return {}; | ||
}; | ||
} | ||
|
||
export async function showCryptoAssets () { | ||
try { | ||
const response = await axios.get('https://abe.zelcore.io/v1/purchase/buyassets'); | ||
return response.data; | ||
} catch(error) { | ||
console.log(error); | ||
return {}; | ||
}; | ||
} | ||
|
||
export async function getPurchaseDetailByPurchaseId (purchaseid: string) { | ||
try { | ||
const response = await axios.get(`https://abe.zelcore.io/v1/purchase/detail?purchaseid=${purchaseid}`); | ||
return response.data; | ||
} catch(error) { | ||
console.log(error); | ||
return {}; | ||
}; | ||
} | ||
|
||
export async function submitPurchase (purchaseid: string, providerid: string) { | ||
try { | ||
const response = await axios.get(`https://abe.zelcore.io/v1/purchase/submit?purchaseid=${purchaseid}&providerid=${providerid}`); | ||
return response.data; | ||
} catch(error) { | ||
console.log(error); | ||
return {}; | ||
}; | ||
} | ||
|
||
export async function getPurchaseHistory (zelid: string) { | ||
try { | ||
const response = await axios.get(`https://abe.zelcore.io/v1/offramp/user/history?zelid=${zelid}`); | ||
return response.data; | ||
} catch(error) { | ||
console.log(error); | ||
return {}; | ||
}; | ||
} | ||
|
||
|
||
|
||
|