Permalink
Browse files

added key as parameter to create_ISid function

  • Loading branch information...
sckott committed May 8, 2013
1 parent 9c6da6d commit 1d6b009e1f774513ab9031b40729aebe7db0bd98
Showing with 14 additions and 8 deletions.
  1. +2 −2 NAMESPACE
  2. +7 −4 R/tiID.R
  3. +5 −2 man/create_ISid.Rd
View
@@ -1,10 +1,10 @@
+export(IS_providers)
+export(ISid)
export(about_IS)
export(collection_metrics)
export(create_ISid)
export(github_heatmap)
export(github_plot)
export(github_report)
-export(IS_providers)
-export(ISid)
export(metrics)
export(save_collection)
View
@@ -28,13 +28,16 @@ return(str_sub(ISid, start=2, end=-2))
#'
#' @param id The id of an object. If you specify a \code{doi}, then leave the namespace blank. Otherwise please specify the namespace. Currently acceptable namespaces are \code{github}, \code{url}, and \code{pmid} (the last one is new and experimetal as of 09/07/2012)
#' @param nspace Default is \code{doi}
+#' @param key An ImpactStory API key
#' @export
#' @return character
#' @examples \dontrun{
-#' create_ISid('10.1038/nrg3270')
+#' create_ISid(id='10.1038/nrg3270')
#'}
-create_ISid <- function(id = NULL, nspace = 'doi') {
- new_id <- postForm(paste0("http://api.impactstory.org/v1/item/", nspace, "/", id), args = NULL, style = "POST")
- return(str_sub(new_id[1], start = 2, end = -2))
+create_ISid <- function(id = NULL, nspace = 'doi', key = getOption("ImpactStoryKey", stop("Missing ImpactStory consumer key"))) {
+ url <- "http://api.impactstory.org/v1/item/"
+ url2 <- paste0(url, nspace, "/", id, "?key=", key)
+ out <- postForm(url2, args = NULL, style = "POST")
+ return(str_sub(out[1], start = 2, end = -2))
}
View
@@ -2,7 +2,8 @@
\alias{create_ISid}
\title{Creates a ImpactStory ID for a new object. (This function will be deprecated shortly since Impact Story plans to discontinue assinging their own IDs)}
\usage{
- create_ISid(id = NULL, nspace = "doi")
+ create_ISid(id = NULL, nspace = "doi",
+ key = getOption("ImpactStoryKey", stop("Missing ImpactStory consumer key")))
}
\arguments{
\item{id}{The id of an object. If you specify a
@@ -12,6 +13,8 @@
(the last one is new and experimetal as of 09/07/2012)}
\item{nspace}{Default is \code{doi}}
+
+ \item{key}{An ImpactStory API key}
}
\value{
character
@@ -23,7 +26,7 @@
}
\examples{
\dontrun{
-create_ISid('10.1038/nrg3270')
+create_ISid(id='10.1038/nrg3270')
}
}

0 comments on commit 1d6b009

Please sign in to comment.