Skip to content

Commit 5c4fbe9

Browse files
authored
11 use dict to generate urls (#16)
* Add url dict * Bump patch version
1 parent 93e3b96 commit 5c4fbe9

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CoinbaseProExchange"
22
uuid = "06c3450d-869c-4596-88b4-6f9fb82f72bd"
33
authors = ["Vikas Negi <vikas.negi10@gmail.com>"]
4-
version = "1.1.0"
4+
version = "1.1.1"
55

66
[deps]
77
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/getpublic.jl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,17 @@ end
104104

105105
function get_url(pair::String, endpoint::String)
106106

107-
url = ""
108-
if endpoint == "24hr stats"
109-
url = URL * "/products/$(pair)/stats"
110-
elseif endpoint == "product info"
111-
url = URL * "/products/$(pair)"
112-
elseif endpoint == "product ticker"
113-
url = URL * "/products/$(pair)/ticker"
114-
elseif occursin("order book", endpoint)
115-
level = parse(Int64, endpoint[end])
116-
url = URL * "/products/$(pair)/book?level=$(level)"
107+
url_dict = Dict(
108+
"24hr stats" => URL * "/products/$(pair)/stats",
109+
"product info" => URL * "/products/$(pair)",
110+
"product ticker" => URL * "/products/$(pair)/ticker",
111+
)
112+
113+
if occursin("order book", endpoint)
114+
return URL * "/products/$(pair)/book?level=$(parse(Int64, endpoint[end]))"
115+
else
116+
return url_dict[endpoint]
117117
end
118-
119-
return url
120118
end
121119

122120
function get_product_data(pair::String, endpoint::String)

0 commit comments

Comments
 (0)