Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .xsdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<PostponedAnnotations>false</PostponedAnnotations>
<UnnestClasses>false</UnnestClasses>
</Output>
<Extensions>
<!--Extensions>
<Extension type="class" class=".*" import="nfelib.CommonMixin" prepend="false" applyIfDerived="false"/>
</Extensions>
</Extensions-->
<Conventions>
<ClassName case="pascalCase" safePrefix="type"/>
<FieldName case="originalCase" safePrefix="value"/>
Expand All @@ -21,6 +21,12 @@
<PackageName case="snakeCase" safePrefix="pkg"/>
</Conventions>
<Substitutions>
<!-- Because we use the originalCase options, some dataclass attributes
might have the same names as dataclass types, typically starting
with an upper case. In these few cases, we use the xsdata substitution
system to replace these attributes starting with a lower case.
-->

<!-- defaults : -->
<Substitution type="package" search="http://www.w3.org/2001/XMLSchema" replace="xs"/>
<Substitution type="package" search="http://www.w3.org/XML/1998/namespace" replace="xml"/>
Expand All @@ -31,6 +37,11 @@
<Substitution type="package" search="http://schemas.xmlsoap.org/wsdl/soap12/" replace="soap12"/>
<Substitution type="package" search="http://schemas.xmlsoap.org/soap/envelope/" replace="soapenv"/>

<!-- soap: -->
<Substitution type="field" search="Header" replace="header"/>
<Substitution type="field" search="Body" replace="body"/>
<Substitution type="field" search="Fault" replace="fault"/>

<!-- xmldsig : -->
<Substitution type="field" search="^@any_element$" replace="any_element"/>
<Substitution type="field" search="^@other_element$" replace="other_element"/>
Expand Down
Empty file.
156 changes: 156 additions & 0 deletions nfelib/cte/client/v4_0/servers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Auto-generated file. Do not edit manually.
# ruff: noqa: D101
# ruff: noqa: E501

from __future__ import annotations # Python 3.8 compat

from enum import Enum
from typing import TypedDict


class Endpoint(Enum):
QRCODE = "qrcode"
CTESTATUSSERVICOV4 = "CteStatusServicoV4"
CTECONSULTAV4 = "CteConsultaV4"
CTERECEPCAOEVENTOV4 = "CteRecepcaoEventoV4"
CTERECEPCAOOSV4 = "CTeRecepcaoOSV4"
CTERECEPCAOSINCV4 = "CTeRecepcaoSincV4"
CTERECEPCAOGTVEV4 = "CTeRecepcaoGTVeV4"
CTERECEPCAOSIMPV4 = "CTeRecepcaoSimpV4"


class ServerConfig(TypedDict):
prod_server: str
dev_server: str
soap_version: str
endpoints: dict[Endpoint, str]


