R/get_business_types.R

Defines functions get_business_types

Documented in get_business_types

#' Get business types
#'
#' Fetches the list of business types in the FHRS
#'
#' `get_business_types` makes an API call that returns the business types that
#' can be found in the FHRS, and their code, which can be used to filter other
#' API calls. It takes no parameters.
#'
#' @return A tibble of business types and their codes
#'
#' @examples get_business_types()
#'
#' @export
#'
get_business_types <- function() {
  getbtype <- httr::GET("https://api.ratings.food.gov.uk/BusinessTypes", httr::add_headers('x-api-version' = 2))
  httr::content(getbtype, "text") %>%
    jsonlite::fromJSON() %>%
    .$businessTypes %>%
    tibble::as_tibble() %>%
    dplyr::filter(BusinessTypeId != -1) %>%
    dplyr::select(1:2)
}
helen-food/fhrsdata documentation built on Aug. 21, 2019, 12:22 p.m.