Skip to content

Commit

Permalink
Exposes config options to download file function. Closes #58
Browse files Browse the repository at this point in the history
  • Loading branch information
wibeasley committed Nov 3, 2014
1 parent 8b1a018 commit fc7f790
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
20 changes: 10 additions & 10 deletions R/redcap_download_file_oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#' @param field The name of the field where the file is saved in REDCap. Required
#' @param event The name of the event where the file is saved in REDCap. Optional
#' @param verbose A boolean value indicating if \code{message}s should be printed to the R console during the operation. Optional.
#' @param cert_location If present, this string should point to the location of the cert files required for SSL verification. If the value is missing or NULL, the server's identity will be verified using a recent CA bundle from the \href{http://curl.haxx.se}{cURL website}. See the details below. Optional.
#' @param sslversion The SSL version for curl. The default is 3. Set to NULL if your server has disabled SSL v3.
#' @param config_options A list of options to pass to \code{POST} method in the \code{httr} package. See the details below. Optional.
#'
#' @return Currently, a list is returned with the following elements,
#' \enumerate{
Expand Down Expand Up @@ -65,7 +64,7 @@
#' base::unlink(relative_name)
#' }

redcap_download_file_oneshot <- function( file_name=NULL, directory=NULL, overwrite=FALSE, redcap_uri, token, record, field, event="", verbose=TRUE, cert_location=NULL, sslversion=3 ) {
redcap_download_file_oneshot <- function( file_name=NULL, directory=NULL, overwrite=FALSE, redcap_uri, token, record, field, event="", verbose=TRUE, config_options=NULL ) {
start_time <- Sys.time()

if( missing(redcap_uri) )
Expand All @@ -74,13 +73,14 @@ redcap_download_file_oneshot <- function( file_name=NULL, directory=NULL, overwr
if( missing(token) )
stop("The required parameter `token` was missing from the call to `redcap_download_file_oneshot()`.")

if( missing( cert_location ) | is.null(cert_location) )
cert_location <- system.file("ssl_certs/mozilla_ca_root.crt", package="REDCapR")

if( !base::file.exists(cert_location) )
stop(paste0("The file specified by `cert_location`, (", cert_location, ") could not be found."))

config_options <- list(cainfo=cert_location, sslversion=sslversion)
if( missing( config_options ) | is.null(config_options) ) {
cert_location <- system.file("ssl_certs/mozilla_ca_root.crt", package="REDCapR")

if( !base::file.exists(cert_location) )
stop(paste0("The file specified by `cert_location`, (", cert_location, ") could not be found."))

config_options <- list(cainfo=cert_location)
}

post_body <- list(
token = token,
Expand Down
14 changes: 4 additions & 10 deletions man/redcap_download_file_oneshot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
\usage{
redcap_download_file_oneshot(file_name = NULL, directory = NULL,
overwrite = FALSE, redcap_uri, token, record, field, event = "",
verbose = TRUE, cert_location = NULL, sslversion = 3)
verbose = TRUE, config_options = NULL)
}
\arguments{
\item{file_name}{The name of the file where the
Expand Down Expand Up @@ -38,15 +38,9 @@ redcap_download_file_oneshot(file_name = NULL, directory = NULL,
\code{message}s should be printed to the R console during
the operation. Optional.}

\item{cert_location}{If present, this string should point
to the location of the cert files required for SSL
verification. If the value is missing or NULL, the
server's identity will be verified using a recent CA
bundle from the \href{http://curl.haxx.se}{cURL website}.
See the details below. Optional.}
\item{sslversion}{The SSL version for curl. The default
is 3. Set to NULL if your server has disabled SSL v3.}
\item{config_options}{A list of options to pass to
\code{POST} method in the \code{httr} package. See the
details below. Optional.}
}
\value{
Currently, a list is returned with the following elements,
Expand Down

0 comments on commit fc7f790

Please sign in to comment.