shippex v0.6.15 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)
abbreviation_to_country_name(String.t()) :: nil | String.t()

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
Link to this function countries()
countries() :: %{optional(String.t()) => String.t()}

Returns a map of country codes and their full names.

iex> countries = ISO.countries()
...> match? %{"US" => "United States"}, countries
true

Returns all ISO-3166-2 data.

Link to this function states(country \\ "US")
states(String.t()) :: %{optional(String.t()) => String.t()}

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.")
%{}