shippex v0.6.8 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
Converts a full state name to its state code, or abbreviation
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
full_state_to_abbreviation(state)
Converts a full state name to its state code, or abbreviation.
iex> ISO.full_state_to_abbreviation("Texas")
"TX"
iex> ISO.full_state_to_abbreviation("teXaS")
"TX"
iex> ISO.full_state_to_abbreviation("TX")
nil
iex> ISO.full_state_to_abbreviation("AlberTa")
"AB"
iex> ISO.full_state_to_abbreviation("Veracruz")
"VER"
iex> ISO.full_state_to_abbreviation("Yucatán")
"YUC"
iex> ISO.full_state_to_abbreviation("Yucatan")
"YUC"
iex> ISO.full_state_to_abbreviation("YucatAN")
"YUC"
iex> ISO.full_state_to_abbreviation("Not a state.")
nil
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.")
%{}