servers: dict[str, ServerConfig] = {
"MT": {
"prod_server": "cte.sefaz.mt.gov.br",
"dev_server": "homologacao.sefaz.mt.gov.br",
"soap_version": "1.1",
"endpoints": {
Endpoint.QRCODE: "/cte/qrcode",
Endpoint.CTESTATUSSERVICOV4: "/ctews2/services/CTeStatusServicoV4?wsdl",
Endpoint.CTECONSULTAV4: "/ctews2/services/CTeConsultaV4?wsdl",
Endpoint.CTERECEPCAOEVENTOV4: "/ctews2/services/CTeRecepcaoEventoV4?wsdl",
Endpoint.CTERECEPCAOOSV4: "/ctews/services/CTeRecepcaoOSV4?wsdl",
Endpoint.CTERECEPCAOSINCV4: "/ctews2/services/CTeRecepcaoSincV4?wsdl",
Endpoint.CTERECEPCAOGTVEV4: "/ctews2/services/CTeRecepcaoGTVeV4?wsdl",
Endpoint.CTERECEPCAOSIMPV4: "/cte-ws/services/CTeRecepcaoSimpV4",
},
},
"MS": {
"prod_server": "producao.cte.ms.gov.br",
"dev_server": "homologacao.cte.ms.gov.br",
"soap_version": "1.1",
"endpoints": {
Endpoint.QRCODE: "/cte/qrcode",
Endpoint.CTESTATUSSERVICOV4: "/ws/CTeStatusServicoV4",
Endpoint.CTECONSULTAV4: "/ws/CTeConsultaV4",
Endpoint.CTERECEPCAOEVENTOV4: "/ws/CTeRecepcaoEventoV4",
Endpoint.CTERECEPCAOOSV4: "/ws/CTeRecepcaoOSV4",
Endpoint.CTERECEPCAOSINCV4: "/ws/CTeRecepcaoSincV4",
Endpoint.CTERECEPCAOGTVEV4: "/ws/CTeRecepcaoGTVeV4",
Endpoint.CTERECEPCAOSIMPV4: "/ws/CTeRecepcaoSimpV4",
},
},
"MG": {
"prod_server": "cte.fazenda.mg.gov.br",
"dev_server": "hcte.fazenda.mg.gov.br",
"soap_version": "1.2",
"endpoints": {
Endpoint.QRCODE: "/portalcte/sistema/qrcode.xhtml",
Endpoint.CTESTATUSSERVICOV4: "/cte/services/CTeStatusServicoV4",
Endpoint.CTECONSULTAV4: "/cte/services/CTeConsultaV4",
Endpoint.CTERECEPCAOEVENTOV4: "/cte/services/CTeRecepcaoEventoV4",
Endpoint.CTERECEPCAOOSV4: "/cte/services/CTeRecepcaoOSV4",
Endpoint.CTERECEPCAOSINCV4: "/cte/services/CTeRecepcaoSincV4",
Endpoint.CTERECEPCAOGTVEV4: "/cte/services/CTeRecepcaoGTVeV4",
Endpoint.CTERECEPCAOSIMPV4: "/cte/services/CTeRecepcaoSimpV4",
},
},
"PR": {
"prod_server": "cte.fazenda.pr.gov.br",
"dev_server": "homologacao.cte.fazenda.pr.gov.br",
"soap_version": "1.2",
"endpoints": {
Endpoint.QRCODE: "/cte/qrcode",
Endpoint.CTESTATUSSERVICOV4: "/cte4/CTeStatusServicoV4?wsdl",
Endpoint.CTECONSULTAV4: "/cte4/CTeConsultaV4?wsdl",
Endpoint.CTERECEPCAOEVENTOV4: "/cte4/CTeRecepcaoEventoV4?wsdl",
Endpoint.CTERECEPCAOOSV4: "/cte4/CTeRecepcaoOSV4?wsdl",
Endpoint.CTERECEPCAOSINCV4: "/cte4/CTeRecepcaoSincV4?wsdl",
Endpoint.CTERECEPCAOGTVEV4: "/cte4/CTeRecepcaoGTVeV4?wsdl",
Endpoint.CTERECEPCAOSIMPV4: "/cte4/CTeRecepcaoSimpV4",
},
},
"RS": {
"prod_server": "cte.svrs.rs.gov.br",
"dev_server": "cte-homologacao.svrs.rs.gov.br",
"soap_version": "1.2",
"endpoints": {
Endpoint.QRCODE: "/cte/qrCode",
Endpoint.CTESTATUSSERVICOV4: "/ws/CTeStatusServicoV4/CTeStatusServicoV4.asmx",
Endpoint.CTECONSULTAV4: "/ws/CTeConsultaV4/CTeConsultaV4.asmx",
Endpoint.CTERECEPCAOEVENTOV4: "/ws/CTeRecepcaoEventoV4/CTeRecepcaoEventoV4.asmx",
Endpoint.CTERECEPCAOOSV4: "/ws/CTeRecepcaoOSV4/CTeRecepcaoOSV4.asmx",
Endpoint.CTERECEPCAOSINCV4: "/ws/CTeRecepcaoSincV4/CTeRecepcaoSincV4.asmx",
Endpoint.CTERECEPCAOGTVEV4: "/ws/CTeRecepcaoGTVeV4/CTeRecepcaoGTVeV4.asmx",
Endpoint.CTERECEPCAOSIMPV4: "/ws/CTeRecepcaoSimpV4/CTeRecepcaoSimpV4.asmx",
},
},
"SP": {
"prod_server": "nfe.fazenda.sp.gov.br",
"dev_server": "homologacao.nfe.fazenda.sp.gov.br",
"soap_version": "1.2",
"endpoints": {
Endpoint.QRCODE: "/CTeConsulta/qrCode",
Endpoint.CTESTATUSSERVICOV4: "/CTeWS/WS/CTeStatusServicoV4.asmx",
Endpoint.CTECONSULTAV4: "/CTeWS/WS/CTeConsultaV4.asmx",
Endpoint.CTERECEPCAOEVENTOV4: "/CTeWS/WS/CTeRecepcaoEventoV4.asmx",
Endpoint.CTERECEPCAOOSV4: "/CTeWS/WS/CTeRecepcaoOSV4.asmx",
Endpoint.CTERECEPCAOSINCV4: "/CTeWS/WS/CTeRecepcaoSincV4.asmx",
Endpoint.CTERECEPCAOGTVEV4: "/CTeWS/WS/CTeRecepcaoGTVeV4.asmx",
Endpoint.CTERECEPCAOSIMPV4: "/CTeWS/WS/CTeRecepcaoSimpV4.asmx",
},
},
"SVRS": {
"prod_server": "cte.svrs.rs.gov.br",
"dev_server": "cte-homologacao.svrs.rs.gov.br",
"soap_version": "1.2",
"endpoints": {
Endpoint.QRCODE: "/cte/qrCode",
Endpoint.CTESTATUSSERVICOV4: "/ws/CTeStatusServicoV4/CTeStatusServicoV4.asmx",
Endpoint.CTECONSULTAV4: "/ws/CTeConsultaV4/CTeConsultaV4.asmx",
Endpoint.CTERECEPCAOEVENTOV4: "/ws/CTeRecepcaoEventoV4/CTeRecepcaoEventoV4.asmx",
Endpoint.CTERECEPCAOOSV4: "/ws/CTeRecepcaoOSV4/CTeRecepcaoOSV4.asmx",
Endpoint.CTERECEPCAOSINCV4: "/ws/CTeRecepcaoSincV4/CTeRecepcaoSincV4.asmx",
Endpoint.CTERECEPCAOGTVEV4: "/ws/CTeRecepcaoGTVeV4/CTeRecepcaoGTVeV4.asmx",
Endpoint.CTERECEPCAOSIMPV4: "/ws/CTeRecepcaoSimpV4/CTeRecepcaoSimpV4.asmx",
},
},
"SVSP": {
"prod_server": "nfe.fazenda.sp.gov.br",
"dev_server": "homologacao.nfe.fazenda.sp.gov.br",
"soap_version": "1.2",
"endpoints": {
Endpoint.QRCODE: "/CTeConsulta/qrCode",
Endpoint.CTESTATUSSERVICOV4: "/CTeWS/WS/CTeStatusServicoV4.asmx",
Endpoint.CTECONSULTAV4: "/CTeWS/WS/CTeConsultaV4.asmx",
Endpoint.CTERECEPCAOEVENTOV4: "/CTeWS/WS/CTeRecepcaoEventoV4.asmx",
Endpoint.CTERECEPCAOOSV4: "/CTeWS/WS/CTeRecepcaoOSV4.asmx",
Endpoint.CTERECEPCAOSINCV4: "/CTeWS/WS/CTeRecepcaoSincV4.asmx",
Endpoint.CTERECEPCAOGTVEV4: "/CTeWS/WS/CTeRecepcaoGTVeV4.asmx",
Endpoint.CTERECEPCAOSIMPV4: "/CTeWS/WS/CTeRecepcaoSimpV4.asmx",
},
},
"AN": {
"prod_server": "www1.cte.fazenda.gov.br",
"dev_server": "hom1.cte.fazenda.gov.br",
"soap_version": "1.1",
"endpoints": {},
},
}
38 changes: 38 additions & 0 deletions nfelib/cte/client/v4_0/servers_scraper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (C) 2024 Raphaël Valyi - Akretion <[email protected]>

