ExIbge.Locality.Region (ex_ibge v0.4.0)

Copy Markdown View Source

Module for handling Region (Macrorregião) queries from IBGE.

This module provides functions to fetch Regions (Norte, Nordeste, Sudeste, Sul, Centro-Oeste).

Summary

Functions

Get all regions (Macrorregiões).

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

Get region(s) by identifier(s).

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

Functions

all(query \\ [])

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

Get all regions (Macrorregiões).

Parameters

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

Examples

iex> ExIbge.Locality.Region.all()
{:ok, [%ExIbge.Geography.Region{id: 3, acronym: "SE", name: "Sudeste"}, ...]}

See Also

IBGE API: Regiões

all!(query \\ [])

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

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

Params and options are the same as all/1.

Examples

iex> ExIbge.Locality.Region.all!()
[%ExIbge.Geography.Region{id: 3, acronym: "SE", name: "Sudeste"}, ...]

find(ids, query \\ [])

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

Get region(s) by identifier(s).

Parameters

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

Examples

# Get a single region
iex> ExIbge.Locality.Region.find(3)
{:ok, [%ExIbge.Geography.Region{id: 3, acronym: "SE", name: "Sudeste"}]}

# Get multiple regions
iex> ExIbge.Locality.Region.find([3, 4])
{:ok, [%ExIbge.Geography.Region{id: 3, ...}, %ExIbge.Geography.Region{id: 4, ...}]}

See Also

IBGE API: Região por ID

find!(ids, query \\ [])

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

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

Params and options are the same as find/2.

Examples

iex> ExIbge.Locality.Region.find!(3)
[%ExIbge.Geography.Region{id: 3, acronym: "SE", name: "Sudeste"}]