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).
Same as get_by_immediate_region/2, but raises an error on failure.
Get districts by intermediate region identifier(s).
Same as get_by_intermediate_region/2, but raises an error on failure.
Get districts by mesoregion identifier(s).
Same as get_by_mesoregion/2, but raises an error on failure.
Get districts by microregion identifier(s).
Same as get_by_microregion/2, but raises an error on failure.
Get districts by municipality identifier(s).
Same as get_by_municipality/2, but raises an error on failure.
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
@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
@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{...}, ...]
@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
@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", ...}]
@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.
@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{...}, ...]
@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.
@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{...}, ...]
@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
@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{...}, ...]
@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
@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{...}, ...]
@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
@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{...}, ...]
@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.
@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{...}, ...]
@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
@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{...}, ...]