class Envirobly::Api

def get_deployment_with_delay_and_retry(url, tries = 1)

def get_deployment_with_delay_and_retry(url, tries = 1)
  sleep SHORT_RETRY_INTERVAL * tries
  response = get_as_json URI(url)
  if response.success?
    response
  elsif MAX_RETRIES <= tries
    $stderr.puts "Max retries exhausted while waiting for deployment credentials. Aborting."
    exit 1
  else
    if tries > 3
      sleep LONG_RETRY_INTERVAL
    else
      sleep SHORT_RETRY_INTERVAL
    end
    get_deployment_with_delay_and_retry(url, tries + 1)
  end
end