Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
tweaks to eol() method, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Apr 30, 2018
1 parent f26dc15 commit 3d54d55
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Get species origin data (whether species is native/invasive) from t
(<http://bien.nceas.ucsb.edu/bien/tools/nsr/nsr-ws/>), Integrated Taxonomic
Information Service (<http://www.itis.gov/>), and Global Register of
Introduced and Invasive Species (<http://www.griis.org/>).
Version: 0.2.3.9210
Version: 0.2.5.9110
Authors@R: c(
person("Scott", "Chamberlain", role = c("aut", "cre"), email = "myrmecocystus@gmail.com"),
person("Ignasi", "Bartomeus", role = "aut", email = "nacho.bartomeus@gmail.com")
Expand All @@ -17,7 +17,7 @@ License: MIT + file LICENSE
URL: https://github.com/ropensci/originr
BugReports: https://github.com/ropensci/originr/issues
Imports:
crul (>= 0.4),
crul (>= 0.5.2),
jsonlite (>= 1.5),
data.table,
xml2,
Expand Down
18 changes: 9 additions & 9 deletions R/eol.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @param page A maximum of 30 results are returned per page. This parameter
#' allows you to fetch more pages of results if there are more than 30 matches
#' (Default: 1)
#' @param per_page Results to get per page
#' @param per_page Results to get per page. Default: 500
#' @param key Your EOL API key; loads from .Rprofile.
#' @param messages (logical) If \code{TRUE} the actual taxon queried is printed
#' on the console.
Expand Down Expand Up @@ -88,7 +88,7 @@
#' eol(name='Sargassum', dataset='gisd', verbose = TRUE)
#' }
eol <- function(name, dataset="all", searchby = grep, page=NULL,
per_page=NULL, key = NULL, messages=TRUE, count=FALSE, ...) {
per_page=500, key = NULL, messages=TRUE, count=FALSE, ...) {

if (any(nchar(name) < 1)) stop("'name' must be longer than 0 characters")
if (is.null(dataset)) stop("please provide a dataset name")
Expand All @@ -101,12 +101,12 @@ eol <- function(name, dataset="all", searchby = grep, page=NULL,
i3n = 55176,
mineps = 55331)

args <- orc(list(id = datasetid, page = page, per_page = 500,
filter = 'taxa'))
args <- orc(list(page = page, per_page = 500, filter = 'taxa'))
path <- sprintf("/api/collections/1.0/%s.json", datasetid)

cli <- crul::HttpClient$new(url = 'http://eol.org/api/collections/1.0.json',
cli <- crul::HttpClient$new(url = 'http://eol.org',
opts = list(...))
tt <- cli$get(query = args)
tt <- cli$get(path, query = args)
tt$raise_for_status()
res <- jsonlite::fromJSON(tt$parse("UTF-8"), FALSE)
data_init <- res$collection_items
Expand All @@ -117,9 +117,8 @@ eol <- function(name, dataset="all", searchby = grep, page=NULL,
if (!is.null(pages_get)) {
out <- list()
for (i in pages_get) {
args <- orc(list(id = datasetid, page = i, per_page = 500,
filter = 'taxa'))
tt <- cli$get(query = args)
args <- orc(list(page = i, per_page = 500, filter = 'taxa'))
tt <- cli$get(path, query = args)
tt$raise_for_status()
res <- jsonlite::fromJSON(tt$parse("UTF-8"), FALSE)
out[[i]] <- res$collection_items
Expand All @@ -142,6 +141,7 @@ eol <- function(name, dataset="all", searchby = grep, page=NULL,
df$db <- dataset
names(df)[c(1,3)] <- c("searched_name","eol_object_id")
row.names(df) <- NULL
if (NROW(df) > 0) df <- df[!duplicated(df), ]
if (!count) df else length(stats::na.omit(df$eol_object_id))
}

Expand Down
6 changes: 3 additions & 3 deletions man/eol.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3d54d55

Please sign in to comment.