Created
April 19, 2018 04:40
-
-
Save elbow-jason/44d7823623b3a6b9bc4f255b5faaf26a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 LookupExample do | |
def lookup(ip) do | |
ip | |
|> Geolix.lookup | |
|> parse_lookup | |
end | |
def parse_lookup(%{city: %{name: city_name}, country: %{iso_code: iso_code}, postal: %{code: postal_code}}) do | |
{city_name, iso_code, postal_code} | |
end | |
def parse_lookup(%{enterprise: data}) do | |
parse_lookup(data) | |
end | |
def parse_lookup(_) | |
{"_MM_LOOKUP_FAILED_","_MM_LOOKUP_FAILED_","_MM_LOOKUP_FAILED_"} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment