R/check_input_weather.R

Defines functions check_input_weather

check_input_weather <- function(start, end, user, password) {
  check <- ArgumentCheck::newArgCheck()

  # Check start and end are valid dates
  check <- check_start_end_dates(check, start, end)

  # Test access to IAC website
  url <- "https://iacweb.ethz.ch/data/meteostation/chn/IAC-Met_2017-09-04.dat"
  response <- httr::GET(
    url = url,
    httr::accept_json(),
    httr::authenticate(user = user, password = password)
  )

  # Check if correct user and password
  if (response$status != 200) {
    ArgumentCheck::addError(
      msg = "Invalid IAC username or password",
      argcheck = check
    )
  }

  #* Return errors and warnings (if any)
  return(ArgumentCheck::finishArgCheck(check))
}
lucasjamar/VBZtools documentation built on May 20, 2020, 3:44 a.m.