R/CHECKING-check_apikey.R

Defines functions .check_apikey

.check_apikey <- function(apikey) {
  
  if (is.null(apikey)) {
    
    stop("No ChemSpider \"apikey\" provided.", call. = FALSE)
    
  }
  
  if (length(apikey) > 1) {
    
    stop(paste("This function can only handle a single ChemSpider \"apikey\"",
               "entry.\nFor functional programming, try using it in apply()",
               "or purrr::map()."), call. = FALSE)
    
  }
  
  if (!is.character(apikey)) {
    
    stop("The ChemSpider \"apikey\" should be a 32-character string.",
         call. = FALSE)
    
  }
  
  if (nchar(apikey) != 32) {
    
    stop("Please use a valid 32-character ChemSpider \"apikey\".",
         call. = FALSE)
  }
}
RaoulWolf/chemspiderapi documentation built on July 4, 2021, 5:28 a.m.