File: jurisdiction.R

package info (click to toggle)
r-cran-ritis 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,156 kB
  • sloc: sh: 13; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#' Get jurisdictional origin from tsn
#'
#' @export
#' @name jurisdiction
#' @inheritParams accepted_names
#' @template tsn
#' @return
#' \itemize{
#'  \item jurisdictional_origin: data.frame
#'  \item jurisdiction_origin_values: data.frame
#'  \item jurisdiction_values: character vector
#' }
#' @details Jurisdiction methods:
#' \itemize{
#'  \item jurisdictional_origin: Get jurisdictional origin from tsn
#'  \item jurisdiction_origin_values: Get jurisdiction origin values
#'  \item jurisdiction_values: Get all possible jurisdiction values
#' }
#' @examples \dontrun{
#' jurisdictional_origin(tsn=180543)
#' jurisdictional_origin(tsn=180543, wt = "xml")
#'
#' jurisdiction_origin_values()
#'
#' jurisdiction_values()
#' }
jurisdictional_origin <- function(tsn, wt = "json", raw = FALSE, ...) {
  out <- itis_GET("getJurisdictionalOriginFromTSN", list(tsn = tsn), wt, ...)
  if (raw || wt == "xml") return(out)
  z <- parse_raw(out)
  tibble::as_tibble(
    pick_cols(z$jurisdictionalOrigins, c("jurisdictionValue", "origin",
                                         "updateDate"))
  )
}

#' @export
#' @rdname jurisdiction
jurisdiction_origin_values <- function(wt = "json", raw = FALSE, ...) {
  out <- itis_GET("getJurisdictionalOriginValues", list(), wt, ...)
  if (raw || wt == "xml") return(out)
  tibble::as_tibble(
    pick_cols(parse_raw(out)$originValues, c("jurisdiction", "origin"))
  )
}

#' @export
#' @rdname jurisdiction
jurisdiction_values <- function(wt = "json", raw = FALSE, ...) {
  out <- itis_GET("getJurisdictionValues", list(), wt, ...)
  if (raw || wt == "xml") return(out)
  parse_raw(out)$jurisdictionValues
}