Correios CEP v0.7.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{
type: :request_error,
message: "Request 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{
type: :postal_code_not_found,
message: "Postal code not found",
reason: "CEP NAO ENCONTRADO"
}