# `ExIbge.Locality.MetropolitanRegion`
[🔗](https://github.com/pedrohfonseca81/ex_ibge/blob/main/lib/ex_ibge/locality/metropolitan_region.ex#L1)

Module for handling Metropolitan Region (Região Metropolitana) queries from IBGE.

This module provides functions to fetch Metropolitan Regions by various geographical hierarchies
(State, Region).

# `all`

```elixir
@spec all(Keyword.t()) ::
  {:ok, [ExIbge.Geography.MetropolitanRegion.t()]} | {:error, any()}
```

Get all metropolitan regions.

## Parameters

  * `query` - Optional parameters supported by the API (e.g., `order_by: :name`, `municipality: 4204202`).

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.all()
    {:ok, [%ExIbge.Geography.MetropolitanRegion{id: 3301, name: "Rio de Janeiro", ...}, ...]}

## See Also

[IBGE API: Regiões Metropolitanas](https://servicodados.ibge.gov.br/api/docs/localidades#api-Regioes_metropolitanas-regioes-metropolitanasGet)

# `all!`

```elixir
@spec all!(Keyword.t()) :: [ExIbge.Geography.MetropolitanRegion.t()]
```

Same as `all/1`, but raises an error on failure.

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.all!()
    [%ExIbge.Geography.MetropolitanRegion{id: 3301, name: "Rio de Janeiro", ...}, ...]

# `find`

```elixir
@spec find(integer() | String.t() | [integer() | String.t()], Keyword.t()) ::
  {:ok, [ExIbge.Geography.MetropolitanRegion.t()]} | {:error, any()}
```

Get metropolitan region(s) by identifier(s).

## Parameters

  * `ids` - A single integer ID or a list of integer IDs.
  * `query` - Optional parameters supported by the API.

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.find(3301)
    {:ok, [%ExIbge.Geography.MetropolitanRegion{id: 3301, name: "Rio de Janeiro", ...}]}

## See Also

[IBGE API: Região Metropolitana por ID](https://servicodados.ibge.gov.br/api/docs/localidades#api-Regioes_metropolitanas-regioes-metropolitanasRegiaoMetropolitanaGet)

# `find!`

```elixir
@spec find!(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: [
  ExIbge.Geography.MetropolitanRegion.t()
]
```

Same as `find/2`, but raises an error on failure.

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.find!(3301)
    [%ExIbge.Geography.MetropolitanRegion{id: 3301, name: "Rio de Janeiro", ...}]

# `get_by_region`

```elixir
@spec get_by_region(integer() | String.t() | [integer() | String.t()], Keyword.t()) ::
  {:ok, [ExIbge.Geography.MetropolitanRegion.t()]} | {:error, any()}
```

Get metropolitan regions by region identifier(s).

## Parameters

  * `region_ids` - A single integer ID or a list of integer IDs.
  * `query` - Optional parameters supported by the API.

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.get_by_region(3)
    {:ok, [%ExIbge.Geography.MetropolitanRegion{...}, ...]}

## See Also

[IBGE API: Regiões Metropolitanas por Região](https://servicodados.ibge.gov.br/api/docs/localidades#api-Regioes_metropolitanas-regioesMacrorregiaoRegioesMetropolitanasGet)

# `get_by_region!`

```elixir
@spec get_by_region!(integer() | String.t() | [integer() | String.t()], Keyword.t()) ::
  [
    ExIbge.Geography.MetropolitanRegion.t()
  ]
```

Same as `get_by_region/2`, but raises an error on failure.

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.get_by_region!(3)
    [%ExIbge.Geography.MetropolitanRegion{...}, ...]

# `get_by_state`

```elixir
@spec get_by_state(
  integer() | atom() | String.t() | [integer() | atom() | String.t()],
  Keyword.t()
) :: {:ok, [ExIbge.Geography.MetropolitanRegion.t()]} | {:error, any()}
```

Get metropolitan regions by state identifier(s).

## Parameters

  * `uf_ids` - A single identifier or list of identifiers (Integer ID or Atom UFs).
  * `query` - Optional parameters supported by the API.

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.get_by_state(33)
    {:ok, [%ExIbge.Geography.MetropolitanRegion{...}, ...]}

    iex> ExIbge.Locality.MetropolitanRegion.get_by_state(:rj)
    {:ok, [%ExIbge.Geography.MetropolitanRegion{...}, ...]}

## See Also

[IBGE API: Regiões Metropolitanas por UF](https://servicodados.ibge.gov.br/api/docs/localidades#api-Regioes_metropolitanas-estadosUFRegioesMetropolitanasGet)

# `get_by_state!`

```elixir
@spec get_by_state!(
  integer() | atom() | String.t() | [integer() | atom() | String.t()],
  Keyword.t()
) :: [ExIbge.Geography.MetropolitanRegion.t()]
```

Same as `get_by_state/2`, but raises an error on failure.

## Examples

    iex> ExIbge.Locality.MetropolitanRegion.get_by_state!(33)
    [%ExIbge.Geography.MetropolitanRegion{...}, ...]

---

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