## ----include=FALSE------------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----eval=FALSE---------------------------------------------------------------
# install.packages("eppoFindeR")

## ----eval=FALSE---------------------------------------------------------------
# # install.packages("devtools")
# devtools::install_github("openefsa/eppoFindeR")

## ----apiKeyExample, eval=FALSE------------------------------------------------
# taxon(c("BEMITA"), apiKey = "<your_eppo_api_key>")

## ----loadLibrary, eval=FALSE--------------------------------------------------
# library(eppoFindeR)

## ----eval=FALSE---------------------------------------------------------------
# help("<function_name>")

## ----eval=FALSE---------------------------------------------------------------
# help("taxon")

## ----taxonAllServices, eval=FALSE---------------------------------------------
# taxon(c("BEMITA"))

## ----toolsName2Codes, eval=FALSE----------------------------------------------
# tools(
#   c("name2codes"), # The service to query (/tools/name2codes).
#   params = list(
#     name2codes = list(
#       name = "Bemisia tabaci" # The required parameter.
#     )
#   )
# )

## ----queryService, eval=FALSE-------------------------------------------------
# taxon(c("BEMITA"), c("categorization"))

## ----queryServiceOutput, eval=FALSE-------------------------------------------
# $categorization
# # A tibble: 20 × 12
#    queried_eppo_code continent_id continent_name country_iso country_name    qlist qlist_label year_add
#    <chr>                    <int> <chr>          <chr>       <chr>           <chr> <chr>          <int>
#  1 BEMITA                       4 America        CL          Chile           1     A1 list         2019
#  2 BEMITA                       2 Asia           BH          Bahrain         2     A2 list         2003
#  3 BEMITA                       2 Asia           KZ          Kazakhstan      1     A1 list         2017
#  4 BEMITA                       1 Europe         AZ          Azerbaijan      1     A1 list         2024
#  5 BEMITA                       1 Europe         BY          Belarus         X     Quarantine…     1994
#  6 BEMITA                       1 Europe         GE          Georgia         1     A1 list         2018
#  7 BEMITA                       1 Europe         MD          Moldova, Repub… X     Quarantine…     2017
#  8 BEMITA                       1 Europe         NO          Norway          X     Quarantine…     2012
#  9 BEMITA                       1 Europe         RU          Russian Federa… 2     A2 list         2014
# 10 BEMITA                       1 Europe         RS          Serbia          1     A1 list         2015
# 11 BEMITA                       1 Europe         CH          Switzerland     1     A1 list         2019
# 12 BEMITA                       1 Europe         TR          Türkiye         2     A2 list         2016
# 13 BEMITA                       1 Europe         UA          Ukraine         1     A1 list         2019
# 14 BEMITA                       1 Europe         GB          United Kingdom  1     A1 list         2020
# 15 BEMITA                       5 Oceania        NZ          New Zealand     X     Quarantine…     2000
# 16 BEMITA                       6 RPPO/EU        9M          EAEU            2     A2 list         2016
# 17 BEMITA                       6 RPPO/EU        9A          EPPO            2     A2 list         1989
# 18 BEMITA                       6 RPPO/EU        9L          EU              P     PZ Quarant…     2019
# 19 BEMITA                       6 RPPO/EU        9L          EU              N     A1 Quarant…     2019
# 20 BEMITA                       6 RPPO/EU        9H          OIRSA           2     A2 list         1992
# # ℹ 4 more variables: year_delete <lgl>, year_transient <lgl>, queried_url <chr>, queried_on <dttm>

## ----queryWhole, eval=FALSE---------------------------------------------------
# data <- taxon(c("BEMITA"))

## ----queryAllOutput, eval=FALSE-----------------------------------------------
# # Print the names of the services in the result.
# names(data)
#  [1] "overview"           "infos"              "names"              "taxonomy"
#  [5] "categorization"     "kingdom"            "hosts"              "pests"
#  [9] "vectors"            "vectorof"           "bca"                "bcaof"
# [13] "photos"             "reporting_articles" "documents"          "standards"
# [17] "distribution"
# 
# # Print the data from a specific service.
# data$overview
# # A tibble: 1 × 11
#   queried_eppo_code eppocode datecreate         lastupdate infos replacedby prefname is_active datatype
#   <chr>             <chr>    <chr>              <chr>      <lgl> <lgl>      <chr>    <lgl>     <chr>
# 1 BEMITA            BEMITA   2002-10-28 00:00:… 2002-10-2… NA    NA         Bemisia… TRUE      GAI
# # ℹ 2 more variables: queried_url <chr>, queried_on <dttm>

## ----eval=FALSE---------------------------------------------------------------
# data <- taxon(c("BEMITA"), c("taxonomy"))

## ----uniformTaxonomy, eval=FALSE----------------------------------------------
# taxonomy <- uniformTaxonomy(data$taxonomy)

## ----uniformTaxonomyOutput, eval=FALSE----------------------------------------
# # A tibble: 11 × 6
#    type      queried_eppo_code eppocode prefname       queried_url                  queried_on
#    <chr>     <chr>             <chr>    <chr>          <chr>                        <dttm>
#  1 Kingdom   BEMITA            1ANIMK   Animalia       https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
#  2 Phylum    BEMITA            1ARTHP   Arthropoda     https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
#  3 Subphylum BEMITA            1HEXAQ   Hexapoda       https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
#  4 Class     BEMITA            1INSEC   Insecta        https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
#  5 Subclass  NA                NA       NA             NA                           NA
#  6 Order     BEMITA            1HEMIO   Hemiptera      https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
#  7 Suborder  BEMITA            1STERR   Sternorrhyncha https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
#  8 Family    BEMITA            1ALEYF   Aleyrodidae    https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
#  9 Subfamily NA                NA       NA             NA                           NA
# 10 Genus     BEMITA            1BEMIG   Bemisia        https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50
# 11 Species   BEMITA            BEMITA   Bemisia tabaci https://api.eppo.int/gd/v2/… 2025-11-18 14:29:50

## ----multipleEPPOCodes, eval=FALSE--------------------------------------------
# data <- taxon(c("BEMITA", "GOSHI"))

## ----multipleEPPOCodesOutput, eval=FALSE--------------------------------------
# # Print the names of the services in the result.
# names(data)
#  [1] "overview"           "infos"              "names"              "taxonomy"
#  [5] "categorization"     "kingdom"            "hosts"              "pests"
#  [9] "vectors"            "vectorof"           "bca"                "bcaof"
# [13] "photos"             "reporting_articles" "documents"          "standards"
# [17] "distribution"
# 
# # Print the data from a specific service.
# data$overview
# # A tibble: 2 × 11
#   queried_eppo_code eppocode datecreate         lastupdate infos replacedby prefname is_active datatype
#   <chr>             <chr>    <chr>              <chr>      <chr> <lgl>      <chr>    <lgl>     <chr>
# 1 BEMITA            BEMITA   2002-10-28 00:00:… 2002-10-2… NA    NA         Bemisia… TRUE      GAI
# 2 GOSHI             GOSHI    2004-04-21 00:00:… 2004-04-2… <p>M… NA         Gossypi… TRUE      PFL
# # ℹ 2 more variables: queried_url <chr>, queried_on <dttm>

