Skip to main content

to_authorize

Function to_authorize 

Source
pub fn to_authorize(
    request_xml: &str,
    response_xml: &str,
) -> Result<String, FiscalError>
Expand description

Detect the document type from raw XML and dispatch to the correct protocol-attachment function.

This mirrors the PHP Complements::toAuthorize() method, which uses Standardize::whichIs() internally. The detection logic checks for the same root tags in the same priority order as the PHP implementation:

Detected tagDispatches to
NFeattach_protocol
envEventoattach_event_protocol
inutNFeattach_inutilizacao

ยงErrors

Returns FiscalError::XmlParsing if:

  • Either input is empty
  • The request XML does not match any of the known document types
  • The delegated function returns an error