From 8e723a102e60ed1717f8e4b4332bee874725feb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Wed, 1 Dec 2021 00:48:22 +0000 Subject: [PATCH] feat: add pazuz-ticker support fix: add newline at EOF --- .../ticker/pazuz-ticker/pazuz-ticker.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/plugins/ticker/pazuz-ticker/pazuz-ticker.js diff --git a/lib/plugins/ticker/pazuz-ticker/pazuz-ticker.js b/lib/plugins/ticker/pazuz-ticker/pazuz-ticker.js new file mode 100644 index 00000000..34daf691 --- /dev/null +++ b/lib/plugins/ticker/pazuz-ticker/pazuz-ticker.js @@ -0,0 +1,28 @@ +const https = require('https') +const axios = require('axios').create({ + // TODO: get rejectUnauthorized true to work + baseURL: `${process.env.TICKER_URL}/api/rates/`, + httpsAgent: new https.Agent({ + rejectUnauthorized: false + }) +}) + +const BN = require('../../../bn') + +function ticker (account, fiatCode, cryptoCode) { + return axios.get(`${cryptoCode}/${fiatCode}`) + .then(({ data }) => { + if (data.error) throw new Error(JSON.stringify(data.error)) + return { + rates: { + ask: BN(data.ask), + bid: BN(data.bid), + signature: data.signature + } + } + }) +} + +module.exports = { + ticker +}