From 0f1e2971589c3fe0e50797f83d65ee3bc96697a5 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Thu, 14 Sep 2017 12:56:28 -0700 Subject: [PATCH] fix #97 add key param to package_show --- R/package_show.R | 12 ++++++++---- man/package_show.Rd | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/R/package_show.R b/R/package_show.R index dfa6b6e..d88abf1 100644 --- a/R/package_show.R +++ b/R/package_show.R @@ -6,12 +6,13 @@ #' @param use_default_schema (logical) Use default package schema instead of a #' custom schema defined with an IDatasetForm plugin. Default: FALSE #' @template args +#' @template key #' @details By default the help and success slots are dropped, and only the #' result slot is returned. You can request raw json with \code{as = 'json'} #' then parse yourself to get the help slot. #' @examples \dontrun{ #' # Setup -#' ckanr_setup(url = "http://demo.ckan.org/", key = getOption("ckan_demo_key")) +#' ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) #' #' # create a package #' (res <- package_create("purposeful55")) @@ -30,9 +31,12 @@ #' package_show(res$id, TRUE) #' } package_show <- function(id, use_default_schema = FALSE, - url = get_default_url(), as = 'list', ...) { + url = get_default_url(), key = get_default_key(), + as = 'list', ...) { + id <- as.ckan_package(id, url = url) args <- cc(list(id = id$id, use_default_schema = use_default_schema)) - res <- ckan_GET(url, 'package_show', args, key = NULL, ...) - switch(as, json = res, list = as_ck(jsl(res), "ckan_package"), table = jsd(res)) + res <- ckan_GET(url, 'package_show', args, key = key, ...) + switch(as, json = res, list = as_ck(jsl(res), "ckan_package"), + table = jsd(res)) } diff --git a/man/package_show.Rd b/man/package_show.Rd index 4399b09..794e4eb 100644 --- a/man/package_show.Rd +++ b/man/package_show.Rd @@ -5,7 +5,7 @@ \title{Show a package.} \usage{ package_show(id, use_default_schema = FALSE, url = get_default_url(), - as = "list", ...) + key = get_default_key(), as = "list", ...) } \arguments{ \item{id}{(character) Package identifier.} @@ -16,6 +16,8 @@ custom schema defined with an IDatasetForm plugin. Default: FALSE} \item{url}{Base url to use. Default: \url{http://data.techno-science.ca}. See also \code{\link{ckanr_setup}} and \code{\link{get_default_url}}.} +\item{key}{A privileged CKAN API key, Default: your key set with \code{\link{ckanr_setup}}} + \item{as}{(character) One of list (default), table, or json. Parsing with table option uses \code{jsonlite::fromJSON(..., simplifyDataFrame = TRUE)}, which attempts to parse data to data.frame's when possible, so the result can vary from a vector, list or @@ -34,7 +36,7 @@ By default the help and success slots are dropped, and only the \examples{ \dontrun{ # Setup -ckanr_setup(url = "http://demo.ckan.org/", key = getOption("ckan_demo_key")) +ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key")) # create a package (res <- package_create("purposeful55"))