## ----include=FALSE------------------------------------------------------------
hab_available <- tryCatch({
  httr::status_code(httr::GET("https://www.marinespecies.org/hab/",
                               httr::timeout(5))) < 400
}, error = function(e) FALSE)

toxin_available <- tryCatch({
  httr::status_code(httr::GET("https://toxins.hais.ioc-unesco.org/",
                               httr::timeout(5))) < 400
}, error = function(e) FALSE)

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

## -----------------------------------------------------------------------------
library(SHARK4R)

## ----include=FALSE, eval=hab_available----------------------------------------
hab_list <- try(get_hab_list(), silent = TRUE)
if (inherits(hab_list, "try-error")) hab_available <- FALSE

## ----eval=FALSE---------------------------------------------------------------
# # Retrieve complete HAB list
# hab_list <- get_hab_list()
# 
# # Print result
# print(hab_list)

## ----echo=FALSE, eval=hab_available-------------------------------------------
print(hab_list)

## ----include=FALSE, eval=hab_available----------------------------------------
hab_non_toxic_list <- try(
  get_hab_list(harmful_non_toxic_only = TRUE, verbose = FALSE),
  silent = TRUE
)
if (inherits(hab_non_toxic_list, "try-error")) hab_available <- FALSE

## ----eval=FALSE---------------------------------------------------------------
# # Retrieve complete Harmful non-toxic list
# hab_non_toxic_list <- get_hab_list(harmful_non_toxic_only = TRUE,
#                                    verbose = FALSE)
# 
# # Print result
# print(hab_non_toxic_list)

## ----echo=FALSE, eval=hab_available-------------------------------------------
print(hab_non_toxic_list)

## ----include=FALSE, eval=toxin_available--------------------------------------
toxin_list <- try(get_toxin_list(), silent = TRUE)
if (inherits(toxin_list, "try-error")) toxin_available <- FALSE

## ----eval=FALSE---------------------------------------------------------------
# # Retrieve complete toxin list
# toxin_list <- get_toxin_list()
# 
# # Print result
# print(toxin_list)

## ----echo=FALSE, eval=toxin_available-----------------------------------------
print(toxin_list)

## ----echo=FALSE---------------------------------------------------------------
# Print citation
citation("SHARK4R")

## ----echo=FALSE---------------------------------------------------------------
clean_shark4r_cache(0, clear_perm_cache = TRUE, verbose = FALSE)

