ExIbge.Locality.District (ex_ibge v0.3.0)

Copy Markdown View Source

Module for handling District (Distrito) queries from IBGE.

Districts are administrative subdivisions of municipalities. This module allows fetching districts by various geographical hierarchies (State, Mesoregion, Municipality, etc.).

Summary

Functions

Get all districts.

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

Get district(s) by identifier(s).

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

Get districts by immediate region identifier(s).

Get districts by intermediate region identifier(s).

Get districts by mesoregion identifier(s).

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

Get districts by microregion identifier(s).

Get districts by municipality identifier(s).

Get districts by region identifier(s).

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

Get districts by state identifier(s).

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

Functions

all(query \\ [])

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

Get all districts.

Parameters

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

Examples

iex> ExIbge.Locality.District.all()
{:ok, [%ExIbge.Geography.District{id: 520005005, name: "Abadia de Goiás", ...}, ...]}

See Also

IBGE API: Distritos

all!(query \\ [])

@spec all!(Keyword.t()) :: [ExIbge.Geography.District.t()]

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

Examples

iex> ExIbge.Locality.District.all!()
[%ExIbge.Geography.District{...}, ...]

find(ids, query \\ [])

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

Get district(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.District.find(160030312)
{:ok, [%ExIbge.Geography.District{id: 160030312, name: "Fazendinha", ...}]}

See Also

IBGE API: Distrito por ID

find!(ids, query \\ [])

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

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

Examples

iex> ExIbge.Locality.District.find!(160030312)
[%ExIbge.Geography.District{id: 160030312, name: "Fazendinha", ...}]

get_by_immediate_region(immediate_region_ids, query \\ [])

@spec get_by_immediate_region(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: {:ok, [ExIbge.Geography.District.t()]} | {:error, any()}

Get districts by immediate region identifier(s).

Example:

iex> ExIbge.Locality.District.get_by_immediate_region(310037)
{:ok, [%ExIbge.Geography.District{...}, ...]}

For more information, see the IBGE API documentation.

get_by_immediate_region!(immediate_region_ids, query \\ [])

@spec get_by_immediate_region!(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: [ExIbge.Geography.District.t()]

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

Examples

iex> ExIbge.Locality.District.get_by_immediate_region!(310037)
[%ExIbge.Geography.District{...}, ...]

get_by_intermediate_region(intermediate_region_ids, query \\ [])

@spec get_by_intermediate_region(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: {:ok, [ExIbge.Geography.District.t()]} | {:error, any()}

Get districts by intermediate region identifier(s).

Example:

iex> ExIbge.Locality.District.get_by_intermediate_region(2603)
{:ok, [%ExIbge.Geography.District{...}, ...]}

For more information, see the IBGE API documentation.

get_by_intermediate_region!(intermediate_region_ids, query \\ [])

@spec get_by_intermediate_region!(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: [ExIbge.Geography.District.t()]

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

Examples

iex> ExIbge.Locality.District.get_by_intermediate_region!(2603)
[%ExIbge.Geography.District{...}, ...]

get_by_mesoregion(mesoregion_ids, query \\ [])

@spec get_by_mesoregion(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) ::
  {:ok, [ExIbge.Geography.District.t()]} | {:error, any()}

Get districts by mesoregion identifier(s).

Parameters

  • mesoregion_ids - A single integer ID or a list of integer IDs.
  • query - Optional parameters supported by the API.

Examples

iex> ExIbge.Locality.District.get_by_mesoregion(1602)
{:ok, [%ExIbge.Geography.District{...}, ...]}

See Also

IBGE API: Distritos por Mesorregião

get_by_mesoregion!(mesoregion_ids, query \\ [])

@spec get_by_mesoregion!(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: [
  ExIbge.Geography.District.t()
]

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

Examples

iex> ExIbge.Locality.District.get_by_mesoregion!(1602)
[%ExIbge.Geography.District{...}, ...]

get_by_microregion(microregion_ids, query \\ [])

@spec get_by_microregion(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) ::
  {:ok, [ExIbge.Geography.District.t()]} | {:error, any()}

Get districts by microregion identifier(s).

Parameters

  • microregion_ids - A single integer ID or a list of integer IDs.
  • query - Optional parameters supported by the API.

Examples

iex> ExIbge.Locality.District.get_by_microregion(16003)
{:ok, [%ExIbge.Geography.District{...}, ...]}

See Also

IBGE API: Distritos por Microrregião

get_by_microregion!(microregion_ids, query \\ [])

@spec get_by_microregion!(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: [
  ExIbge.Geography.District.t()
]

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

Examples

iex> ExIbge.Locality.District.get_by_microregion!(16003)
[%ExIbge.Geography.District{...}, ...]

get_by_municipality(municipality_ids, query \\ [])

@spec get_by_municipality(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) ::
  {:ok, [ExIbge.Geography.District.t()]} | {:error, any()}

Get districts by municipality identifier(s).

Parameters

  • municipality_ids - A single integer ID or a list of integer IDs.
  • query - Optional parameters supported by the API.

Examples

iex> ExIbge.Locality.District.get_by_municipality(3550308)
{:ok, [%ExIbge.Geography.District{...}, ...]}

See Also

IBGE API: Distritos por Município

get_by_municipality!(municipality_ids, query \\ [])

@spec get_by_municipality!(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: [
  ExIbge.Geography.District.t()
]

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

Examples

iex> ExIbge.Locality.District.get_by_municipality!(3550308)
[%ExIbge.Geography.District{...}, ...]

get_by_region(region_ids, query \\ [])

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

Get districts by region identifier(s).

Example:

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

For more information, see the IBGE API documentation.

get_by_region!(region_ids, query \\ [])

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

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

Examples

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

get_by_state(uf_ids, query \\ [])

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

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

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

See Also

IBGE API: Distritos por Estado

get_by_state!(uf_ids, query \\ [])

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

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

Examples

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