shippex v0.6.14 Shippex.ISO
This module contains data and functions for obtaining geographic data in compliance with the ISO-3166-2 standard.
Link to this section Summary
Functions
Converts a country’s 2-letter code to its full name
Returns a map of country codes and their full names
Returns all ISO-3166-2 data
Returns a map of state codes and full names for the given 2-letter country code
Link to this section Functions
Link to this function
abbreviation_to_country_name(abbr)
Converts a country’s 2-letter code to its full name.
iex> ISO.abbreviation_to_country_name("US")
"United States"
iex> ISO.abbreviation_to_country_name("TN")
"Tunisia"
iex> ISO.abbreviation_to_country_name("TX")
nil
Returns a map of country codes and their full names.
iex> countries = ISO.countries()
...> match? %{"US" => "United States"}, countries
true
Link to this function
data()
Returns all ISO-3166-2 data.
Link to this function
states(country \\ "US")
Returns a map of state codes and full names for the given 2-letter country code.
iex> states = ISO.states("US")
...> match? %{"TX" => "Texas", "PR" => "Puerto Rico"}, states
true
iex> states = ISO.states("MX")
...> match? %{"AGU" => "Aguascalientes"}, states
true
iex> ISO.states("Not a country.")
%{}