LivePhone.Country (live_phone v0.4.0) View Source

The LivePhone.Country struct holds minimal information about a country, but it should be enough data for LivePhone to work it's magic.

Link to this section Summary

Functions

Converts the given iso_country tuple into a LivePhone.Country struct.

Link to this section Types

Specs

t() :: %LivePhone.Country{
  code: String.t(),
  flag_emoji: String.t(),
  name: String.t(),
  preferred: boolean(),
  region_code: String.t()
}

Link to this section Functions

Specs

from_iso({String.t(), %{required(String.t()) => String.t()}}) :: t()

Converts the given iso_country tuple into a LivePhone.Country struct.

Examples

iex> ISO.countries() |> Map.to_list() |> Enum.find(fn {cc, _} -> cc == "SL" end) |> LivePhone.Country.from_iso()
%LivePhone.Country{
  preferred: false,
  region_code: "232",
  flag_emoji: "πŸ‡ΈπŸ‡±",
  code: "SL",
  name: "Sierra Leone"
}

iex> LivePhone.Country.from_iso({"US", %{"name" => "United States"}})
%LivePhone.Country{
  preferred: false,
  region_code: "1",
  flag_emoji: "πŸ‡ΊπŸ‡Έ",
  code: "US",
  name: "United States"
}