diff --git a/pytrustnfe/nfse/imperial/__init__.py b/pytrustnfe/nfse/imperial/__init__.py
new file mode 100644
index 0000000..1393758
--- /dev/null
+++ b/pytrustnfe/nfse/imperial/__init__.py
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+# © 2016 Danimar Ribeiro, Trustcode
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+import os
+from pytrustnfe import HttpClient
+from pytrustnfe.xml import render_xml, sanitize_response
+
+
+def _render(certificado, method, **kwargs):
+ path = os.path.join(os.path.dirname(__file__), 'templates')
+ xml_send = render_xml(path, '%s.xml' % method, True, **kwargs)
+ return xml_send
+
+
+def _send(certificado, method, **kwargs):
+ base_url = ''
+ if kwargs['ambiente'] == 'producao':
+ base_url = 'https://producao.ginfes.com.br/ServiceGinfesImpl?wsdl'
+ else:
+ base_url = 'https://nfehomologacao.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa
+
+ xml_send = kwargs["xml"]
+ path = os.path.join(os.path.dirname(__file__), 'templates')
+ soap = render_xml(path, 'SoapRequest.xml', False, soap_body=xml_send)
+
+ client = HttpClient(base_url)
+ response = client.post_soap(soap, 'NFeaction/AWS_NFE.%s' % method)
+
+ response, obj = sanitize_response(response)
+ return {
+ 'sent_xml': xml_send,
+ 'received_xml': response,
+ 'object': obj
+ }
+
+
+def xml_processa_rps(certificado, **kwargs):
+ return _render(certificado, 'PROCESSARPS', **kwargs)
+
+
+def processa_rps(certificado, **kwargs):
+ if "xml" not in kwargs:
+ kwargs['xml'] = xml_processa_rps(certificado, **kwargs)
+ return _send(certificado, 'PROCESSARPS', **kwargs)
+
+
+def xml_consulta_protocolo(certificado, **kwargs):
+ return _render(certificado, 'CONSULTAPROTOCOLO', **kwargs)
+
+
+def consulta_protocolo(certificado, **kwargs):
+ if "xml" not in kwargs:
+ kwargs['xml'] = xml_consulta_protocolo(certificado, **kwargs)
+ return _send(certificado, 'CONSULTAPROTOCOLO', **kwargs)
+
+
+def xml_consulta_notas_protocolo(certificado, **kwargs):
+ return _render(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs)
+
+
+def consulta_notas_protocolo(certificado, **kwargs):
+ if "xml" not in kwargs:
+ kwargs['xml'] = xml_consulta_notas_protocolo(certificado, **kwargs)
+ return _send(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs)
+
+
+def xml_cancelar_nfse(certificado, **kwargs):
+ return _render(certificado, 'CANCELANOTAELETRONICA', **kwargs)
+
+
+def cancelar_nfse(certificado, **kwargs):
+ if "xml" not in kwargs:
+ kwargs['xml'] = xml_cancelar_nfse(certificado, **kwargs)
+ return _send(certificado, 'CANCELANOTAELETRONICA', **kwargs)
diff --git a/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml b/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml
new file mode 100644
index 0000000..7a383a3
--- /dev/null
+++ b/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml
@@ -0,0 +1,17 @@
+
+
+
+ [string]
+ [string]
+
+
+ [string]
+ [int]
+ [string]
+ [int]
+ [double]
+ [string]
+ [string]
+
+
+
diff --git a/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml b/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml
new file mode 100644
index 0000000..5c0f433
--- /dev/null
+++ b/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml
@@ -0,0 +1,9 @@
+
+
+ [string]
+
+ [string]
+ [string]
+
+
+
diff --git a/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml b/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml
new file mode 100644
index 0000000..d321c21
--- /dev/null
+++ b/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml
@@ -0,0 +1,9 @@
+
+
+ [string]
+
+ [string]
+ [string]
+
+
+
diff --git a/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml
new file mode 100644
index 0000000..4d65450
--- /dev/null
+++ b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml
@@ -0,0 +1,78 @@
+
+
+
+ [string]
+ [string]
+
+
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+
+
+
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+
+
+
+ [string]
+ [string]
+ [string]
+
+
+
+
+
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+ [string]
+
+
+
+
diff --git a/pytrustnfe/nfse/imperial/templates/SoapRequest.xml b/pytrustnfe/nfse/imperial/templates/SoapRequest.xml
new file mode 100644
index 0000000..e8b56b4
--- /dev/null
+++ b/pytrustnfe/nfse/imperial/templates/SoapRequest.xml
@@ -0,0 +1,5 @@
+
+
+ {{ soap_body }}
+
+