import sys
from pathlib import Path

from nfelib.utils.servers_scraper import fetch_servers, save_servers
from nfelib.utils.soap_generator import generate_soap

# Constants
PROD_URL = "https://www.cte.fazenda.gov.br/portal/webServices.aspx"
DEV_URL = "https://hom.cte.fazenda.gov.br/portal/webServices.aspx"
OUTPUT_FILE = Path("nfelib/cte/client/v4_0/servers.py")


def main():
"""Cli entry point."""
download = False
if "--download" in sys.argv:
download = True
sys.argv.remove(
"--download"
) # Remove the --download flag to avoid interfering with argparse

generate = False
if "--generate" in sys.argv:
generate = True
sys.argv.remove(
"--generate"
) # Remove the --generate flag to avoid interfering with argparse

servers, endpoints = fetch_servers(PROD_URL, DEV_URL)
if servers:
save_servers(servers, endpoints, OUTPUT_FILE)
generate_soap(servers, endpoints, download, generate)


if __name__ == "__main__":
main()
6 changes: 6 additions & 0 deletions nfelib/cte/soap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""This file was generated by xsdata, v25.4, on 2025-04-15 20:42:56

Generator: DataclassGenerator
See: https://xsdata.readthedocs.io/
"""
# nothing here
Empty file.
143 changes: 143 additions & 0 deletions nfelib/cte/soap/v4_0/cteconsultav4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
"""This file was generated by xsdata, v25.4, on 2025-04-15 20:52:17

