libciss 0.1.0a1__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.
- libciss-0.1.0a1.dist-info/METADATA +9 -0
- libciss-0.1.0a1.dist-info/RECORD +10 -0
- libciss-0.1.0a1.dist-info/WHEEL +5 -0
- libciss-0.1.0a1.dist-info/top_level.txt +1 -0
- services/__init__.py +0 -0
- services/cisscontrol/__init__.py +3 -0
- services/cisscontrol/auth.py +60 -0
- services/cisscontrol/models.py +99 -0
- services/cisscontrol/precarga_separacao.py +89 -0
- services/cisscontrol/service.py +10 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
services/cisscontrol/__init__.py,sha256=jLKAr0Wg-suALLnuKYQ7PtBfQxG7gSj56lhNVYjP5Ns,61
|
|
3
|
+
services/cisscontrol/auth.py,sha256=9iFMlR8UjoMLZHAlpDegGJ4GXL3NmKxMC20Hf22Fi6o,1813
|
|
4
|
+
services/cisscontrol/models.py,sha256=qa_7Ijp-Bv7Zr2bI6F-F48epq_mlNhiEbSXHJTN3nB8,2916
|
|
5
|
+
services/cisscontrol/precarga_separacao.py,sha256=7dgXbmFuo4feTgFTR8Ak7aFT-Tfnhv3M19c_8PJQ2Tc,2616
|
|
6
|
+
services/cisscontrol/service.py,sha256=V51BqU66cUSDLlmXKKnyzvru9chlsuEwTWBUrA-SYUM,305
|
|
7
|
+
libciss-0.1.0a1.dist-info/METADATA,sha256=QUipYgnuL_JT6NDnPBB4JtiuPlXz54jkoXCrJiZN2WQ,231
|
|
8
|
+
libciss-0.1.0a1.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
9
|
+
libciss-0.1.0a1.dist-info/top_level.txt,sha256=Xau8qVy0H_tHbGDNnS7i0vFz4WqB9lBwZHg0pGziYuM,9
|
|
10
|
+
libciss-0.1.0a1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
services
|
services/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from functools import wraps
|
|
2
|
+
|
|
3
|
+
from src.exceptions import NotAuthenticatedError
|
|
4
|
+
from .models import LoginResponse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AuthenticationService:
|
|
8
|
+
def __init__(self, client):
|
|
9
|
+
self.client = client
|
|
10
|
+
|
|
11
|
+
self.user: LoginResponse | None = None
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def token(self) -> str | None:
|
|
15
|
+
auth = self.client.session.headers.get("Authorization")
|
|
16
|
+
return auth
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def authenticated(self) -> bool:
|
|
20
|
+
return self.token is not None
|
|
21
|
+
|
|
22
|
+
def login(self, username: str, password: str) -> LoginResponse:
|
|
23
|
+
response = self.client.request(
|
|
24
|
+
"POST",
|
|
25
|
+
"/ciss-control/login",
|
|
26
|
+
json={
|
|
27
|
+
"username": username,
|
|
28
|
+
"password": password,
|
|
29
|
+
},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
data = response.json()
|
|
33
|
+
|
|
34
|
+
self.client.session.headers["Authorization"] = data["tokenBearer"]
|
|
35
|
+
|
|
36
|
+
self.user = LoginResponse(
|
|
37
|
+
token_bearer=data["tokenBearer"],
|
|
38
|
+
id_user=data["idUser"],
|
|
39
|
+
id_grupo=data["idGrupo"],
|
|
40
|
+
username=data["username"],
|
|
41
|
+
enabled=data["enabled"],
|
|
42
|
+
id_empresa=data["idEmpresa"],
|
|
43
|
+
cnpj_empresa=data["cnpjEmpresa"],
|
|
44
|
+
razao_social=data["razaoSocial"].rstrip(),
|
|
45
|
+
permissions=data["permissionsList"],
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
return self.user
|
|
49
|
+
|
|
50
|
+
def logout(self):
|
|
51
|
+
self.client.session.headers.pop("Authorization", None)
|
|
52
|
+
self.user = None
|
|
53
|
+
|
|
54
|
+
def requires_login(func):
|
|
55
|
+
@wraps(func)
|
|
56
|
+
def wrapper(self, *args, **kwargs):
|
|
57
|
+
if not self.client.cisscontrol.auth.authenticated:
|
|
58
|
+
raise NotAuthenticatedError("This endpoint requires authentication. Please log in first.")
|
|
59
|
+
return func(self, *args, **kwargs)
|
|
60
|
+
return wrapper
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from datetime import date
|
|
3
|
+
import datetime
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(slots=True)
|
|
7
|
+
class LoginResponse:
|
|
8
|
+
token_bearer: str
|
|
9
|
+
id_user: int
|
|
10
|
+
id_grupo: int
|
|
11
|
+
username: str
|
|
12
|
+
enabled: bool
|
|
13
|
+
id_empresa: int
|
|
14
|
+
cnpj_empresa: str
|
|
15
|
+
razao_social: str
|
|
16
|
+
permissions: list[str]
|
|
17
|
+
|
|
18
|
+
@dataclass(slots=True)
|
|
19
|
+
class PreCargaSeparacaoItem:
|
|
20
|
+
id_pre_carga: int
|
|
21
|
+
id_empresa: int
|
|
22
|
+
id_documento: int
|
|
23
|
+
id_produto: int
|
|
24
|
+
id_subproduto: int
|
|
25
|
+
ds_local_retirada: str
|
|
26
|
+
num_sequencia: int
|
|
27
|
+
id_lote: str | None
|
|
28
|
+
qtd_produto: float
|
|
29
|
+
fg_separado: str
|
|
30
|
+
qtd_contada_divergente: bool
|
|
31
|
+
id_local_retirada: int
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_dict(cls, data: dict) -> "PreCargaSeparacaoItem":
|
|
35
|
+
return cls(
|
|
36
|
+
id_pre_carga=data["idPreCarga"],
|
|
37
|
+
id_empresa=data["idEmpresa"],
|
|
38
|
+
id_documento=data["idDocumento"],
|
|
39
|
+
id_produto=data["idProduto"],
|
|
40
|
+
id_subproduto=data["idSubproduto"],
|
|
41
|
+
ds_local_retirada=data["dsLocalRetirada"],
|
|
42
|
+
num_sequencia=data["numSequencia"],
|
|
43
|
+
id_lote=data["idLote"] if "idLote" in data else None,
|
|
44
|
+
qtd_produto=data["qtdProduto"],
|
|
45
|
+
fg_separado=data["fgSeparado"],
|
|
46
|
+
qtd_contada_divergente=data["qtdContadaDivergente"],
|
|
47
|
+
id_local_retirada=data["idLocalRetirada"],
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass(slots=True)
|
|
52
|
+
class PreCargaSeparacao:
|
|
53
|
+
id_empresa: int
|
|
54
|
+
id_pre_carga: int
|
|
55
|
+
descricao: str
|
|
56
|
+
dt_movimento: date
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def from_dict(cls, data: dict) -> "PreCargaSeparacao":
|
|
60
|
+
return cls(
|
|
61
|
+
id_empresa=data["idEmpresa"],
|
|
62
|
+
id_pre_carga=data["idPreCarga"],
|
|
63
|
+
descricao=data["descricao"],
|
|
64
|
+
dt_movimento=date.fromisoformat(data["dtMovimento"]),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass(slots=True)
|
|
69
|
+
class PreCargaSeparacaoSubmission:
|
|
70
|
+
id_usuario: int
|
|
71
|
+
id_empresa: int
|
|
72
|
+
id_documento: int
|
|
73
|
+
id_pre_carga: int
|
|
74
|
+
id_produto: int
|
|
75
|
+
id_subproduto: int
|
|
76
|
+
id_local_retirada: int
|
|
77
|
+
ds_local_retirada: str
|
|
78
|
+
num_sequencia: int
|
|
79
|
+
qtd_produto: float
|
|
80
|
+
fg_separado: str
|
|
81
|
+
qtd_contada: float
|
|
82
|
+
dt_hr_inicio: datetime
|
|
83
|
+
|
|
84
|
+
def to_dict(self) -> dict:
|
|
85
|
+
return {
|
|
86
|
+
"idUsuario": self.id_usuario,
|
|
87
|
+
"idEmpresa": self.id_empresa,
|
|
88
|
+
"idDocumento": self.id_documento,
|
|
89
|
+
"idPreCarga": self.id_pre_carga,
|
|
90
|
+
"idProduto": self.id_produto,
|
|
91
|
+
"idSubproduto": self.id_subproduto,
|
|
92
|
+
"idLocalRetirada": self.id_local_retirada,
|
|
93
|
+
"dsLocalRetirada": self.ds_local_retirada,
|
|
94
|
+
"numSequencia": self.num_sequencia,
|
|
95
|
+
"qtdProduto": self.qtd_produto,
|
|
96
|
+
"fgSeparado": self.fg_separado,
|
|
97
|
+
"qtdContada": self.qtd_contada,
|
|
98
|
+
"dtHrInicio": self.dt_hr_inicio.isoformat(),
|
|
99
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from src.services.cisscontrol.models import PreCargaSeparacao, PreCargaSeparacaoItem, PreCargaSeparacaoSubmission
|
|
2
|
+
|
|
3
|
+
from .auth import requires_login
|
|
4
|
+
class PreCargaSeparacaoService:
|
|
5
|
+
def __init__(self, client):
|
|
6
|
+
self.client = client
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@requires_login
|
|
10
|
+
def submit(
|
|
11
|
+
self,
|
|
12
|
+
items: list[PreCargaSeparacaoSubmission],
|
|
13
|
+
):
|
|
14
|
+
response = self.client.request(
|
|
15
|
+
"POST",
|
|
16
|
+
"/ciss-control/precarga_separacao",
|
|
17
|
+
json=[item.to_dict() for item in items],
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return response
|
|
21
|
+
|
|
22
|
+
@requires_login
|
|
23
|
+
def get_all(
|
|
24
|
+
self,
|
|
25
|
+
*,
|
|
26
|
+
id_empresa: int,
|
|
27
|
+
num_dias_sync: int = 99,
|
|
28
|
+
ds_separacao: str = "",
|
|
29
|
+
ds_precarga: str = "",
|
|
30
|
+
ds_ponto_retirada: str = "",
|
|
31
|
+
dt_inicio: str = "",
|
|
32
|
+
ds_pre_separacao: str = "",
|
|
33
|
+
dt_fim: str = "",
|
|
34
|
+
) -> list[PreCargaSeparacao]:
|
|
35
|
+
response = self.client.request(
|
|
36
|
+
"GET",
|
|
37
|
+
"/ciss-control/precarga_separacao",
|
|
38
|
+
params={
|
|
39
|
+
"idEmpresa": id_empresa,
|
|
40
|
+
"numDiasSync": num_dias_sync,
|
|
41
|
+
"dsSeparacao": ds_separacao,
|
|
42
|
+
"dsPreCarga": ds_precarga,
|
|
43
|
+
"dsPontoRetirada": ds_ponto_retirada,
|
|
44
|
+
"dtInicio": dt_inicio,
|
|
45
|
+
"dsPreSeparacao": ds_pre_separacao,
|
|
46
|
+
"dtFim": dt_fim,
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# FIXME: Request is hanging
|
|
51
|
+
if response.status_code == 204:
|
|
52
|
+
return []
|
|
53
|
+
|
|
54
|
+
return [
|
|
55
|
+
PreCargaSeparacao.from_dict(item)
|
|
56
|
+
for item in response.json()
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
@requires_login
|
|
60
|
+
def items(
|
|
61
|
+
self,
|
|
62
|
+
*,
|
|
63
|
+
id_empresa: int,
|
|
64
|
+
id_precarga: int,
|
|
65
|
+
id_usuario: int,
|
|
66
|
+
ds_separacao: str = "",
|
|
67
|
+
ds_precarga: str = "",
|
|
68
|
+
ds_ponto_retirada: str = "",
|
|
69
|
+
dt_inicio: str = "",
|
|
70
|
+
ds_pre_separacao: str = "",
|
|
71
|
+
dt_fim: str = "",
|
|
72
|
+
):
|
|
73
|
+
response = self.client.request(
|
|
74
|
+
"GET",
|
|
75
|
+
"/ciss-control/precarga_separacao/itens",
|
|
76
|
+
params={
|
|
77
|
+
"idEmpresa": id_empresa,
|
|
78
|
+
"idPreCarga": id_precarga,
|
|
79
|
+
"idUsuario": id_usuario,
|
|
80
|
+
"dsSeparacao": ds_separacao,
|
|
81
|
+
"dsPreCarga": ds_precarga,
|
|
82
|
+
"dsPontoRetirada": ds_ponto_retirada,
|
|
83
|
+
"dtInicio": dt_inicio,
|
|
84
|
+
"dsPreSeparacao": ds_pre_separacao,
|
|
85
|
+
"dtFim": dt_fim,
|
|
86
|
+
},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
return [PreCargaSeparacaoItem.from_dict(item) for item in response.json()]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from .auth import AuthenticationService
|
|
2
|
+
from .precarga_separacao import PreCargaSeparacaoService
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CISSControl:
|
|
6
|
+
def __init__(self, client):
|
|
7
|
+
self.client = client
|
|
8
|
+
|
|
9
|
+
self.auth = AuthenticationService(client)
|
|
10
|
+
self.precarga_separacao = PreCargaSeparacaoService(client)
|