R/enrichResponse.R

Defines functions .enrichResponse

#' Enrich API response data.
#'
#' This helper function takes a list containing API response data and enriches
#' it with metadata, including the URL queried and the timestamp of the query.
#'
#' @param responseData `list` or `data.frame`. A structure representing the API
#'   response.
#'
#' @param url `character` (string). The URL that was queried.
#'
#' @return A list containing the original API response data, along with
#'   two additional fields: `queried_on`, the timestamp when the data was
#'   queried, and `queried_url`, the URL used for the API request.
#' 
#' @importFrom checkmate assert assert_string check_list check_data_frame
#' 
#' @keywords internal
#' @noRd
#'
.enrichResponse <- function(responseData, url) {
  
  assert(check_list(responseData), check_data_frame(responseData))
  assert_string(url)
  
  responseData$queried_on <- Sys.time()
  responseData$queried_url <- url
  
  return(responseData)
}

Try the eppoFindeR package in your browser

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

eppoFindeR documentation built on April 25, 2026, 1:07 a.m.