Created
April 15, 2017 23:49
-
-
Save mlusiak/b00a756b891e701354cba66fae55bd78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Flightlog.FlightView do | |
use Flightlog.Web, :view | |
def download(airport) do | |
url = "https://airportapi02560c297e8.azurewebsites.net/api/Airports?code={not_that_important}&iataCode=" <> airport | |
response = HTTPotion.get url | |
{status, fields} = JSON.decode(response.body) | |
fields | |
end | |
def lat(airport) do | |
fields = download(airport) | |
fields["lat@"] | |
end | |
def lon(airport) do | |
fields = download(airport) | |
fields["lon@"] | |
end | |
def location(airport) do | |
fields = download(airport) | |
fields["city@"] <> ", " <> fields["country@"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment