ExIbge.Locality.Subdistrict (ex_ibge v0.4.0)

Copy Markdown View Source

Module for handling Subdistrict (Subdistrito) queries from IBGE.

This module provides functions to fetch Subdistricts by various geographical hierarchies (District, Municipality, State, etc.).

Summary

Functions

Get all subdistricts.

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

Get subdistrict(s) by identifier(s).

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

Get subdistricts by district identifier(s).

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

Get subdistricts by immediate region identifier(s).

Get subdistricts by mesoregion identifier(s).

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

Get subdistricts by microregion identifier(s).

Get subdistricts by municipality identifier(s).

Get subdistricts by region identifier(s).

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

Get subdistricts 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.Subdistrict.t()]} | {:error, any()}

Get all subdistricts.

Parameters

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

Examples

iex> ExIbge.Locality.Subdistrict.all()
{:ok, [%ExIbge.Geography.Subdistrict{id: 53001080517, name: "Brasília", ...}, ...]}

See Also

IBGE API: Subdistritos

all!(query \\ [])

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

Examples

iex> ExIbge.Locality.Subdistrict.all!()
[%ExIbge.Geography.Subdistrict{id: 53001080517, name: "Brasília", ...}, ...]

find(ids, query \\ [])

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

Get subdistrict(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.Subdistrict.find(53001080517)
{:ok, [%ExIbge.Geography.Subdistrict{id: 53001080517, name: "Brasília", ...}]}

See Also

IBGE API: Subdistrito por ID

find!(ids, query \\ [])

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

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

Examples

iex> ExIbge.Locality.Subdistrict.find!(53001080517)
[%ExIbge.Geography.Subdistrict{id: 53001080517, name: "Brasília", ...}]

get_by_district(district_ids, query \\ [])

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

Get subdistricts by district identifier(s).

Parameters

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

Examples

iex> ExIbge.Locality.Subdistrict.get_by_district(530010805)
{:ok, [%ExIbge.Geography.Subdistrict{...}, ...]}

See Also

IBGE API: Subdistritos por Distrito

get_by_district!(district_ids, query \\ [])

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

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

Examples

iex> ExIbge.Locality.Subdistrict.get_by_district!(530010805)
[%ExIbge.Geography.Subdistrict{...}, ...]

get_by_immediate_region(immediate_region_ids, query \\ [])

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

Get subdistricts by immediate region identifier(s).

Parameters

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

Examples

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

See Also

IBGE API: Subdistritos por Região Imediata

get_by_immediate_region!(immediate_region_ids, query \\ [])

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

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

Examples

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

get_by_mesoregion(mesoregion_ids, query \\ [])

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

Get subdistricts 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.Subdistrict.get_by_mesoregion(5301)
{:ok, [%ExIbge.Geography.Subdistrict{...}, ...]}

See Also

IBGE API: Subdistritos por Mesorregião

get_by_mesoregion!(mesoregion_ids, query \\ [])

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

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

Examples

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

get_by_microregion(microregion_ids, query \\ [])

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

Get subdistricts 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.Subdistrict.get_by_microregion(53001)
{:ok, [%ExIbge.Geography.Subdistrict{...}, ...]}

See Also

IBGE API: Subdistritos por Microrregião

get_by_microregion!(microregion_ids, query \\ [])

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

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

Examples

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

get_by_municipality(municipality_ids, query \\ [])

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

Get subdistricts 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.Subdistrict.get_by_municipality(5300108)
{:ok, [%ExIbge.Geography.Subdistrict{...}, ...]}

See Also

IBGE API: Subdistritos por Município

get_by_municipality!(municipality_ids, query \\ [])

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

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

Examples

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

get_by_region(region_ids, query \\ [])

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

Get subdistricts 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.Subdistrict.get_by_region(5)
{:ok, [%ExIbge.Geography.Subdistrict{...}, ...]}

See Also

IBGE API: Subdistritos por Região

get_by_region!(region_ids, query \\ [])

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

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

Examples

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

get_by_state(uf_ids, query \\ [])

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

Get subdistricts 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.Subdistrict.get_by_state(53)
{:ok, [%ExIbge.Geography.Subdistrict{...}, ...]}

See Also

IBGE API: Subdistritos por UF

get_by_state!(uf_ids, query \\ [])

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

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

Examples

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