Skip to content

Commit 407a1d1

Browse files
committed
changed username and key checking with fxns
1 parent 91f14e6 commit 407a1d1

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

R/plotly.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@
4040
#' browseURL(url)
4141
#' }
4242

43-
plotly <- function(username, key){
43+
plotly <- function(username=NULL, key=NULL){
44+
45+
if(is.null(username))
46+
username <- getOption("plotlyUsername", stop("you need a user name for Plot.ly - See the signup function"))
47+
if(is.null(key))
48+
key <- getOption("plotlyKey", stop("you need an API key for Plot.ly - See the signup function"))
49+
4450
# public attributes/methods that the user has access to
4551
pub = list(
4652
username = username,
4753
key = key,
4854
filename='from api',
4955
fileopt=NULL,
50-
version = '0.3.1'
56+
version = as.character(packageVersion("plotly"))
5157
)
5258

5359
priv = list()

R/signup.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424
#' response$tmp_pw # temporary password to access your plotly account
2525
#' }
2626

27-
signup <- function(username, email){
27+
signup <- function(username=NULL, email=NULL){
28+
if(is.null(username))
29+
key <- getOption("plotlyUsername", stop("you need a user name for Plot.ly - See the signup function"))
30+
if(is.null(key))
31+
key <- getOption("plotlyKey", stop("you need an API key for Plot.ly - See the signup function"))
32+
2833
platform = 'R'
29-
version = packageVersion("plotly")
34+
version = as.character(packageVersion("plotly"))
3035
url = 'https://plot.ly/apimkacct'
3136
options(RCurlOptions = list(sslversion=3, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
3237
respst = postForm(url,
@@ -40,4 +45,4 @@ signup <- function(username, email){
4045
if(!is.null(resp$warning)) cat(resp$warning)
4146
if(!is.null(resp$message)) cat(resp$message)
4247
return(resp)
43-
}
48+
}

man/plotly.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
\alias{plotly}
33
\title{Main interface to plotly}
44
\usage{
5-
plotly(username, key)
5+
plotly(username = NULL, key = NULL)
66
}
77
\arguments{
88
\item{username}{plotly username}

man/signup.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
\alias{signup}
33
\title{Sign up to plotly.}
44
\usage{
5-
signup(username, email)
5+
signup(username = NULL, email = NULL)
66
}
77
\arguments{
88
\item{username}{Desired username}

0 commit comments

Comments
 (0)