Skip to content

Commit b57e172

Browse files
committed
Instead of inferring api domain, add a new env var
1 parent 6eafd16 commit b57e172

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

R/figure.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
get_figure <- function(username, id) {
1919
if (missing(username)) username <- verify("username")
2020
if (missing(id)) stop("Please provide a figure id number")
21-
base_url <- file.path(get_domain(), "apigetfile", username, id)
21+
base_url <- file.path("https://plot.ly/apigetfile", username, id)
2222
resp <- httr::GET(base_url, plotly_headers(), httr::config(ssl_verifypeer=FALSE))
2323
process(struct(resp, "figure"))
2424
}

R/plotly_IMAGE.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ plotly_IMAGE <- function(x, width = 1000, height = 500, format = "png",
3232
scale = scale,
3333
encoded = FALSE
3434
)
35-
base_url <- paste0(get_domain("v2"), "images")
35+
base_url <- file.path(get_domain("api"), "v2", "images")
3636
resp <- httr::POST(base_url, plotly_headers("v2"), body = to_JSON(bod),
3737
if (!missing(out_file)) write_disk(out_file, overwrite = TRUE),
3838
...)

R/plotly_POST.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ plotly_POST <- function(x, filename, fileopt = "new",
7171
args = to_JSON(x$data),
7272
kwargs = to_JSON(x[get_kwargs()])
7373
)
74-
base_url <- file.path(get_domain(), "clientresp")
74+
base_url <- "https://plot.ly/clientresp"
7575
resp <- httr::POST(base_url, body = bod)
7676
con <- process(struct(resp, "clientresp"))
7777
if (sharing[1] == "hidden") {
7878
bits <- strsplit(con$url, "/")[[1]]
7979
plot_id <- bits[length(bits)]
80-
url <- file.path(get_domain("v2"), "files", paste0(verify("username"), ":", plot_id))
80+
url <- file.path(get_domain("api"), "v2", "files",
81+
paste0(verify("username"), ":", plot_id))
8182
bod <- list(share_key_enabled = TRUE)
8283
con2 <- httr::PATCH(url, plotly_headers("v2"), body = bod, encode = "json")
8384
con$url <- paste0(con$url, "?share_key=", content(con2)$share_key)

R/signup.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ signup <- function(username, email, save = TRUE) {
4343
platform = "R",
4444
version = as.character(packageVersion("plotly"))
4545
)
46-
base_url <- file.path(get_domain(), "apimkacct")
46+
base_url <- "https://plot.ly/apimkacct"
4747
resp <- httr::POST(base_url, body = bod)
4848
con <- process(struct(resp, "signup"))
4949
if (save) {

R/utils.R

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,12 @@ struct <- function(x, y, ...) {
183183
}
184184

185185
# TODO: what are some other common configuration options we want to support??
186-
get_domain <- function(type = "main") {
187-
dom <- Sys.getenv("plotly_domain", "https://plot.ly")
188-
if (type == "v2") {
189-
u <- httr::parse_url(dom)
190-
u$hostname <- paste0("api.", u$hostname)
191-
u$path <- "v2"
192-
dom <- httr::build_url(u)
186+
get_domain <- function(type = "") {
187+
if (type == "api") {
188+
Sys.getenv("plotly_api_domain", "https://api.plot.ly")
189+
} else {
190+
Sys.getenv("plotly_domain", "https://plot.ly")
193191
}
194-
dom
195192
}
196193

197194
# plotly's special keyword arguments in POST body

0 commit comments

Comments
 (0)