Correios CEP v0.6.0 Correios.CEP.Parser View Source
Parser for Correios API responses.
Link to this section Summary
Functions
Parses a Correios API response error to Correios.CEP.Error
struct.
Parses a successful Correios API response body to Correios.CEP.Address
struct.
Link to this section Functions
Specs
parse_error(any()) :: Correios.CEP.Error.t()
Parses a Correios API response error to Correios.CEP.Error
struct.
Examples
iex> Correios.CEP.Parser.parse_error(response_body)
%Correios.CEP.Error{ ... }
iex> Correios.CEP.Parser.parse_error(:timeout)
%Correios.CEP.Error{reason: "timeout"}
Specs
parse_ok(String.t()) :: Correios.CEP.Address.t() | Correios.CEP.Error.t()
Parses a successful Correios API response body to Correios.CEP.Address
struct.
When the response body is empty, returns a not found Correios.CEP.Error
struct.
Examples
iex> Correios.CEP.Parser.parse_ok(response_body)
%Correios.CEP.Address{ ... }
iex> Correios.CEP.Parser.parse_ok(response_body)
%Correios.CEP.Error{reason: "CEP NAO ENCONTRADO"}