/***********************************************************************************************
COST IMPORT
/**********************************************************************************************/
var config_spreadsheet_url = "config spreadsheet url";
var sheet_name = "cost_import";
/***********************************************************************************************
Script:      Cost Import
Created By:  Stanislav Jilek (cost-import.cz)
/**********************************************************************************************/

function main() {
  //!Do not delete, necessary for authorisation
  //UrlFetchApp.fetch();
  //SpreadsheetApp.openByUrl();
  //MailApp.sendEmail();
  //DriveApp.Folder.createFile();
  //BigQuery.Tables.get();

  var url = "https://www.cost-import.cz/api/v2/";
  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());
    }
  }
}