Cepex (cepex v0.1.0) View Source
Link to this section Summary
Functions
Lookups a postal code (CEP) and returns a Cepex.Address struct with the address
information.
Link to this section Functions
Specs
lookup(String.t() | integer(), [keyword()]) :: {:ok, Cepex.Address.t()} | {:error, :request_failed} | {:error, {:invalid_response, Cepex.HTTP.Response.t()}} | {:error, :invalid_cep} | {:error, :cep_not_found}
Lookups a postal code (CEP) and returns a Cepex.Address struct with the address
information.
Available options are http_client (defaults to Cepex.HTTP.Hackney) and service
(defaults to Cepex.Service.ViaCEP).
Examples
iex> Cepex.lookup("80010-180")
{:ok, %Cepex.Address{
address: "Rua Barão do Rio Branco",
cep: "80010180",
city: "Curitiba",
complement: "",
http_response: %Cepex.HTTP.Response{},
neighborhood: "Centro",
state: "PR"
}}
iex> Cepex.lookup(80010180)
{:ok, %Cepex.Address{
address: "Rua Barão do Rio Branco",
cep: "80010180",
city: "Curitiba",
complement: "",
http_response: %Cepex.HTTP.Response{},
neighborhood: "Centro",
state: "PR"
}}
iex> Cepex.lookup("80210130")
{:ok, %Cepex.Address{
address: "Rua Barão do Rio Branco",
cep: "80010180",
city: "Curitiba",
complement: "",
http_response: %Cepex.HTTP.Response{},
neighborhood: "Centro",
state: "PR"
}}