ExIbge.Locality.Country (ex_ibge v0.4.0)

Copy Markdown View Source

Module for handling Country (País) queries from IBGE.

This module provides functions to fetch Countries.

Summary

Functions

Get all countries.

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

Get country(ies) by identifier(s).

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

Functions

all(query \\ [])

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

Get all countries.

Parameters

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

Examples

iex> ExIbge.Locality.Country.all()
{:ok, [%ExIbge.Geography.Country{id: 76, name: "Brasil", ...}, ...]}

See Also

IBGE API: Países

all!(query \\ [])

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

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

Examples

iex> ExIbge.Locality.Country.all!()
[%ExIbge.Geography.Country{id: 76, name: "Brasil", ...}, ...]

find(ids, query \\ [])

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

Get country(ies) by identifier(s).

Parameters

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

Examples

iex> ExIbge.Locality.Country.find(76)
{:ok, [%ExIbge.Geography.Country{id: 76, name: "Brasil", ...}]}

See Also

IBGE API: País por ID

find!(ids, query \\ [])

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

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

Examples

iex> ExIbge.Locality.Country.find!(76)
[%ExIbge.Geography.Country{id: 76, name: "Brasil", ...}]