diff --git a/NAMESPACE b/NAMESPACE index 6b228b7f..f62e0f2f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,8 +18,6 @@ S3method(print,occ_download_describe) S3method(print,occ_download_get) S3method(print,occ_download_meta) S3method(print,occ_download_prep) -S3method(print,occ_download_sql) -S3method(print,occ_download_sql_prep) S3method(print,occ_predicate) S3method(print,occ_predicate_list) export("%>%") diff --git a/R/occ_download_sql.R b/R/occ_download_sql.R index 22d2711d..c140f5d8 100644 --- a/R/occ_download_sql.R +++ b/R/occ_download_sql.R @@ -5,22 +5,27 @@ #' @param user your GBIF user name #' @param pwd your GBIF password #' @param email your email address +#' @param validate should the query be validated before submission. Default is +#' TRUE. #' @param curlopts list of curl options #' #' @details #' This is an experimental feature, and the implementation may change throughout #' 2024. The feature is currently only available for preview by invited users. -#' Contact helpdesk@gbif.org to request access. +#' Contact `helpdesk@gbif.org` to request access. +#' +#' Please see the article here for more information: +#' \url{https://docs.ropensci.org/rgbif/articles/getting_occurrence_data.html} #' #' @return an object of class 'occ_download_sql' #' #' @references -#' https://techdocs.gbif.org/en/data-use/api-sql-downloads +#' \url{https://techdocs.gbif.org/en/data-use/api-sql-downloads} #' #' @name occ_download_sql #' @export #' -#' @examples /dontrun{ +#' @examples \dontrun{ #' occ_download_sql("SELECT gbifid,countryCode FROM occurrence #' WHERE genusKey = 2435098") #' } @@ -29,7 +34,8 @@ occ_download_sql <- function(q = NULL, format = "SQL_TSV_ZIP", user = NULL, pwd = NULL, - email = NULL, + email = NULL, + validate = TRUE, curlopts = list()) { z <- occ_download_sql_prep(q=q, @@ -37,6 +43,7 @@ occ_download_sql <- function(q = NULL, user=user, pwd=pwd, email=email, + validate=validate, curlopts=curlopts) out <- rg_POST(z$url, req = z$request, user = z$user, pwd = z$pwd, curlopts=curlopts) @@ -59,12 +66,14 @@ occ_download_sql <- function(q = NULL, #' @name occ_download_sql #' @export -occ_download_sql_validate <- function(req = NULL, user = NULL, pwd = NULL) { - stopifnot(is.list(req)) +occ_download_sql_validate <- function(q = NULL, + user = NULL, + pwd = NULL) { + stopifnot(is.list(q)) url <- "https://api.gbif.org/v1/occurrence/download/request/validate" user <- check_user(user) pwd <- check_pwd(pwd) - out <- rg_POST(url=url, req=req, user=user, pwd=pwd, curlopts=list()) + out <- rg_POST(url=url, req=q, user=user, pwd=pwd, curlopts=list()) out } @@ -94,7 +103,7 @@ occ_download_sql_prep <- function(q=NULL, sql = unbox(q) ) - if(validate) occ_download_sql_validate(req = req, user = user, pwd = pwd) + if(validate) occ_download_sql_validate(q = req, user = user, pwd = pwd) structure(list( url = url, @@ -109,8 +118,6 @@ occ_download_sql_prep <- function(q=NULL, } -#' @name occ_download_sql -#' @export print.occ_download_sql <- function(x) { stopifnot(inherits(x, 'occ_download_sql')) cat_n("<>") @@ -136,8 +143,7 @@ print.occ_download_sql <- function(x) { cat_n(" ", attr(x,"citation")) } -#' @name occ_download_sql -#' @export + print.occ_download_sql_prep <- function(x) { stopifnot(inherits(x, 'occ_download_sql_prep')) cat_n("<>") diff --git a/man/occ_download_sql.Rd b/man/occ_download_sql.Rd index 02daae10..df0a835f 100644 --- a/man/occ_download_sql.Rd +++ b/man/occ_download_sql.Rd @@ -4,8 +4,6 @@ \alias{occ_download_sql} \alias{occ_download_sql_validate} \alias{occ_download_sql_prep} -\alias{print.occ_download_sql} -\alias{print.occ_download_sql_prep} \title{Download occurrence data using a SQL query} \usage{ occ_download_sql( @@ -14,10 +12,11 @@ occ_download_sql( user = NULL, pwd = NULL, email = NULL, + validate = TRUE, curlopts = list() ) -occ_download_sql_validate(req = NULL, user = NULL, pwd = NULL) +occ_download_sql_validate(q = NULL, user = NULL, pwd = NULL) occ_download_sql_prep( q = NULL, @@ -28,10 +27,6 @@ occ_download_sql_prep( validate = TRUE, curlopts = list() ) - -\method{print}{occ_download_sql}(x) - -\method{print}{occ_download_sql_prep}(x) } \arguments{ \item{q}{sql query} @@ -44,6 +39,9 @@ occ_download_sql_prep( \item{email}{your email address} +\item{validate}{should the query be validated before submission. Default is +TRUE.} + \item{curlopts}{list of curl options} } \value{ @@ -55,15 +53,18 @@ Download occurrence data using a SQL query \details{ This is an experimental feature, and the implementation may change throughout 2024. The feature is currently only available for preview by invited users. -Contact helpdesk@gbif.org to request access. +Contact \code{helpdesk@gbif.org} to request access. + +Please see the article here for more information: +\url{https://docs.ropensci.org/rgbif/articles/getting_occurrence_data.html} } \examples{ -/dontrun{ +\dontrun{ occ_download_sql("SELECT gbifid,countryCode FROM occurrence WHERE genusKey = 2435098") } } \references{ -https://techdocs.gbif.org/en/data-use/api-sql-downloads +\url{https://techdocs.gbif.org/en/data-use/api-sql-downloads} }