# `URL.Tel`
[🔗](https://github.com/kipcole9/url/blob/v2.0.3/lib/url/tel.ex#L1)

Parses the scheme-specific part of a `tel` URL as defined
in [RFC 3966](https://tools.ietf.org/html/rfc3966).

When the optional `ex_phone_number` dependency is available the
number is formatted in international form, with a `phone-context`
parameter that is itself a number prepended first. The territory
used for numbers without a country code comes from the current
`localize` locale, then the current `gettext` locale, then `"US"`.
Numbers that `ex_phone_number` cannot parse are kept as written.
The primary API is `parse/1`, which `URL.new/1` calls for any URL
with the `tel` scheme.

# `t`

```elixir
@type t() :: %URL.Tel{params: map(), tel: String.t()}
```

# `parse`

```elixir
@spec parse(URI.t()) :: {:ok, t()} | {:error, {module(), binary()}}
```

Parses the path of a `tel` URI into a `t:t/0` struct.

### Arguments

* `uri` is a `t:URI.t/0` whose `:scheme` is `"tel"`.

### Returns

* `{:ok, t:t/0}` with the formatted (or, if it cannot be
  parsed, unformatted) telephone number in `:tel` and any
  parameters in `:params`, or

* `{:error, {URL.Parser.ParseError, reason}}` if the path is
  not a valid telephone subscriber string, including an empty path.

### Examples

    iex> tel = URI.parse "tel:+61-0407-555-987"
    iex> URL.Tel.parse(tel)
    {:ok, %URL.Tel{tel: "+61 407 555 987", params: %{}}}

    iex> tel = URI.parse "tel:0407-555-987;phone-context=+61"
    iex> URL.Tel.parse(tel)
    {:ok, %URL.Tel{tel: "+61 407 555 987", params: %{"phone-context" => "+61"}}}

    iex> {:error, {URL.Parser.ParseError, _reason}} = URL.Tel.parse(URI.parse("tel:abc"))

---

*Consult [api-reference.md](api-reference.md) for complete listing*
