R/exportUserDagAssignments.R

Defines functions exportUserDagAssignments.redcapApiConnection exportUserDagAssignments

Documented in exportUserDagAssignments exportUserDagAssignments.redcapApiConnection

# Complete documentation in documentation.R
#' @describeIn dagAssignmentMethods Export current User-DAG Assignments
#' @order 1
#' @export

exportUserDagAssignments <- function(rcon, 
                                     ...){
  UseMethod("exportUserDagAssignments")
}

#' @rdname dagAssignmentMethods
#' @export

exportUserDagAssignments.redcapApiConnection <- function(rcon, 
                                                         ...)
{
  ###################################################################
  # Argument Validation                                          ####
  
  coll <- checkmate::makeAssertCollection()
  
  checkmate::assert_class(x = rcon, 
                          classes = "redcapApiConnection", 
                          add = coll)

  checkmate::reportAssertions(coll)
  
  ###################################################################
  # Build the body list                                          ####
  
  body <- list(content = "userDagMapping", 
               format = "csv", 
               returnFormat = "csv")

  ###################################################################
  # Make the API Call                                            ####
  
  response <- as.data.frame(makeApiCall(rcon, body, ...))

  if(nrow(response) == 0) REDCAP_DAG_ASSIGNMENT_STRUCTURE else response
}

Try the redcapAPI package in your browser

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

redcapAPI documentation built on Oct. 17, 2024, 5:07 p.m.