# WARNING - Generated by {fusen} from dev/flat_scenario.Rmd: do not edit by hand # nolint: line_length_linter.

#' Crop Query
#' 
#' Query to return crop ID from crop Name in crop database
#' @param config list configuration file default value is config_ambre dataset
#' @param cropName character Name of crop for which you want to find the identifier
#' @importFrom dplyr filter pull
#' @return cropID integer
#' 
#' @export
#' @examples
#' query_crop(cropName = "Corn seed")
query_crop <- function(config = config_ambre, cropName) {
  allowed_crop <- c("Corn seed", "Potato", "Tomato", "Onion", "Apple", "Salad")
  if (any(!cropName %in% allowed_crop)){
    stop("Crop name doesn't exist")}

  config$crop |>
    filter(CropName %in% cropName) |>   # filtre sur la valeur fournie
    pull(CropID) 
    
}
