Skip to content

Commit e125a03

Browse files
ODBrenomarcelsavegnago
authored andcommitted
[ADD] CTe Adapter
1 parent 8ee2c2a commit e125a03

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

nfelib/nfe/ws/edoc_legacy.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from erpbrasil.edoc.edoc import DocumentoEletronico
1616
from erpbrasil.edoc.mde import MDe
1717
from erpbrasil.edoc.mdfe import MDFe
18+
from erpbrasil.edoc.cte import CTe
1819
from erpbrasil.edoc.nfce import NFCe
1920
from erpbrasil.edoc.nfe import NFe, localizar_url, WS_NFE_CONSULTA
2021
from erpbrasil.edoc.resposta import RetornoSoap, analisar_retorno_raw
@@ -141,6 +142,22 @@ class MDeAdapter(DocumentoElectronicoAdapter, MDe):
141142
pass
142143

143144

145+
class CTeAdapter(DocumentoElectronicoAdapter, CTe):
146+
147+
def _post(self, raiz, url, operacao, classe):
148+
xml_etree = xml_string = raiz
149+
if is_dataclass(raiz):
150+
xml_string, xml_etree = self.render_edoc_xsdata(raiz)
151+
with self._transmissao.cliente(url):
152+
retorno = self._transmissao.enviar(operacao, xml_etree)
153+
if is_dataclass(classe):
154+
return analisar_retorno_raw_xsdata(
155+
operacao, raiz, xml_string, retorno, classe
156+
)
157+
else:
158+
return analisar_retorno_raw(operacao, raiz, xml_string, retorno, classe)
159+
160+
144161
class MDFeAdapter(DocumentoElectronicoAdapter, MDFe):
145162
NAMESPACES = {
146163
"mdfe": "http://www.portalfiscal.inf.br/mdfe",

0 commit comments

Comments
 (0)