Builds the SOAP 1.2 envelope the 4.00 webservices expect.
Each service takes its message inside nfeDadosMsg, whose namespace is the
service's own WSDL namespace — that is what routes the call on the .asmx
endpoint, so it is per service rather than global.
CT-e and MDF-e use the same SOAP 1.2 shape with their own namespaces
(.../cte/wsdl/<service>, .../mdfe/wsdl/<service>) and their own body
element, cteDadosMsg and mdfeDadosMsg.
The message itself is passed through untouched. For SefazNfe.authorize/1
that matters: the ERP owns the XML and a signed document must reach SEFAZ byte
for byte, or the signature breaks (SEFAZ-04).
Summary
Functions
SOAPAction URI for service.
consReciNFe for NFeRetAutorizacao4.
consSitNFe for NFeConsultaProtocolo4.
ConsCad for NFeConsultaCadastro (layout 2.00, not 4.00).
distDFeInt for NFeDistribuicaoDFe.
envEvento for NFeRecepcaoEvento4, carrying one already signed event.
enviNFe for NFeAutorizacao4, carrying one already signed NF-e.
consStatServ for NFeStatusServico4.
consStatServCTe for CTeStatusServicoV4, layout 4.00.
consStatServMDFe for MDFeStatusServico, layout 3.00.
A CPF is 11 digits; anything else is treated as a CNPJ.
tpAmb for an environment: 1 is production, 2 is homologation.
Wraps message for service.
Types
@type service() :: SefazNfe.Endpoints.service()
Functions
@spec action(service(), String.t() | nil) :: {:ok, String.t()} | {:error, {:unknown_service, term()}}
SOAPAction URI for service.
operation overrides the service's default operation name. Only
NFeConsultaCadastro needs it: its authorizers disagree on the name, so it
comes from SefazNfe.Endpoints.operation/2. nil keeps the default.
consReciNFe for NFeRetAutorizacao4.
consSitNFe for NFeConsultaProtocolo4.
ConsCad for NFeConsultaCadastro (layout 2.00, not 4.00).
uf is the UF whose registry is consulted. filter is exactly one of
{:tax_id, id} (CPF or CNPJ) and {:ie, ie}.
MT quirk (from NFePHP): SEFAZ-MT wants the message wrapped in one more
nfeDadosMsg, with no namespace of its own, inside the WSDL one. Every other
authorizer takes ConsCad directly.
@spec dist_dfe(String.t(), pos_integer(), 1 | 2, {atom(), String.t()}) :: binary()
distDFeInt for NFeDistribuicaoDFe.
The cursor is one of {:ult_nsu, nsu} to walk forward, {:nsu, nsu} for a
single document, or {:ch_nfe, key} to fetch one by access key.
envEvento for NFeRecepcaoEvento4, carrying one already signed event.
enviNFe for NFeAutorizacao4, carrying one already signed NF-e.
ind_sinc 1 asks SEFAZ to process the batch in the same call and answer with
the protocol; 0 answers a receipt that SefazNfe.authorization_result/1 then
consults. The MOC allows up to 50 documents per batch, and v1 sends one.
The signed document is embedded verbatim apart from its XML declaration, which is not allowed inside another document. Touching anything else would break the signature.
@spec status_service(pos_integer(), 1 | 2) :: binary()
consStatServ for NFeStatusServico4.
xServ is fixed at STATUS; it is the only operation the service defines.
@spec status_service_cte(pos_integer(), 1 | 2) :: binary()
consStatServCTe for CTeStatusServicoV4, layout 4.00.
Same fields as the NF-e one (tpAmb, cUF, xServ fixed at STATUS) in the
CT-e namespace.
@spec status_service_mdfe(1 | 2) :: binary()
consStatServMDFe for MDFeStatusServico, layout 3.00.
Unlike NF-e and CT-e it has no cUF: SVRS answers for every UF.
A CPF is 11 digits; anything else is treated as a CNPJ.
@spec tp_amb(:production | :homologation) :: 1 | 2
tpAmb for an environment: 1 is production, 2 is homologation.
Wraps message for service.
The UF services take nfeDadosMsg directly in the body. NFeDistribuicaoDFe
nests it one level deeper, inside the operation element — sending it flat
makes the Ambiente Nacional answer a null reference from its own .NET stack
rather than a cStat.