Skip to content

Commit b53b4c9

Browse files
committed
Merge pull request #10 from plotly/api_endpoint_fix
Api endpoint fix
2 parents 9c2131d + 807f636 commit b53b4c9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Plotly.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ type CurrentPlot
1111
url::String
1212
end
1313

14+
api_version = "v2"
15+
1416
default_options = {"filename"=>"Plot from Julia API",
1517
"world_readable"=> true,
1618
"layout"=>{""=>""}}
@@ -31,13 +33,16 @@ default_opts = {
3133
function get_plot_endpoint()
3234
config = get_config()
3335
plot_endpoint = "clientresp"
34-
return joinpath(config.plotly_domain, plot_endpoint)
36+
return "$(config.plotly_domain)/$plot_endpoint"
3537
end
3638

3739
function get_content_endpoint(file_id::String, owner::String)
3840
config = get_config()
39-
content_endpoint = "files/$owner:$file_id/content"
40-
return joinpath(config.plotly_api_domain, content_endpoint)
41+
api_endpoint = "$(config.plotly_api_domain)/$api_version/files"
42+
detail = "$owner:$file_id"
43+
custom_action = "content"
44+
content_endpoint = "$api_endpoint/$detail/$custom_action"
45+
return content_endpoint
4146
end
4247

4348
function plot(data::Array,options=Dict())

test/tests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Base.Test
44

55
# just check that http://plot.ly/clientresp behaves as expected -- nothing to see here
66

7-
Plotly.signin("unittest","tfzz811f5n")
7+
Plotly.signin("unittest","tfzz811f5n", {"plotly_domain"=>"https://plot.ly","plotly_api_domain"=>"https://api.plot.ly"})
88

99
(x0,y0) = [1,2,3], [4,5,6]
1010
(x1,y1) = [1,2,3], [2,10,12]
@@ -50,4 +50,4 @@ Plotly.signin("test_username", "test_api_key", endpoints)
5050
fid = "123_fake"
5151
owner = "test_owner"
5252
content_endpoint = Plotly.get_content_endpoint(fid, owner)
53-
@test content_endpoint == "my_plotly_api_domain/files/test_owner:123_fake/content"
53+
@test content_endpoint == "my_plotly_api_domain/v2/files/test_owner:123_fake/content"

0 commit comments

Comments
 (0)