Generator: DataclassGenerator
See: https://xsdata.readthedocs.io/
"""

from dataclasses import dataclass, field
from typing import Optional

__NAMESPACE__ = "http://www.portalfiscal.inf.br/cte/wsdl/CTeConsultaV4"


@dataclass
class CteConsultaCtresult:
class Meta:
name = "cteConsultaCTResult"
namespace = "http://www.portalfiscal.inf.br/cte/wsdl/CTeConsultaV4"

content: list[object] = field(
default_factory=list,
metadata={
"type": "Wildcard",
"namespace": "##any",
"mixed": True,
},
)


@dataclass
class CteDadosMsg:
class Meta:
name = "cteDadosMsg"
namespace = "http://www.portalfiscal.inf.br/cte/wsdl/CTeConsultaV4"

content: list[object] = field(
default_factory=list,
metadata={
"type": "Wildcard",
"namespace": "##any",
"mixed": True,
},
)


@dataclass
class CteConsultaV4Soap12CteConsultaCtInput:
class Meta:
name = "Envelope"
namespace = "http://schemas.xmlsoap.org/soap/envelope/"

body: Optional["CteConsultaV4Soap12CteConsultaCtInput.Body"] = field(
default=None,
metadata={
"name": "Body",
"type": "Element",
},
)

@dataclass
class Body:
cteDadosMsg: Optional[CteDadosMsg] = field(
default=None,
metadata={
"type": "Element",
"namespace": "http://www.portalfiscal.inf.br/cte/wsdl/CTeConsultaV4",
},
)


@dataclass
class CteConsultaV4Soap12CteConsultaCtOutput:
class Meta:
name = "Envelope"
namespace = "http://schemas.xmlsoap.org/soap/envelope/"

body: Optional["CteConsultaV4Soap12CteConsultaCtOutput.Body"] = field(
default=None,
metadata={
"name": "Body",
"type": "Element",
},
)

@dataclass
class Body:
cteConsultaCTResult: Optional[CteConsultaCtresult] = field(
default=None,
metadata={
"type": "Element",
"namespace": "http://www.portalfiscal.inf.br/cte/wsdl/CTeConsultaV4",
},
)
fault: Optional[
"CteConsultaV4Soap12CteConsultaCtOutput.Body.Fault"
] = field(
default=None,
metadata={
"name": "Fault",
"type": "Element",
},
)

@dataclass
class Fault:
faultcode: Optional[str] = field(
default=None,
metadata={
"type": "Element",
"namespace": "",
},
)
faultstring: Optional[str] = field(
default=None,
metadata={
"type": "Element",
"namespace": "",
},
)
faultactor: Optional[str] = field(
default=None,
metadata={
"type": "Element",
"namespace": "",
},
)
detail: Optional[str] = field(
default=None,
metadata={
"type": "Element",
"namespace": "",
},
)


class CteConsultaV4Soap12CteConsultaCt:
style = "document"
location = "https://cte.svrs.rs.gov.br/ws/CTeConsultaV4/CTeConsultaV4.asmx"
transport = "http://schemas.xmlsoap.org/soap/http"
soapAction = (
"http://www.portalfiscal.inf.br/cte/wsdl/CTeConsultaV4/cteConsultaCT"
)
input = CteConsultaV4Soap12CteConsultaCtInput
output = CteConsultaV4Soap12CteConsultaCtOutput
Loading
Loading