emitare 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- emitare/__init__.py +6 -0
- emitare/client.py +133 -0
- emitare-1.0.0.dist-info/METADATA +87 -0
- emitare-1.0.0.dist-info/RECORD +6 -0
- emitare-1.0.0.dist-info/WHEEL +5 -0
- emitare-1.0.0.dist-info/top_level.txt +1 -0
emitare/__init__.py
ADDED
emitare/client.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Cliente principal do SDK Emitare para Python."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import urllib.request
|
|
5
|
+
import urllib.error
|
|
6
|
+
from typing import Any, Dict, Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class EmitareError(Exception):
|
|
10
|
+
def __init__(self, message: str, status_code: int = 0, body: Any = None):
|
|
11
|
+
super().__init__(message)
|
|
12
|
+
self.status_code = status_code
|
|
13
|
+
self.body = body
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class _Resource:
|
|
17
|
+
def __init__(self, client: "Emitare"):
|
|
18
|
+
self._c = client
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class NfseResource(_Resource):
|
|
22
|
+
def emitir(self, dados: Dict) -> Dict:
|
|
23
|
+
return self._c._request("POST", "/api/v1/nfse/emitir", dados)
|
|
24
|
+
|
|
25
|
+
def consultar(self, nfse_id: str) -> Dict:
|
|
26
|
+
return self._c._request("GET", f"/api/v1/nfse/{nfse_id}")
|
|
27
|
+
|
|
28
|
+
def cancelar(self, nfse_id: str, motivo: str) -> Dict:
|
|
29
|
+
return self._c._request("POST", f"/api/v1/nfse/{nfse_id}/cancelar", {"motivo": motivo})
|
|
30
|
+
|
|
31
|
+
def listar(self, empresa_id: str, **params) -> Dict:
|
|
32
|
+
qs = "&".join(f"{k}={v}" for k, v in params.items())
|
|
33
|
+
path = f"/api/v1/nfse?empresaId={empresa_id}" + (f"&{qs}" if qs else "")
|
|
34
|
+
return self._c._request("GET", path)
|
|
35
|
+
|
|
36
|
+
def xml(self, nfse_id: str) -> Dict:
|
|
37
|
+
return self._c._request("GET", f"/api/v1/nfse/{nfse_id}/xml")
|
|
38
|
+
|
|
39
|
+
def pdf(self, nfse_id: str) -> Dict:
|
|
40
|
+
return self._c._request("GET", f"/api/v1/nfse/{nfse_id}/pdf")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class CompaniesResource(_Resource):
|
|
44
|
+
def listar(self) -> Dict:
|
|
45
|
+
return self._c._request("GET", "/api/v1/companies")
|
|
46
|
+
|
|
47
|
+
def criar(self, dados: Dict) -> Dict:
|
|
48
|
+
return self._c._request("POST", "/api/v1/companies", dados)
|
|
49
|
+
|
|
50
|
+
def buscar(self, empresa_id: str) -> Dict:
|
|
51
|
+
return self._c._request("GET", f"/api/v1/companies/{empresa_id}")
|
|
52
|
+
|
|
53
|
+
def atualizar(self, empresa_id: str, dados: Dict) -> Dict:
|
|
54
|
+
return self._c._request("PATCH", f"/api/v1/companies/{empresa_id}", dados)
|
|
55
|
+
|
|
56
|
+
def remover(self, empresa_id: str) -> Dict:
|
|
57
|
+
return self._c._request("DELETE", f"/api/v1/companies/{empresa_id}")
|
|
58
|
+
|
|
59
|
+
def upload_certificado(self, empresa_id: str, pfx_base64: str, senha: str) -> Dict:
|
|
60
|
+
return self._c._request("POST", f"/api/v1/companies/{empresa_id}/certificate", {
|
|
61
|
+
"pfxBase64": pfx_base64,
|
|
62
|
+
"senha": senha
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class MunicipiosResource(_Resource):
|
|
67
|
+
def buscar_por_ibge(self, ibge: int) -> Dict:
|
|
68
|
+
return self._c._request("GET", f"/api/v1/municipios/{ibge}")
|
|
69
|
+
|
|
70
|
+
def buscar_por_nome(self, nome: str) -> Dict:
|
|
71
|
+
import urllib.parse
|
|
72
|
+
return self._c._request("GET", f"/api/v1/municipios?nome={urllib.parse.quote(nome)}")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class Emitare:
|
|
76
|
+
"""
|
|
77
|
+
Cliente da API NFS-e Emitare.
|
|
78
|
+
|
|
79
|
+
Uso:
|
|
80
|
+
from emitare import Emitare
|
|
81
|
+
|
|
82
|
+
client = Emitare("sua-api-key")
|
|
83
|
+
nota = client.nfse.emitir({ ... })
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
def __init__(
|
|
87
|
+
self,
|
|
88
|
+
api_key: str,
|
|
89
|
+
base_url: str = "https://emitare.com.br",
|
|
90
|
+
timeout: int = 30,
|
|
91
|
+
):
|
|
92
|
+
if not api_key:
|
|
93
|
+
raise ValueError("api_key é obrigatório")
|
|
94
|
+
self.api_key = api_key
|
|
95
|
+
self.base_url = base_url.rstrip("/")
|
|
96
|
+
self.timeout = timeout
|
|
97
|
+
|
|
98
|
+
self.nfse = NfseResource(self)
|
|
99
|
+
self.companies = CompaniesResource(self)
|
|
100
|
+
self.municipios = MunicipiosResource(self)
|
|
101
|
+
|
|
102
|
+
def _request(self, method: str, path: str, body: Optional[Dict] = None) -> Any:
|
|
103
|
+
full_url = self.base_url + path
|
|
104
|
+
payload = json.dumps(body).encode() if body is not None else None
|
|
105
|
+
|
|
106
|
+
req = urllib.request.Request(
|
|
107
|
+
full_url,
|
|
108
|
+
data=payload,
|
|
109
|
+
method=method,
|
|
110
|
+
headers={
|
|
111
|
+
"x-api-key": self.api_key,
|
|
112
|
+
"Content-Type": "application/json",
|
|
113
|
+
"Accept": "application/json",
|
|
114
|
+
"User-Agent": "emitare-python/1.0.0",
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
with urllib.request.urlopen(req, timeout=self.timeout) as resp:
|
|
120
|
+
return json.loads(resp.read().decode())
|
|
121
|
+
except urllib.error.HTTPError as e:
|
|
122
|
+
body = {}
|
|
123
|
+
try:
|
|
124
|
+
body = json.loads(e.read().decode())
|
|
125
|
+
except Exception:
|
|
126
|
+
pass
|
|
127
|
+
raise EmitareError(
|
|
128
|
+
body.get("message", f"HTTP {e.code}"),
|
|
129
|
+
e.code,
|
|
130
|
+
body
|
|
131
|
+
) from e
|
|
132
|
+
except urllib.error.URLError as e:
|
|
133
|
+
raise EmitareError(str(e.reason), 0, None) from e
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: emitare
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SDK Python para a API NFS-e Emitare — emita notas fiscais de serviço em todos os municípios do Brasil
|
|
5
|
+
Home-page: https://emitare.com.br/docs
|
|
6
|
+
Author: Emitare
|
|
7
|
+
Author-email: dev@emitare.com.br
|
|
8
|
+
Project-URL: Documentação, https://emitare.com.br/docs
|
|
9
|
+
Project-URL: Repositório, https://github.com/krgitti/emitare-nfs-api
|
|
10
|
+
Project-URL: Rastreador de bugs, https://github.com/krgitti/emitare-nfs-api/issues
|
|
11
|
+
Keywords: nfse nota-fiscal-servico api-nfse brasil prefeitura erp fiscal
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: keywords
|
|
32
|
+
Dynamic: project-url
|
|
33
|
+
Dynamic: requires-python
|
|
34
|
+
Dynamic: summary
|
|
35
|
+
|
|
36
|
+
# Emitare SDK para Python
|
|
37
|
+
|
|
38
|
+
SDK oficial Python para a [API NFS-e Emitare](https://emitare.com.br) — emita Notas Fiscais de Serviço Eletrônicas em todos os 5.570 municípios do Brasil.
|
|
39
|
+
|
|
40
|
+
## Instalação
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install emitare
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Uso rápido
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from emitare import Emitare
|
|
50
|
+
|
|
51
|
+
client = Emitare("sua-api-key")
|
|
52
|
+
|
|
53
|
+
# Emitir NFS-e
|
|
54
|
+
nfse = client.nfse.emitir(
|
|
55
|
+
empresa_id="uuid-da-empresa",
|
|
56
|
+
tomador={
|
|
57
|
+
"cpfCnpj": "12345678000195",
|
|
58
|
+
"razaoSocial": "Empresa Tomadora Ltda",
|
|
59
|
+
"email": "financeiro@tomadora.com.br"
|
|
60
|
+
},
|
|
61
|
+
servico={
|
|
62
|
+
"codigoMunicipio": 3550308, # São Paulo
|
|
63
|
+
"descricao": "Desenvolvimento de software",
|
|
64
|
+
"valorTotal": 1500.00,
|
|
65
|
+
"aliquotaIss": 2.0
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
print(f"NFS-e emitida: {nfse['numero']}")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Funcionalidades
|
|
73
|
+
|
|
74
|
+
- ✅ Emissão de NFS-e em 5.570 municípios brasileiros
|
|
75
|
+
- ✅ Suporte a 10 provedores (GINFES, ISSNet, SIGISS, Betha, IPM, SimplISS, DSF, eGoverne, PRODAM, Padrão Nacional 2026)
|
|
76
|
+
- ✅ Padrão Nacional 2026 (LC 214/2025 — IBS/CBS)
|
|
77
|
+
- ✅ Consulta e cancelamento de NFS-e
|
|
78
|
+
- ✅ Emissão em lote
|
|
79
|
+
- ✅ Webhooks em tempo real
|
|
80
|
+
|
|
81
|
+
## Documentação
|
|
82
|
+
|
|
83
|
+
Documentação completa em [emitare.com.br/docs](https://emitare.com.br/docs)
|
|
84
|
+
|
|
85
|
+
## Licença
|
|
86
|
+
|
|
87
|
+
MIT
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
emitare/__init__.py,sha256=5GQlc0sYqDxXyRDT_a0STOu94Zpwk_W3ghfY9XLwEVU,149
|
|
2
|
+
emitare/client.py,sha256=TbS6qpVBSDqNw6VwtvcLNKk-cXY08ktFo4XBla6V0NI,4374
|
|
3
|
+
emitare-1.0.0.dist-info/METADATA,sha256=zOlI2GhebPE_0m9vxVD7LOFTKTxb81MLlaAEsgFzpAU,2634
|
|
4
|
+
emitare-1.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
5
|
+
emitare-1.0.0.dist-info/top_level.txt,sha256=QjHxXv4Pp8Emuu1Cla8MV10PI6eleaDApWQtmBHIL7o,8
|
|
6
|
+
emitare-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
emitare
|