Skip to content

Commit

Permalink
Merge pull request #526 from jrob95/patch-1
Browse files Browse the repository at this point in the history
Update redcap-survey-link-export-oneshot.R
  • Loading branch information
wibeasley authored Aug 12, 2024
2 parents e97e124 + 076c268 commit 8c75a12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions R/redcap-survey-link-export-oneshot.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @title
#' Download a file from a REDCap project record
#' Get survey link from REDCap
#'
#' @description
#' This function uses REDCap's API to download a file.
#' This function uses REDCap's API to get the link for a survey.
#'
#' @param redcap_uri The
#' [uri](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)/url
Expand All @@ -11,10 +11,12 @@
#' Required.
#' @param token The user-specific string that serves as the password for a
#' project. Required.
#' @param record The record ID where the file is to be imported. Required
#' @param record The record ID associated with the
#' survey link. Required
#' @param instrument The name of the instrument associated with the
#' survey link. Required
#' @param event The name of the event where the file is saved in REDCap.
#' @param event The name of the event associated with the
#' survey link.
#' Optional
#' @param verbose A boolean value indicating if `message`s should be printed
#' to the R console during the operation. Optional.
Expand All @@ -27,21 +29,22 @@
#'
#' @return
#' Currently, a list is returned with the following elements,
#' * `survey_link`: a character string containing the URL for the survey.
#' * `success`: A boolean value indicating if the operation was apparently
#' successful.
#' * `status_code`: The
#' [http status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
#' of the operation.
#' * `outcome_message`: A human readable string indicating the operation's
#' outcome.
#' * `records_affected_count`: The number of records inserted or updated.
#' * `affected_ids`: The subject IDs of the inserted or updated records.
#' * `instrument`: The instrument associated with the survey link.
#' * `records_affected_count`: The number of records associated with
#' the survey link.
#' * `affected_ids`: The subject IDs associated with the survey link.
#' * `elapsed_seconds`: The duration of the function.
#' * `raw_text`: If an operation is NOT successful, the text returned by
#' REDCap. If an operation is successful, the `raw_text` is returned as an
#' empty string to save RAM.
#' * `file_name`: The name of the file persisted to disk. This is useful if
#' the name stored in REDCap is used (which is the default).
#'
#' @details
#' Currently, the function doesn't modify any variable types to conform to
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-survey-link-export-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test_that("Nonexistent Record ID", {
expect_equal(result$instrument, "participant_morale_questionnaire")
expect_equal(result$records_affected_count, 0L)
expect_equal(result$affected_ids, character(0))
expect_equal(result$raw_text, "ERROR: The record '-1' does not exist")
expect_equal(result$raw_text, "ERROR: The record \"-1\" does not exist")
})

rm(credential, record, instrument)

0 comments on commit 8c75a12

Please sign in to comment.