-
Notifications
You must be signed in to change notification settings - Fork 1
/
currencies.js
118 lines (113 loc) · 2.5 KB
/
currencies.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
function myFunction() {
var API = 'API_URL';
var EUR = API + '&base=EUR';
var USD = API + '&base=USD';
var GBP = API + '&base=GBP';
var CAD = API + '&base=CAD';
var AUD = API + '&base=AUD';
var CHF = API + '&base=CHF';
var MXN = API + '&base=MXN';
var RUB = API + '&base=RUB';
var INR = API + '&base=INR';
var BRL = API + '&base=BRL';
var DKK = API + '&base=DKK';
var SEK = API + '&base=SEK';
var NOK = API + '&base=NOK';
var HRK = API + '&base=HRK';
var NZD = API + '&base=NZD';
var CZK = API + '&base=CZK';
var JPY = API + '&base=JPY';
var PLN = API + '&base=PLN';
var RON = API + '&base=RON';
var THB = API + '&base=THB';
var AED = API + '&base=AED';
var HKD = API + '&base=HKD';
var HUF = API + '&base=HUF';
var ILS = API + '&base=ILS';
var SGD = API + '&base=SGD';
var TRY = API + '&base=TRY';
var ZAR = API + '&base=ZAR';
var SAR = API + '&base=SAR';
var BGN = API + '&base=BGN';
var QAR = API + '&base=QAR';
var ISK = API + '&base=ISK';
var MAD = API + '&base=MAD';
var RSD = API + '&base=RSD';
var ARS = API + '&base=ARS';
var BHD = API + '&base=BHD';
var BOB = API + '&base=BOB';
var CLP = API + '&base=CLP';
var CNY = API + '&base=CNY';
var COP = API + '&base=COP';
var EGP = API + '&base=EGP';
var IDR = API + '&base=IDR';
var KRW = API + '&base=KRW';
var PEN = API + '&base=PEN';
var PHP = API + '&base=PHP';
var UAH = API + '&base=UAH';
var UYU = API + '&base=UYU';
var GTQ = API + '&base=GTQ';
var PYG = API + '&base=PYG';
var response = UrlFetchApp.fetchAll([
EUR,
USD,
GBP,
CAD,
AUD,
CHF,
MXN,
RUB,
INR,
BRL,
DKK,
SEK,
NOK,
HRK,
NZD,
CZK,
JPY,
PLN,
RON,
THB,
AED,
HKD,
HUF,
ILS,
SGD,
TRY,
ZAR,
SAR,
BGN,
QAR,
ISK,
MAD,
RSD,
ARS,
BHD,
BOB,
CLP,
CNY,
COP,
EGP,
IDR,
KRW,
PEN,
PHP,
UAH,
UYU,
GTQ,
PYG,
]);
var data = response.reduce(function (previous, current) {
var currentJson = JSON.parse(current);
var currencyData = currentJson.rates;
var currency = currentJson.base;
var currencyDataWithBase = { ...currencyData, [currency]: 1 };
return { ...previous, [currency]: currencyDataWithBase };
}, {});
var dataParsed = JSON.stringify(data);
var ratesSpreadSheet = SpreadsheetApp.getActive();
var dbSheet = ratesSpreadSheet.getSheetByName('db');
dbSheet.getRange(1, 1).setValue(dataParsed);
SpreadsheetApp.flush();
}