LivePhone.Countries (live_phone v0.1.1) View Source
The LivePhone.Countries
module can be used to list all known countries and return
them ordered alphabetically, and optionally you can ensure your preferred countries
are prepended to the list instead of mixed in with the rest.
Link to this section Summary
Functions
This function will lookup a Country
by it's country code.
This function returns all known countries as LivePhone.Country
structs,
sorted alphabetically by country name.
This function can be used to try and find the Country
for a specific
phone number in the ExPhoneNumber
format.
Link to this section Types
Specs
Link to this section Functions
Specs
get_country(String.t()) :: {:ok, LivePhone.Country.t()} | {:error, :not_found}
This function will lookup a Country
by it's country code.
Examples:
iex> LivePhone.Countries.get_country("US")
{:ok, %LivePhone.Country{code: "US", flag_emoji: "πΊπΈ", name: "United States of America (the)", preferred: false, region_code: "1"}}
iex> LivePhone.Countries.get_country("FAKE")
{:error, :not_found}
Specs
list_countries([String.t()]) :: [LivePhone.Country.t()]
This function returns all known countries as LivePhone.Country
structs,
sorted alphabetically by country name.
Optionally you can specify a list of preferred country codes, these will subsequently be prepended to the list.
# This will return everything alphabetically
abc_countries = LivePhone.Countries.list_countries()
# This will return it alphabetically as well, but push
# the US and GB `LivePhone.Country` structs to the top
# of the list.
my_countries = LivePhone.Countries.list_countries(["US", "GB"])
Specs
lookup(phone()) :: {:ok, LivePhone.Country.t()} | {:error, :not_found}
This function can be used to try and find the Country
for a specific
phone number in the ExPhoneNumber
format.