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

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

  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());
    }
  }
}