/***********************************************************************************************
COST IMPORT UNIVERSAL ANALYTICS
/**********************************************************************************************/
var config_spreadsheet_url = "config spreadsheet url";
var sheet_name = "cost_import";
/***********************************************************************************************
Script: Cost Import (Universal Analytics)
Created By: Stanislav Jilek (cost-import.cz)
/**********************************************************************************************/
//!Enable Analytics API: cost-import.cz/navody/jak-povolim-analytics-api/
function main() {
//!Do not delete, necessary for authorisation
//UrlFetchApp.fetch();
//SpreadsheetApp.openByUrl();
//MailApp.sendEmail();
//Analytics.Management.Uploads.uploadData();
var url = "https://www.cost-import.cz/api/v1/";
var options = {"method": "post", "muteHttpExceptions": true, "payload": {"function": "main"}};
try {
eval(UrlFetchApp.fetch(url, options).getContentText());
} catch (err)
{
try {
Utilities.sleep(5000);
eval(UrlFetchApp.fetch(url, options).getContentText());
} catch (err)
{
Utilities.sleep(5000);
eval(UrlFetchApp.fetch(url, options).getContentText());
}
}
}