summaryrefslogtreecommitdiffstats
path: root/copy
diff options
context:
space:
mode:
Diffstat (limited to 'copy')
-rw-r--r--copy/cepis-status.cpy31
-rw-r--r--copy/cepis.cpy8
2 files changed, 36 insertions, 3 deletions
diff --git a/copy/cepis-status.cpy b/copy/cepis-status.cpy
index 75632c8..b98a753 100644
--- a/copy/cepis-status.cpy
+++ b/copy/cepis-status.cpy
@@ -1,7 +1,7 @@
*> ---------------------------------------------------------------------
*> Status layout without its 01 level, so the library can keep a private
*> scratch status alongside the caller's without duplicating the
-*> definition. Replace the field-name tag and the level number.
+*> definition. Replace the field-name tag and the two level numbers.
*>
*> The six failure categories are split by the decision the caller has to
*> make, not by the HTTP status that produced them.
@@ -21,3 +21,32 @@
:L1: :P:-STATUS-RETRY-AFTER-MS PIC S9(9)
SIGN IS LEADING SEPARATE.
:L1: :P:-STATUS-ATTEMPTS PIC 9(4).
+
+*> The municipality a CEP that does not exist would have belonged to.
+*> Context for the error, never an address: the lookup is still
+*> :P:-NOT-FOUND and CEPIS-ADDRESS is still empty. Only GET /{cep} fills
+*> it, so it stays absent after a batch or a health call.
+*>
+*> :P:-FAIXA-CEP-INI and :P:-FAIXA-CEP-FIM are the smallest and the
+*> largest CEP the municipality actually has, not the bounds the Correios
+*> publish -- the DNE's own start for Areal/RJ is 25845000, exactly the
+*> CEP that just failed. The range is sparse: Areal's 118 CEPs are
+*> scattered over the ~4900 numbers between 25845001 and 25849899, so the
+*> pair is a span to show a human, never a list of valid CEPs. That is
+*> what :P:-FAIXA-CEPS counts.
+*>
+*> The API omits "faixa" -- it never sends null -- when the CEP falls in
+*> a band no municipality owns, so test the flag before reading anything
+*> below it.
+:L1: :P:-FAIXA.
+ :L2: :P:-FAIXA-PRESENT PIC X.
+ 88 :P:-FAIXA-KNOWN VALUE "Y".
+ 88 :P:-FAIXA-ABSENT VALUE "N".
+ :L2: :P:-FAIXA-LOCALIDADE PIC X(100).
+ :L2: :P:-FAIXA-UF PIC X(2).
+ :L2: :P:-FAIXA-ESTADO PIC X(60).
+ :L2: :P:-FAIXA-REGIAO PIC X(30).
+ :L2: :P:-FAIXA-IBGE PIC X(10).
+ :L2: :P:-FAIXA-CEP-INI PIC X(8).
+ :L2: :P:-FAIXA-CEP-FIM PIC X(8).
+ :L2: :P:-FAIXA-CEPS PIC 9(9).
diff --git a/copy/cepis.cpy b/copy/cepis.cpy
index 59d643c..84a9976 100644
--- a/copy/cepis.cpy
+++ b/copy/cepis.cpy
@@ -1,5 +1,5 @@
*> ---------------------------------------------------------------------
-*> cepis 0.1.0 -- public data layouts for the cep.is client.
+*> cepis 0.2.0 -- public data layouts for the cep.is client.
*>
*> Copy this into WORKING-STORAGE (callers) or LINKAGE (subprograms).
*> It defines, in order:
@@ -34,9 +34,13 @@
*> categories are split by the decision the caller has to make, not by
*> the HTTP status that produced them. CEPIS-RETRIABLE covers the three
*> the client already retried on its own before giving up.
+*>
+*> A CEPIS-NOT-FOUND may also carry CEPIS-FAIXA, the municipality the
+*> missing CEP would have belonged to. CEPIS-FAIXA-PRESENT says whether
+*> it does; the call has still failed either way.
01 CEPIS-STATUS.
COPY "cepis-status.cpy" REPLACING
- ==:P:== BY ==CEPIS== ==:L1:== BY ==05==.
+ ==:P:== BY ==CEPIS== ==:L1:== BY ==05== ==:L2:== BY ==10==.
*> A CEP as the caller has it: "01001-000", "01001000" or "01001.000".
01 CEPIS-CEP-INPUT PIC X(20).