diff --git a/R/api-gol.R b/R/api-gol.R index 58881aa8..6299d8ae 100644 --- a/R/api-gol.R +++ b/R/api-gol.R @@ -2,11 +2,7 @@ ## Summary information about the Graph of Life .gol_about <- function(...) { res <- otl_POST(path="graph/about", body=list(), ...) - cont <- otl_parse(res) - if (length(cont) < 1) { - warning("Nothing returned") - } - return(cont) + res } @@ -33,8 +29,7 @@ q <- list(study_id=jsonlite::unbox(study_id), tree_id=jsonlite::unbox(tree_id), git_sha=jsonlite::unbox(git_sha)) res <- otl_POST(path="graph/source_tree", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } ##' @importFrom jsonlite unbox @@ -53,6 +48,5 @@ q <- list(ott_id=jsonlite::unbox(ott_id), include_lineage=jsonlite::unbox(include_lineage)) } res <- otl_POST(path="graph/node_info", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } diff --git a/R/api-studies.R b/R/api-studies.R index 5369a39f..5ac6905c 100644 --- a/R/api-studies.R +++ b/R/api-studies.R @@ -28,8 +28,7 @@ res <- otl_POST(path="studies/find_studies/", body=req_body, ...) - cont <- otl_parse(res) - return(cont) + res } ##' @importFrom jsonlite unbox @@ -65,8 +64,7 @@ body=c(req_body, jsonlite::unbox(verbose), jsonlite::unbox(exact)), ...) - cont <- otl_parse(res) - return(cont) + res } @@ -74,8 +72,7 @@ ## Return a list of properties that can be used to search studies and trees .studies_properties <- function() { res <- otl_POST(path="studies/properties/", body=list()) - cont <- otl_parse(res) - return(cont) + res } @@ -92,8 +89,7 @@ res <- otl_GET(path=paste("study", paste0(study_id, otl_formats(format)), sep="/"), ...) - cont <- otl_parse(res) - return(cont) + res } @@ -117,13 +113,12 @@ tip_label <- paste0("/?tip_label=", tip_label) tree_file <- paste0(tree_id, otl_formats(format), tip_label) res <- otl_GET(path=paste("study", study_id, "tree", tree_file, sep="/"), ...) - cont <- otl_parse(res) - return(cont) + res } ##' @importFrom httr content .get_study_meta <- function(study_id, ...) { - otl_parse(otl_GET(path= paste("study", study_id, "meta", sep="/"), ...)) + otl_GET(path= paste("study", study_id, "meta", sep="/"), ...) } @@ -149,7 +144,7 @@ format <- otl_formats(format) url_stem <- paste("study", study_id, "tree", paste0(tree_id, format), sep="/") res <- otl_GET(path=paste(url_stem, "?subtree_id=", subtree_id, sep=""), ...) - otl_parse(res) + res } ### Let's not worry about those for now, as their results could be diff --git a/R/api-taxonomy.R b/R/api-taxonomy.R index 5bc7a0af..730a899b 100644 --- a/R/api-taxonomy.R +++ b/R/api-taxonomy.R @@ -2,9 +2,7 @@ ## Summary information about the OpenTree Taxaonomy (OTT) .taxonomy_about <- function(...) { res <- otl_POST(path="/taxonomy/about", body=list(), ...) - cont <- otl_parse(res) - - return(cont) + res } @@ -28,8 +26,7 @@ include_lineage = jsonlite::unbox(include_lineage), list_terminal_descendants = jsonlite::unbox(list_terminal_descendants)) res <- otl_POST(path="/taxonomy/taxon", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } @@ -46,8 +43,7 @@ } q <- list(ott_id=jsonlite::unbox(ott_id)) res <- otl_POST(path="/taxonomy/subtree", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } @@ -61,6 +57,5 @@ } q <- list(ott_ids=ott_ids) res <- otl_POST(path="/taxonomy/lica", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } diff --git a/R/api-tnrs.R b/R/api-tnrs.R index 4f9b9275..b57b78b9 100644 --- a/R/api-tnrs.R +++ b/R/api-tnrs.R @@ -40,8 +40,7 @@ q <- q[!toKeep] res <- otl_POST("tnrs/match_names", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } @@ -49,8 +48,7 @@ ## Get OpenTree TNRS contexts .tnrs_contexts <- function(...) { res <- otl_POST("tnrs/contexts", body=list(), ...) - cont <- otl_parse(res) - return(cont) + res } @@ -63,6 +61,5 @@ } q <- list(names=names) res <- otl_POST("tnrs/infer_context", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } diff --git a/R/api-tol.R b/R/api-tol.R index 7dc8694c..9448edac 100644 --- a/R/api-tol.R +++ b/R/api-tol.R @@ -7,8 +7,7 @@ } q <- list(study_list=jsonlite::unbox(study_list)) res <- otl_POST(path="tree_of_life/about", body=q, ...) - cont <- otl_parse(res) - return(invisible(cont)) + res } @@ -26,8 +25,7 @@ q <- list(ott_ids = ott_ids) } res <- otl_POST(path="tree_of_life/mrca", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } @@ -47,8 +45,7 @@ q <- list(ott_id = jsonlite::unbox(ott_id)) } res <- otl_POST(path="tree_of_life/subtree", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } @@ -71,6 +68,5 @@ q <- list(ott_ids = ott_ids) res <- otl_POST("tree_of_life/induced_subtree", body=q, ...) - cont <- otl_parse(res) - return(cont) + res } diff --git a/R/base.R b/R/base.R index d4e31694..28f9ade6 100644 --- a/R/base.R +++ b/R/base.R @@ -42,6 +42,7 @@ otl_check_error <- function(cont) { } } +## Check and parse result of query otl_check <- function(req) { if (!req$status_code < 400) { msg <- otl_parse(req) @@ -49,13 +50,13 @@ otl_check <- function(req) { } desc <- otl_parse(req) otl_check_error(desc) + desc } ##' @importFrom httr GET otl_GET <- function(path, dev_url = FALSE, otl_v = otl_version(), ...) { req <- httr::GET(otl_url(), path=paste(otl_v, path, sep="/"), ...) otl_check(req) - req } ##' @importFrom jsonlite toJSON @@ -69,7 +70,6 @@ otl_POST <- function(path, body, dev_url = FALSE, otl_v = otl_version(), ...) { path=paste(otl_v, path, sep="/"), body=body_json, ...) otl_check(req) - req }