Skip to content

Commit

Permalink
get_historical* functions added
Browse files Browse the repository at this point in the history
  • Loading branch information
machmaleinheelflip committed May 2, 2024
1 parent 56503bd commit 24e44e1
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,29 @@ get_projects <- function(...) {
}


#' Get historical projects list.
#'
#' Wrapper around the 'ListView historicalprojects' endpoint to retrieve a list of historical projects based on the specified query parameters.
#'
#' @param ... query paramaters. See \url(https://api.ecopi.de/api/v0.1/docs/#operation/historicalprojects_list)
#'
#' @examples
#' # retrieve a dataframe of all historical projects
#' get_historicalprojects()
#'
#' # Retrieve a list of projects that contain 'red_panda' or 'green_banana' in their name
#' get_historicalprojects(project_name__in = "red_panda, green_banana")
#'
#' @return A dataframe containing the historical projects that match the specified query parameters: \url{https://api.ecopi.de/api/v0.1/docs/#operation/historicalprojects_list}.
#'
#' @export
get_historicalprojects <- function(...) {
params <- list(...)
ecopi_api("GET /historicalprojects/", params = params) |>
resp_body_json_to_df()
}


#' Get project info.
#'
#' Wrapper around the 'projects_read' endpoint to retrieve information about a specific project.
Expand Down Expand Up @@ -238,6 +261,27 @@ get_recordergroups <- function(...) {
}


#' Get historical recorder groups list.
#'
#' Wrapper around the 'ListView historicalrecordergroups' endpoint to retrieve a list of recorder groups based on the specified query parameters.
#' This contains the configurations and species list
#'
#' @param ... query paramaters. See \url{https://api.ecopi.de/api/v0.1/docs/#operation/historicalrecordergroups_list}.
#'
#' @examples
#' # Retrieve a data frame of historical recorder groups for project 'oekofor'
#' get_historicalrecordergroups(project_name = "oekofor")
#'
#' @return A list containing the historical recorder groups that match the specified query parameters: \url{https://api.ecopi.de/api/v0.1/docs/#operation/historicalrecordergroups_list}.
#'
#' @export
get_historicalrecordergroups <- function(...) {
params <- list(...)
ecopi_api("GET /historicalrecordergroups/", params = params) |>
resp_body_json_to_df()
}


#' Get recorder group info.
#'
#' Wrapper around the 'recordergroups_read' endpoint to retrieve information about a specific recorder group.
Expand Down Expand Up @@ -337,6 +381,26 @@ get_recorders <- function(...) {
}


#' Get historical recorders list.
#'
#' Wrapper around the 'ListView historicalrecorders' endpoint to retrieve a list of recorders based on the specified query parameters.
#'
#' @param ... query paramaters. See \url{https://api.ecopi.de/api/v0.1/docs/#operation/historicalrecorders_list}.
#'
#' @examples
#' # Retrieve a list of historical recorders for project '017_neeri'
#' get_historicalrecorders(project_name = "017_neerach_ried")
#'
#' @return A dataframe containing the historical recorders that match the specified query parameters: \url{https://api.ecopi.de/api/v0.1/docs/#operation/historicalrecorders_list}.
#'
#' @export
get_historicalrecorders <- function(...) {
params <- list(...)
ecopi_api("GET /historicalrecorders/", params = params) |>
resp_body_json_to_df()
}


#' Get recorder info.
#'
#' Wrapper around the 'recorders_read' endpoint to retrieve information about a specific recorder.
Expand Down

0 comments on commit 24e44e1

Please sign in to comment.