Skip to content

Commit

Permalink
integrate sanitize_token()
Browse files Browse the repository at this point in the history
Closes #144
  • Loading branch information
wibeasley committed Mar 24, 2017
1 parent 14badb5 commit 5a41ae0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/redcap-read-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ redcap_read_oneshot <- function(
if( !(raw_or_label %in% c("raw", "label")) )
stop("The optional parameter `raw_or_label` must be either 'raw' or 'label'.")

token <- sub("\\n", "", token)
token <- sanitize_token(token)

if( all(nchar(records_collapsed)==0) )
records_collapsed <- ifelse(is.null(records), "", paste0(records, collapse=",")) #This is an empty string if `records` is NULL.
Expand Down
2 changes: 1 addition & 1 deletion R/redcap-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ redcap_read <- function(
if( missing(token) )
stop("The required parameter `token` was missing from the call to `redcap_read()`.")

token <- sub("\\n", "", token)
token <- sanitize_token(token)

if( all(nchar(records_collapsed)==0) )
records_collapsed <- ifelse(is.null(records), "", paste0(records, collapse=",")) #This is an empty string if `records` is NULL.
Expand Down
2 changes: 1 addition & 1 deletion R/redcap-upload-file-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ redcap_upload_file_oneshot <- function( file_name, record, redcap_uri, token, fi
if( missing(token) )
stop("The required parameter `token` was missing from the call to `redcap_upload_file_oneshot()`.")

token <- sub("\\n", "", token)
token <- sanitize_token(token)

if( verbose )
message("Preparing to upload the file `", file_name, "`.")
Expand Down
3 changes: 2 additions & 1 deletion R/redcap-write-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ redcap_write_oneshot <- function( ds, redcap_uri, token, verbose=TRUE, config_op
if( missing(token) )
stop("The required parameter `token` was missing from the call to `redcap_write_oneshot()`.")

token <- sub("\\n", "", token)
token <- sanitize_token(token)

con <- base::textConnection(object='csvElements', open='w', local=TRUE)
utils::write.csv(ds, con, row.names = FALSE, na="")
close(con)
Expand Down
6 changes: 3 additions & 3 deletions R/redcap-write.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ redcap_write <- function(
verbose = TRUE, config_options = NULL
) {

start_time <- base::Sys.time()

if( base::missing(redcap_uri) )
base::stop("The required parameter `redcap_uri` was missing from the call to `redcap_write()`.")

if( base::missing(token) )
base::stop("The required parameter `token` was missing from the call to `redcap_write()`.")

start_time <- base::Sys.time()

token <- sub("\\n", "", token)
token <- sanitize_token(token)

ds_glossary <- REDCapR::create_batch_glossary(row_count=base::nrow(ds_to_write), batch_size=batch_size)

Expand Down

0 comments on commit 5a41ae0

Please sign in to comment.