From 8c13bf3187b5fd9a59baf49f0c63861349ea48fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Neto?= Date: Tue, 14 May 2024 22:49:03 -0300 Subject: [PATCH] Adapt for erpbrasil.edoc integration Adapted the current library to ensure compatibility with the new erpbrasil.edoc library that is pending release. This change is on a feature branch to support the upcoming integration. See the related PR: https://github.com/erpbrasil/erpbrasil.edoc/pull/77 --- nfelib/nfe/ws/edoc_legacy.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/nfelib/nfe/ws/edoc_legacy.py b/nfelib/nfe/ws/edoc_legacy.py index 5669102..51c449b 100644 --- a/nfelib/nfe/ws/edoc_legacy.py +++ b/nfelib/nfe/ws/edoc_legacy.py @@ -108,19 +108,31 @@ def consulta_documento(self, chave): xServ="CONSULTAR", chNFe=chave, ) - return self._post( - raiz=raiz, - url=localizar_url( + + # Check if the method ´_get_ws_endpoint´ exists to ensure compatibility + # with different versions of the erpbrasil.edoc library. + if hasattr(self, '_get_ws_endpoint'): + url = self._get_ws_endpoint(WS_NFE_CONSULTA) + else: + # TODO: Remove this fallback in the next few months. + # The following block is a temporary solution to support older versions. + # After transitioning, remove the localizar_url method call. + url = localizar_url( WS_NFE_CONSULTA, str(self.uf), self.mod, int(self.ambiente) - ), + ) + + return self._post( + raiz=raiz, + url=url, operacao="nfeConsultaNF", classe=RetConsSitNfe, ) + class NFCeAdapter(DocumentoElectronicoAdapter, NFCe): pass