2018-12-13 13:36:50 -08:00
|
|
|
// @flow
|
2019-02-04 20:41:45 -08:00
|
|
|
|
2019-02-20 09:56:35 -08:00
|
|
|
import got from 'got';
|
2018-12-13 13:36:50 -08:00
|
|
|
|
|
|
|
type Payload = {
|
|
|
|
[currency: string]: number,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
WARNING:
|
|
|
|
Just a super fast way to get the zec price
|
|
|
|
*/
|
2019-02-04 20:41:45 -08:00
|
|
|
// eslint-disable-next-line
|
2018-12-13 13:36:50 -08:00
|
|
|
export default (currencies: string[] = ['USD']): Promise<Payload> => new Promise((resolve, reject) => {
|
|
|
|
const ENDPOINT = `https://min-api.cryptocompare.com/data/price?fsym=ZEC&tsyms=${currencies.join(
|
|
|
|
',',
|
2018-12-15 13:45:48 -08:00
|
|
|
)}&api_key=${String(process.env.ZEC_PRICE_API_KEY)}`;
|
2018-12-13 13:36:50 -08:00
|
|
|
|
2019-02-20 09:56:35 -08:00
|
|
|
got(ENDPOINT)
|
|
|
|
.then(response => resolve(JSON.parse(response.body)))
|
|
|
|
.catch(reject);
|
2018-12-13 13:36:50 -08:00
|
|
|
});
|