R/data_cities.R

#' data_cities
#'
#' \code{data_cities} provides the options to filter \code{get_occurences} by city.
#' The user can select more than one city when applying the function \code{get_occurences}
#'
#' @param \code{add_token}: add the user's token to access the API.
#' @usage data_cities(add_token=xxxx)
#' @return it returns a dataframe of with the options available in the API to filter by city
#' The values can be used to filter the cases in the function \code{get_occurrences}
#' #' @examples
#' data_cities()
#' @import httr
#' @import rvest
#' @import purrr
#' @import jsonlite
#' @import tibble
#' @importFrom magrittr "%>%"
#' @export

data_cities <- function(add_token){

  endpoint <- "/cities"

  response <- httr::GET(paste0(base, endpoint),
                        add_headers('Authorization' = paste("Bearer", add_token, sep = " ")))

  jsonlite::fromJSON(httr::content(response, as="text")) %>% tibble::as_tibble()

}
TiagoVentura/get_fogocruzado documentation built on June 27, 2019, 12:19 a.m.