I'm having some trouble getting the syntax on getting a plumbed function when that function is defined in another file.
I want to put a standard plumb function in a package. My first try was something like this:
# in the package
#' Get results for plumber
#'
#' @param client the clientname
#' @param date The date of data to fetch
#' @param config a config file
#'
#' @export
plumber_ga <- function(client = "none", date = Sys.Date(), config = NULL){
message("Calling API for client:", client, " for date:", date)
...
}
and then trying to call that function in an API file:
# api.R
#* Get data
#* @param client the clientname
#* @param date One day of data to fetch
#* @param config A config file TBD
#* @post /datalake/<client>/foo
plumber_ga(client = "none", date = Sys.Date(), config = NULL){
...
}
...but when I try that, I get an client is not defined
error. Is there a way to do this? I guess the annotations clash or something - or do I need to define the function only once in the api.R file?
The same function works if called directly:
# api.R
#* Get data
#* @param client the clientname
#* @param date One day of data to fetch
#* @param config A config file TBD
#* @post /datalake/<client>/foo
function(client = "none", date = Sys.Date(), config = NULL){
...
}
(also asked on the package GitHub)