Skip to content

Commit 84d28d0

Browse files
committed
hardcode encode_httr in kernel_api()
ref #429
1 parent 12002e6 commit 84d28d0

8 files changed

+58
-39
lines changed

R/kernel-api.R

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#' [httr::POST()].
2121
#' This is useful for only unconventional authentication approaches. It
2222
#' should be `NULL` for most institutions.
23-
#' @param encode_httr The value passed to the `encode` parameter of
24-
#' [httr::POST()].
25-
#' This is useful for only unconventional authentication approaches.
26-
#' Defaults to `"multipart"`, which is appropriate for most institutions.
23+
# @param encode_httr The value passed to the `encode` parameter of
24+
# [httr::POST()].
25+
# This is useful for only unconventional authentication approaches.
26+
# Defaults to `"multipart"`, which is appropriate for most institutions.
2727
#'
2828
#' @return
2929
#' A [utils::packageVersion].
@@ -58,14 +58,14 @@ kernel_api <- function(
5858
config_options,
5959
encoding = "UTF-8",
6060
content_type = "text/csv",
61-
handle_httr = NULL,
62-
encode_httr = "multipart"
61+
handle_httr = NULL
62+
# encode_httr = "multipart"
6363
) {
6464

6565
checkmate::assert_character(redcap_uri , len = 1, any.missing = FALSE, null.ok = FALSE)
6666
checkmate::assert_character(encoding , len = 1, any.missing = FALSE, null.ok = FALSE)
6767
checkmate::assert_character(content_type , len = 1, any.missing = FALSE, null.ok = FALSE)
68-
checkmate::assert_character(encode_httr , len = 1, any.missing = FALSE, null.ok = FALSE)
68+
# checkmate::assert_character(encode_httr , len = 1, any.missing = FALSE, null.ok = FALSE)
6969

7070
start_time <- Sys.time()
7171

@@ -78,7 +78,7 @@ kernel_api <- function(
7878
body = post_body,
7979
config = config_options,
8080
handle = handle_httr,
81-
encode = encode_httr,
81+
encode = "multipart",
8282
httr::user_agent("OuhscBbmc/REDCapR")
8383
)
8484

R/redcap-metadata-read.R

+13-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#' be visible somewhere public. Optional.
2828
#' @param config_options A list of options passed to [httr::POST()].
2929
#' See details at [httr::httr_options()]. Optional.
30+
#' @param handle_httr The value passed to the `handle` parameter of
31+
#' [httr::POST()].
32+
#' This is useful for only unconventional authentication approaches. It
33+
#' should be `NULL` for most institutions. Optional.
3034
#'
3135
#' @return
3236
#' Currently, a list is returned with the following elements:
@@ -74,7 +78,8 @@ redcap_metadata_read <- function(
7478
fields = NULL,
7579
fields_collapsed = "",
7680
verbose = TRUE,
77-
config_options = NULL
81+
config_options = NULL,
82+
handle_httr = NULL
7883
) {
7984

8085
checkmate::assert_character(redcap_uri , any.missing=FALSE, len=1, pattern="^.{1,}$")
@@ -99,7 +104,13 @@ redcap_metadata_read <- function(
99104
)
100105

101106
# This is the important line that communicates with the REDCap server.
102-
kernel <- kernel_api(redcap_uri, post_body, config_options)
107+
kernel <-
108+
kernel_api(
109+
redcap_uri = redcap_uri,
110+
post_body = post_body,
111+
config_options = config_options,
112+
handle_httr = handle_httr
113+
)
103114

104115
if (kernel$success) {
105116
try(

R/redcap-read-oneshot.R

+10-10
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@
8888
#' @param handle_httr The value passed to the `handle` parameter of
8989
#' [httr::POST()].
9090
#' This is useful for only unconventional authentication approaches. It
91-
#' should be `NULL` for most institutions.
92-
#' @param encode_httr The value passed to the `encode` parameter of
93-
#' [httr::POST()].
94-
#' This is useful for only unconventional authentication approaches.
95-
#' Defaults to `"multipart"`, which is appropriate for most institutions.
91+
#' should be `NULL` for most institutions. Optional.
92+
# @param encode_httr The value passed to the `encode` parameter of
93+
# [httr::POST()].
94+
# This is useful for only unconventional authentication approaches.
95+
# Defaults to `"multipart"`, which is appropriate for most institutions.
9696
#'
9797
#' @return
9898
#' Currently, a list is returned with the following elements:
@@ -203,8 +203,8 @@ redcap_read_oneshot <- function(
203203
locale = readr::default_locale(),
204204
verbose = TRUE,
205205
config_options = NULL,
206-
handle_httr = NULL,
207-
encode_httr = "multipart"
206+
handle_httr = NULL
207+
# encode_httr = "multipart"
208208
) {
209209

210210
checkmate::assert_character(redcap_uri , any.missing=FALSE, len=1, pattern="^.{1,}$")
@@ -237,7 +237,7 @@ redcap_read_oneshot <- function(
237237
checkmate::assert_class( locale, "locale" , null.ok = FALSE)
238238
checkmate::assert_logical( verbose , any.missing=FALSE, len=1, null.ok=TRUE)
239239
checkmate::assert_list( config_options , any.missing=TRUE , null.ok=TRUE)
240-
checkmate::assert_character(encode_httr , any.missing=FALSE, len=1, null.ok = FALSE)
240+
# checkmate::assert_character(encode_httr , any.missing=FALSE, len=1, null.ok = FALSE)
241241

242242
validate_field_names(fields, stop_on_error = TRUE)
243243

@@ -283,8 +283,8 @@ redcap_read_oneshot <- function(
283283
post_body = post_body,
284284
config_options = config_options,
285285
encoding = http_response_encoding,
286-
handle_httr = handle_httr,
287-
encode_httr = encode_httr
286+
handle_httr = handle_httr
287+
# encode_httr = encode_httr
288288
)
289289

290290
if (kernel$success) {

R/redcap-read.R

+11-3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
#' be visible somewhere public. Optional.
9797
#' @param config_options A list of options passed to [httr::POST()].
9898
#' See details at [httr::httr_options()]. Optional.
99+
#' @param handle_httr The value passed to the `handle` parameter of
100+
#' [httr::POST()].
101+
#' This is useful for only unconventional authentication approaches. It
102+
#' should be `NULL` for most institutions. Optional.
99103
#' @param id_position The column position of the variable that unique
100104
#' identifies the subject (typically `record_id`).
101105
#' This defaults to the first variable in the dataset.
@@ -216,6 +220,7 @@ redcap_read <- function(
216220
locale = readr::default_locale(),
217221
verbose = TRUE,
218222
config_options = NULL,
223+
handle_httr = NULL,
219224
id_position = 1L
220225
) {
221226

@@ -270,7 +275,8 @@ redcap_read <- function(
270275
redcap_uri = redcap_uri,
271276
token = token,
272277
verbose = verbose,
273-
config_options = config_options
278+
config_options = config_options,
279+
handle_httr = handle_httr
274280
)
275281

276282
if (!metadata$success) {
@@ -296,7 +302,8 @@ redcap_read <- function(
296302
http_response_encoding = http_response_encoding,
297303
locale = locale,
298304
verbose = verbose,
299-
config_options = config_options
305+
config_options = config_options,
306+
handle_httr = handle_httr
300307
)
301308

302309
# Stop and return to the caller if the initial query failed. --------------
@@ -371,7 +378,8 @@ redcap_read <- function(
371378
http_response_encoding = http_response_encoding,
372379
locale = locale,
373380
verbose = verbose,
374-
config_options = config_options
381+
config_options = config_options,
382+
handle_httr = handle_httr
375383
)
376384

377385
lst_status_code[[i]] <- read_result$status_code

man/kernel_api.Rd

+1-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/redcap_metadata_read.Rd

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/redcap_read.Rd

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/redcap_read_oneshot.Rd

+2-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)