Module for handling Municipality (Município) queries from IBGE.
This module provides functions to fetch Municipalities by various geographical hierarchies (State, Mesoregion, Microregion, Immediate Region, Intermediate Region, Region).
Summary
Functions
Get all municipalities.
Same as all/1, but raises an error on failure.
Get municipalities by identifier(s).
Same as find/2, but raises an error on failure.
Get municipalities by immediate region identifier(s).
Get municipalities by immediate region identifier(s) or raise an error.
Get municipalities by intermediate region identifier(s).
Get municipalities by intermediate region identifier(s) or raise an error.
Get municipalities by mesoregion identifier(s).
Get municipalities by mesoregion identifier(s) or raise an error.
Get municipalities by microregion identifier(s).
Get municipalities by microregion identifier(s) or raise an error.
Get municipalities by region identifier(s).
Get municipalities by region identifier(s) or raise an error.
Get municipalities by state identifier(s).
Same as get_by_state/2, but raises an error on failure.
Functions
@spec all(Keyword.t()) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get all municipalities.
Example:
iex> ExIbge.Locality.Municipality.all()
{:ok, [%ExIbge.Geography.Municipality{id: 1100015, name: "Alta Floresta D'Oeste", ...}, ...]}Example with query:
iex> ExIbge.Locality.Municipality.all(order_by: :name, view: "nivelado")
{:ok, [%ExIbge.Geography.Municipality{id: 1100015, name: "Alta Floresta D'Oeste", ...}, ...]}For more information, see the IBGE API documentation.
@spec all!(Keyword.t()) :: [ExIbge.Geography.Municipality.t()]
Same as all/1, but raises an error on failure.
Examples
iex> ExIbge.Locality.Municipality.all!()
[%ExIbge.Geography.Municipality{id: 1100015, name: "Alta Floresta D'Oeste", ...}, ...]
@spec find(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get municipalities by identifier(s).
Example:
iex> ExIbge.Locality.Municipality.find(3550308)
{:ok, [%ExIbge.Geography.Municipality{id: 3550308, name: "São Paulo", ...}]}Example with multiple IDs:
iex> ExIbge.Locality.Municipality.find([3304557, 3550308])
{:ok, [%ExIbge.Geography.Municipality{id: 3304557, name: "Rio de Janeiro", ...}, ...]}For more information, see the IBGE API documentation.
@spec find!(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: [ ExIbge.Geography.Municipality.t() ]
Same as find/2, but raises an error on failure.
Examples
iex> ExIbge.Locality.Municipality.find!(3550308)
[%ExIbge.Geography.Municipality{id: 3550308, name: "São Paulo", ...}]
@spec get_by_immediate_region( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get municipalities by immediate region identifier(s).
Example:
iex> ExIbge.Locality.Municipality.get_by_immediate_region(310055)
{:ok, [%ExIbge.Geography.Municipality{...}, ...]}For more information, see the IBGE API documentation.
@spec get_by_immediate_region!( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: [ExIbge.Geography.Municipality.t()]
Get municipalities by immediate region identifier(s) or raise an error.
@spec get_by_intermediate_region( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get municipalities by intermediate region identifier(s).
Example:
iex> ExIbge.Locality.Municipality.get_by_intermediate_region(5202)
{:ok, [%ExIbge.Geography.Municipality{...}, ...]}For more information, see the IBGE API documentation.
@spec get_by_intermediate_region!( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: [ExIbge.Geography.Municipality.t()]
Get municipalities by intermediate region identifier(s) or raise an error.
@spec get_by_mesoregion( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get municipalities by mesoregion identifier(s).
Example:
iex> ExIbge.Locality.Municipality.get_by_mesoregion(3301)
{:ok, [%ExIbge.Geography.Municipality{...}, ...]}For more information, see the IBGE API documentation.
@spec get_by_mesoregion!( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: [ ExIbge.Geography.Municipality.t() ]
Get municipalities by mesoregion identifier(s) or raise an error.
@spec get_by_microregion( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get municipalities by microregion identifier(s).
Example:
iex> ExIbge.Locality.Municipality.get_by_microregion(33001)
{:ok, [%ExIbge.Geography.Municipality{...}, ...]}For more information, see the IBGE API documentation.
@spec get_by_microregion!( integer() | String.t() | [integer() | String.t()], Keyword.t() ) :: [ ExIbge.Geography.Municipality.t() ]
Get municipalities by microregion identifier(s) or raise an error.
@spec get_by_region(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get municipalities by region identifier(s).
Example:
iex> ExIbge.Locality.Municipality.get_by_region(3)
{:ok, [%ExIbge.Geography.Municipality{...}, ...]}For more information, see the IBGE API documentation.
@spec get_by_region!(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: [ ExIbge.Geography.Municipality.t() ]
Get municipalities by region identifier(s) or raise an error.
@spec get_by_state(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: {:ok, [ExIbge.Geography.Municipality.t()]} | {:error, any()}
Get municipalities by state identifier(s).
Example:
iex> ExIbge.Locality.Municipality.get_by_state(33)
{:ok, [%ExIbge.Geography.Municipality{id: 3300100, name: "Angra dos Reis", ...}, ...]}Example with multiple states:
iex> ExIbge.Locality.Municipality.get_by_state([33, 35])
{:ok, [%ExIbge.Geography.Municipality{id: 3300100, name: "Angra dos Reis", ...}, ...]}Example with state atom:
iex> ExIbge.Locality.Municipality.get_by_state(:rj)
{:ok, [%ExIbge.Geography.Municipality{id: 3300100, name: "Angra dos Reis", ...}, ...]}For more information, see the IBGE API documentation.
@spec get_by_state!(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: [ ExIbge.Geography.Municipality.t() ]
Same as get_by_state/2, but raises an error on failure.
Examples
iex> ExIbge.Locality.Municipality.get_by_state!(33)
[%ExIbge.Geography.Municipality{id: 3300100, name: "Angra dos Reis", ...}, ...]