using System.Text.Json.Serialization;
namespace Cepis;
///
/// The municipality a CEP that does not exist would have belonged to.
///
///
///
/// This is context for an error, never an address. It rides on the 404
/// of , hanging
/// off . The CEP that was asked for
/// still does not exist, and nothing here says otherwise: filling a form from
/// these fields would be inventing an address.
///
///
/// It is worth having because a CEP that fails is rarely random — it is usually
/// someone who knows the city and guessed the number. The classic guess is the
/// -000, which 957 municipalities never received. Knowing where the
/// guess landed is what turns "CEP not found" into "did you mean a street in
/// Areal/RJ?".
///
///
/// and are the smallest and the
/// largest CEP that actually exist in that municipality, not the
/// bounds the Correios publish. For Areal the DNE's own range starts at
/// 25845000 — exactly the CEP that just failed — while
/// is 25845001.
///
///
/// The range is sparse, and the pair is not a list of valid CEPs. Areal
/// has 118 of them () spread across the ~4,900 numbers
/// between its two ends, so a number picked in between overwhelmingly does not
/// exist either. Never iterate the interval, and never show it as a set of
/// usable CEPs.
///
///
/// The property names are the API's own, in Portuguese, with only the casing
/// adapted — the same rule the rest of the data follows. On the wire they are
/// localidade, uf, estado, regiao, ibge,
/// cep_ini, cep_fim and ceps.
///
///
public sealed record Faixa
{
/// The municipality. Wire name localidade.
[JsonPropertyName("localidade")]
public string Localidade { get; init; } = "";
/// The two-letter state code. Wire name uf.
[JsonPropertyName("uf")]
public string UF { get; init; } = "";
/// The state's name. Wire name estado.
[JsonPropertyName("estado")]
public string Estado { get; init; } = "";
/// The region of the country. Wire name regiao.
[JsonPropertyName("regiao")]
public string Regiao { get; init; } = "";
/// The IBGE municipality code. Wire name ibge.
[JsonPropertyName("ibge")]
public string Ibge { get; init; } = "";
///
/// The smallest CEP that exists in that municipality, unmasked. Wire name
/// cep_ini.
///
///
/// The smallest one in the database, not the start of the range the
/// Correios publish — the published start may itself be a CEP that was never
/// issued, which is often precisely the one the caller just tried.
///
[JsonPropertyName("cep_ini")]
public string CepIni { get; init; } = "";
///
/// The largest CEP that exists in that municipality, unmasked. Wire name
/// cep_fim.
///
///
/// Together with it bounds the CEPs of the
/// municipality; it does not enumerate them. See .
///
[JsonPropertyName("cep_fim")]
public string CepFim { get; init; } = "";
///
/// How many CEPs the municipality actually has. Wire name ceps.
///
///
/// This field exists to keep and
/// from being read as a contiguous interval. Areal's 118 CEPs sit inside a
/// span of about 4,900 numbers: the range is mostly empty.
///
[JsonPropertyName("ceps")]
public int Ceps { get; init; }
}