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

Module for handling Mesoregion (Mesorregião) queries from IBGE.

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

# `all`

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

Get all mesoregions.

## Parameters

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

## Examples

    iex> ExIbge.Locality.Mesoregion.all()
    {:ok, [%ExIbge.Geography.Mesoregion{id: 3301, name: "Noroeste Fluminense", ...}, ...]}

## See Also

[IBGE API: Mesorregiões](https://servicodados.ibge.gov.br/api/docs/localidades#api-Mesorregioes-mesorregioesGet)

# `all!`

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

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

## Examples

    iex> ExIbge.Locality.Mesoregion.all!()
    [%ExIbge.Geography.Mesoregion{id: 3301, name: "Noroeste Fluminense", ...}, ...]

# `find`

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

Get mesoregion(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.Mesoregion.find(3301)
    {:ok, [%ExIbge.Geography.Mesoregion{id: 3301, name: "Noroeste Fluminense", ...}]}

## See Also

[IBGE API: Mesorregião por ID](https://servicodados.ibge.gov.br/api/docs/localidades#api-Mesorregioes-mesorregioesMesorregiaoGet)

# `find!`

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

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

## Examples

    iex> ExIbge.Locality.Mesoregion.find!(3301)
    [%ExIbge.Geography.Mesoregion{id: 3301, name: "Noroeste Fluminense", ...}]

# `get_by_region`

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

Get mesoregions 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.Mesoregion.get_by_region(3)
    {:ok, [%ExIbge.Geography.Mesoregion{...}, ...]}

## See Also

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

# `get_by_region!`

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

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

## Examples

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

# `get_by_state`

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

Get mesoregions 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.Mesoregion.get_by_state(33)
    {:ok, [%ExIbge.Geography.Mesoregion{...}, ...]}

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

## See Also

[IBGE API: Mesorregiões por Estado](https://servicodados.ibge.gov.br/api/docs/localidades#api-Mesorregioes-estadosUFMesorregioesGet)

# `get_by_state!`

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

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

## Examples

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

---

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