|
|
|
@ -14,6 +14,8 @@ from pytrustnfe.Certificado import converte_pfx_pem |
|
|
|
from pytrustnfe.Strings import CONSULTA_CADASTRO_COMPLETA |
|
|
|
|
|
|
|
class Comunicacao(object): |
|
|
|
url = '' |
|
|
|
web_service = '' |
|
|
|
|
|
|
|
def __init__(self, certificado, senha): |
|
|
|
self.certificado = certificado |
|
|
|
@ -35,6 +37,23 @@ class Comunicacao(object): |
|
|
|
|
|
|
|
return chave_temp, certificado_temp |
|
|
|
|
|
|
|
def _validar_dados(self): |
|
|
|
assert self.url != '', "Url servidor não configurada" |
|
|
|
assert self.web_service != '', "Web service não especificado" |
|
|
|
assert self.certificado != '', "Certificado não configurado" |
|
|
|
assert self.senha != '', "Senha não configurada" |
|
|
|
|
|
|
|
def _executar_consulta(self, xmlEnviar): |
|
|
|
self._validar_dados() |
|
|
|
chave, certificado = self._preparar_temp_pem() |
|
|
|
|
|
|
|
client = HttpClient(self.url, chave, certificado) |
|
|
|
xml_retorno = client.post_xml(self.web_service, xmlEnviar) |
|
|
|
|
|
|
|
obj = objectify.fromstring(xml_retorno) |
|
|
|
return xml_retorno, obj |
|
|
|
|
|
|
|
|
|
|
|
def consulta_cadastro(self, obj_consulta): |
|
|
|
chave, certificado = self._preparar_temp_pem() |
|
|
|
|
|
|
|
|