R/yadirSetAgencyAccount.R

Defines functions yadirSetAgencyAccount

Documented in yadirSetAgencyAccount

yadirSetAgencyAccount <- function(AgencyAccount, TokenPath = yadirTokenPath()) {
  
  if ( is.null(AgencyAccount) || is.na(AgencyAccount) ) {
    
    message("Unset AgencyAccount")
    options(ryandexdirect.agency_account = NULL)
    
  } else  {
  
    file_name   <- file.path(TokenPath, str_glue("{AgencyAccount}.yadirAuth.RData")) 
  
    if ( file.exists(file_name) ) {
      
      options(ryandexdirect.agency_account = AgencyAccount)
      
    } else if ( interactive() ) {
      
      yadirAuth(Login = AgencyAccount, NewUser = TRUE, TokenPath)
      
      options(ryandexdirect.user = AgencyAccount)
      
    } else {
      
      stop(str_glue("Your login not found in {TokenPath}, and you using batch mode. Run R in interactive mode and repeat this action."))
      
    }
  
  }
  
  return(TRUE)

}

Try the ryandexdirect package in your browser

Any scripts or data that you put into this service are public.

ryandexdirect documentation built on July 1, 2020, 10:39 p.m.