Brasilapi.Cep.Address (BrasilAPI v0.1.5)

View Source

Struct representing address data from BrasilAPI CEP v2.

This struct contains postal code information including address details and geographic coordinates when available.

Summary

Functions

Creates an Address struct from a map.

Types

coordinates()

@type coordinates() :: %{required(String.t()) => term()}

location()

@type location() :: %{type: String.t(), coordinates: coordinates()}

t()

@type t() :: %Brasilapi.Cep.Address{
  cep: String.t(),
  city: String.t(),
  location: location() | nil,
  neighborhood: String.t(),
  service: String.t(),
  state: String.t(),
  street: String.t()
}

Functions

from_map(map)

@spec from_map(map()) :: t()

Creates an Address struct from a map.

Examples

iex> map = %{
...>   "cep" => "89010025",
...>   "state" => "SC",
...>   "city" => "Blumenau",
...>   "neighborhood" => "Centro",
...>   "street" => "Rua Doutor Luiz de Freitas Melro",
...>   "service" => "viacep",
...>   "location" => %{
...>     "type" => "Point",
...>     "coordinates" => %{}
...>   }
...> }
iex> Brasilapi.Cep.Address.from_map(map)
%Brasilapi.Cep.Address{
  cep: "89010025",
  state: "SC",
  city: "Blumenau",
  neighborhood: "Centro",
  street: "Rua Doutor Luiz de Freitas Melro",
  service: "viacep",
  location: %{type: "Point", coordinates: %{}}
}