Skip to content
This repository has been archived by the owner on Jan 3, 2021. It is now read-only.

Commit

Permalink
Merge 86601c5 into f0de569
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisvalentiner committed Aug 13, 2018
2 parents f0de569 + 86601c5 commit 9008bbe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
- linux
- osx
julia:
- 0.7
- 1.0
- nightly
matrix:
allow_failures:
Expand Down
4 changes: 0 additions & 4 deletions REQUIRE

This file was deleted.

20 changes: 17 additions & 3 deletions src/DarkSky.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION >= v"0.7.0" && __precompile__()
VERSION >= v"1.0.0" && __precompile__()

module DarkSky

Expand Down Expand Up @@ -26,7 +26,21 @@ struct DarkSkyResponse
alerts::Optional{Array}
flags::Optional{Dict}
end
DarkSkyResponse(x::Dict) = DarkSkyResponse((get.(x, String.(fieldnames(DarkSkyResponse)), nothing))...)
# DarkSkyResponse(x::Dict) = DarkSkyResponse((get.(x, String.(fieldnames(DarkSkyResponse)), nothing))...)
function DarkSkyResponse(x::Dict)
DarkSkyResponse(
get(x, "latitude", nothing),
get(x, "longitude", nothing),
get(x, "timezone", nothing),
get(x, "offset", nothing),
get(x, "currently", nothing),
get(x, "minutely", nothing),
get(x, "hourly", nothing),
get(x, "daily", nothing),
get(x, "alerts", nothing),
get(x, "flags", nothing)
)
end
Dict(x::DarkSkyResponse) = Dict(String(f) => getfield(x, f) for f in fieldnames(typeof(x)) if getfield(x, f) != nothing)
Base.convert(Dict, x::DarkSkyResponse) = Dict(x)

Expand All @@ -44,7 +58,7 @@ end

function _get_json(url::String, out_type::String, verbose::Bool)
response = HTTP.get(url)
verbose ? @info(response) : nothing
verbose ? info(response) : nothing
if response.status == 200
out = JSON.Parser.parse(String(response.body))
if out_type == "DarkSkyResponse"
Expand Down

0 comments on commit 9008bbe

Please sign in to comment.