-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto.js
36 lines (27 loc) · 898 Bytes
/
crypto.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const {CMC} = require('./entities.js');
const CRYPTO_UPDATE_IMG = {
path: './img/cryptoPriceUpdate.jpg'
}
const {uploadImgToTwitter, updateTweetStatus} = require('./twitter.js');
const getCoinData = (coin) => {
return {
name: coin.name,
id: coin.id,
price: (coin.quote.USD.price).toFixed(2)
}
}
const updateCryptoPrices = async() => {
const {data} = await CMC.getTickers({
limit: 3
});
const topThreeCoins = data.map(getCoinData);
let priceUpdateString = "🌔 Top 3 Cryptocurrency Coins $USD price update: 🌔\n";
topThreeCoins.forEach(({name, price}) => {
priceUpdateString += (`📈 #${name} 💵: ${price}$\n`);
});
const cryptoImgUpload = await uploadImgToTwitter(CRYPTO_UPDATE_IMG.path);
updateTweetStatus(priceUpdateString, cryptoImgUpload);
}
module.exports = {
updateCryptoPrices
}