attime-star-api-python-sdk 1.2.0__tar.gz → 1.3.0__tar.gz
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.
- {attime_star_api_python_sdk-1.2.0/src/attime_star_api_python_sdk.egg-info → attime_star_api_python_sdk-1.3.0}/PKG-INFO +1 -1
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/pyproject.toml +1 -1
- attime_star_api_python_sdk-1.2.0/src/attime/star/apis/oxxy001.py → attime_star_api_python_sdk-1.3.0/src/attime/star/apis/bvix.py +11 -11
- attime_star_api_python_sdk-1.2.0/src/attime/star/dtos/oxxy001.py → attime_star_api_python_sdk-1.3.0/src/attime/star/dtos/bvix.py +25 -12
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0/src/attime_star_api_python_sdk.egg-info}/PKG-INFO +1 -1
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime_star_api_python_sdk.egg-info/SOURCES.txt +2 -2
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/LICENSE +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/README.md +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/setup.cfg +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime/star/api.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime/star/apis/__init__.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime/star/apis/infocar.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime/star/dtos/__init__.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime/star/dtos/infocar.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime_star_api_python_sdk.egg-info/dependency_links.txt +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime_star_api_python_sdk.egg-info/top_level.txt +0 -0
|
@@ -2,17 +2,17 @@ import logging, jsonpickle
|
|
|
2
2
|
from http import HTTPMethod
|
|
3
3
|
from fmconsult.utils.url import UrlUtil
|
|
4
4
|
from attime.star.api import ATTimeStarApi
|
|
5
|
-
from attime.star.dtos.
|
|
5
|
+
from attime.star.dtos.bvix import APIBvix001DTO, TipoItem
|
|
6
6
|
|
|
7
7
|
ALLOWED_TIPO_ITEM = {int(TipoItem.VIDA_VIAGEM), int(TipoItem.AUTOMOVEL)}
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class
|
|
10
|
+
class BvixApi(ATTimeStarApi):
|
|
11
11
|
|
|
12
|
-
def insere_item_contrato(self, item:
|
|
13
|
-
logging.info('inserting contract item via
|
|
12
|
+
def insere_item_contrato(self, item: APIBvix001DTO | dict) -> list[APIBvix001DTO]:
|
|
13
|
+
logging.info('inserting contract item via ApiBVIX InsereItemContrato...')
|
|
14
14
|
try:
|
|
15
|
-
if isinstance(item,
|
|
15
|
+
if isinstance(item, APIBvix001DTO):
|
|
16
16
|
payload = item.to_dict()
|
|
17
17
|
else:
|
|
18
18
|
payload = dict(item)
|
|
@@ -30,7 +30,7 @@ class Oxxy001Api(ATTimeStarApi):
|
|
|
30
30
|
|
|
31
31
|
url = UrlUtil().make_url(
|
|
32
32
|
self.base_url,
|
|
33
|
-
['btc', '
|
|
33
|
+
['btc', 'ABTP0005', 'ApiBVIX', 'InsereItemContrato']
|
|
34
34
|
)
|
|
35
35
|
res = self.call_request(
|
|
36
36
|
http_method=HTTPMethod.POST,
|
|
@@ -40,22 +40,22 @@ class Oxxy001Api(ATTimeStarApi):
|
|
|
40
40
|
res = jsonpickle.decode(res)
|
|
41
41
|
|
|
42
42
|
if isinstance(res, list):
|
|
43
|
-
return [
|
|
43
|
+
return [APIBvix001DTO.from_dict(row) for row in res]
|
|
44
44
|
|
|
45
45
|
if isinstance(res, dict):
|
|
46
46
|
if 'dados' in res:
|
|
47
47
|
dados = res['dados']
|
|
48
48
|
if isinstance(dados, list):
|
|
49
|
-
return [
|
|
49
|
+
return [APIBvix001DTO.from_dict(row) for row in dados]
|
|
50
50
|
if isinstance(dados, dict):
|
|
51
|
-
return [
|
|
51
|
+
return [APIBvix001DTO.from_dict(dados)]
|
|
52
52
|
raise Exception(res.get('mensagem', 'Resposta inesperada em dados'))
|
|
53
53
|
|
|
54
54
|
if 'codigo' in res:
|
|
55
55
|
raise Exception(res.get('mensagem', 'Erro desconhecido'))
|
|
56
56
|
|
|
57
|
-
return [
|
|
57
|
+
return [APIBvix001DTO.from_dict(res)]
|
|
58
58
|
|
|
59
|
-
raise Exception('Resposta inesperada da API
|
|
59
|
+
raise Exception('Resposta inesperada da API BVIX')
|
|
60
60
|
except:
|
|
61
61
|
raise
|
|
@@ -49,7 +49,7 @@ class ValoresCoberturaServico:
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
@dataclass
|
|
52
|
-
class
|
|
52
|
+
class APIBvix001DTO:
|
|
53
53
|
tipoItem: int | TipoItem
|
|
54
54
|
numeroContrato: str
|
|
55
55
|
cpf: Optional[str] = None
|
|
@@ -62,10 +62,9 @@ class APIOxxy001DTO:
|
|
|
62
62
|
inicioVigencia: Optional[str] = None
|
|
63
63
|
fimVigencia: Optional[str] = None
|
|
64
64
|
destino: Optional[str] = None
|
|
65
|
-
placa: Optional[str] = None
|
|
66
|
-
chassi: Optional[str] = None
|
|
67
65
|
valoresCoberturas: Optional[list[ValoresCobertura]] = None
|
|
68
66
|
valoresCoberturasServico: Optional[list[ValoresCoberturaServico]] = None
|
|
67
|
+
caracteristicas: Optional[dict[str, str]] = None
|
|
69
68
|
|
|
70
69
|
def to_dict(self):
|
|
71
70
|
raw = asdict(self)
|
|
@@ -75,6 +74,14 @@ class APIOxxy001DTO:
|
|
|
75
74
|
continue
|
|
76
75
|
if isinstance(value, IntEnum):
|
|
77
76
|
result[key] = int(value)
|
|
77
|
+
elif key == 'caracteristicas' and isinstance(value, dict):
|
|
78
|
+
cleaned = {
|
|
79
|
+
str(k): str(v)
|
|
80
|
+
for k, v in value.items()
|
|
81
|
+
if v is not None and str(v) != ''
|
|
82
|
+
}
|
|
83
|
+
if cleaned:
|
|
84
|
+
result[key] = cleaned
|
|
78
85
|
elif isinstance(value, list):
|
|
79
86
|
result[key] = [
|
|
80
87
|
{k: v for k, v in item.items() if v is not None} if isinstance(item, dict) else item
|
|
@@ -85,11 +92,18 @@ class APIOxxy001DTO:
|
|
|
85
92
|
return result
|
|
86
93
|
|
|
87
94
|
@classmethod
|
|
88
|
-
def from_dict(cls, data: dict |
|
|
95
|
+
def from_dict(cls, data: dict | APIBvix001DTO) -> APIBvix001DTO:
|
|
89
96
|
if isinstance(data, cls):
|
|
90
97
|
return data
|
|
91
98
|
coberturas = data.get('valoresCoberturas')
|
|
92
99
|
servicos = data.get('valoresCoberturasServico')
|
|
100
|
+
caracteristicas = data.get('caracteristicas')
|
|
101
|
+
if isinstance(caracteristicas, dict):
|
|
102
|
+
caracteristicas = {
|
|
103
|
+
str(k): str(v) for k, v in caracteristicas.items() if v is not None and str(v) != ''
|
|
104
|
+
} or None
|
|
105
|
+
else:
|
|
106
|
+
caracteristicas = None
|
|
93
107
|
return cls(
|
|
94
108
|
tipoItem=data.get('tipoItem'),
|
|
95
109
|
numeroContrato=data.get('numeroContrato'),
|
|
@@ -103,10 +117,9 @@ class APIOxxy001DTO:
|
|
|
103
117
|
inicioVigencia=data.get('inicioVigencia'),
|
|
104
118
|
fimVigencia=data.get('fimVigencia'),
|
|
105
119
|
destino=data.get('destino'),
|
|
106
|
-
placa=data.get('placa'),
|
|
107
|
-
chassi=data.get('chassi'),
|
|
108
120
|
valoresCoberturas=[ValoresCobertura.from_dict(i) for i in coberturas] if coberturas else None,
|
|
109
121
|
valoresCoberturasServico=[ValoresCoberturaServico.from_dict(i) for i in servicos] if servicos else None,
|
|
122
|
+
caracteristicas=caracteristicas,
|
|
110
123
|
)
|
|
111
124
|
|
|
112
125
|
@classmethod
|
|
@@ -125,7 +138,8 @@ class APIOxxy001DTO:
|
|
|
125
138
|
numeroSorte: Optional[str] = None,
|
|
126
139
|
valoresCoberturas: Optional[list[ValoresCobertura]] = None,
|
|
127
140
|
valoresCoberturasServico: Optional[list[ValoresCoberturaServico]] = None,
|
|
128
|
-
|
|
141
|
+
caracteristicas: Optional[dict[str, str]] = None,
|
|
142
|
+
) -> APIBvix001DTO:
|
|
129
143
|
return cls(
|
|
130
144
|
tipoItem=TipoItem.VIDA_VIAGEM,
|
|
131
145
|
numeroContrato=numeroContrato,
|
|
@@ -141,14 +155,13 @@ class APIOxxy001DTO:
|
|
|
141
155
|
numeroSorte=numeroSorte,
|
|
142
156
|
valoresCoberturas=valoresCoberturas,
|
|
143
157
|
valoresCoberturasServico=valoresCoberturasServico,
|
|
158
|
+
caracteristicas=caracteristicas,
|
|
144
159
|
)
|
|
145
160
|
|
|
146
161
|
@classmethod
|
|
147
162
|
def for_automovel(
|
|
148
163
|
cls,
|
|
149
164
|
numeroContrato: str,
|
|
150
|
-
placa: Optional[str] = None,
|
|
151
|
-
chassi: Optional[str] = None,
|
|
152
165
|
cpf: Optional[str] = None,
|
|
153
166
|
nome: Optional[str] = None,
|
|
154
167
|
dataNascimento: Optional[str] = None,
|
|
@@ -160,12 +173,11 @@ class APIOxxy001DTO:
|
|
|
160
173
|
numeroSorte: Optional[str] = None,
|
|
161
174
|
valoresCoberturas: Optional[list[ValoresCobertura]] = None,
|
|
162
175
|
valoresCoberturasServico: Optional[list[ValoresCoberturaServico]] = None,
|
|
163
|
-
|
|
176
|
+
caracteristicas: Optional[dict[str, str]] = None,
|
|
177
|
+
) -> APIBvix001DTO:
|
|
164
178
|
return cls(
|
|
165
179
|
tipoItem=TipoItem.AUTOMOVEL,
|
|
166
180
|
numeroContrato=numeroContrato,
|
|
167
|
-
placa=placa,
|
|
168
|
-
chassi=chassi,
|
|
169
181
|
cpf=cpf,
|
|
170
182
|
nome=nome,
|
|
171
183
|
dataNascimento=dataNascimento,
|
|
@@ -177,4 +189,5 @@ class APIOxxy001DTO:
|
|
|
177
189
|
numeroSorte=numeroSorte,
|
|
178
190
|
valoresCoberturas=valoresCoberturas,
|
|
179
191
|
valoresCoberturasServico=valoresCoberturasServico,
|
|
192
|
+
caracteristicas=caracteristicas,
|
|
180
193
|
)
|
|
@@ -3,11 +3,11 @@ README.md
|
|
|
3
3
|
pyproject.toml
|
|
4
4
|
src/attime/star/api.py
|
|
5
5
|
src/attime/star/apis/__init__.py
|
|
6
|
+
src/attime/star/apis/bvix.py
|
|
6
7
|
src/attime/star/apis/infocar.py
|
|
7
|
-
src/attime/star/apis/oxxy001.py
|
|
8
8
|
src/attime/star/dtos/__init__.py
|
|
9
|
+
src/attime/star/dtos/bvix.py
|
|
9
10
|
src/attime/star/dtos/infocar.py
|
|
10
|
-
src/attime/star/dtos/oxxy001.py
|
|
11
11
|
src/attime_star_api_python_sdk.egg-info/PKG-INFO
|
|
12
12
|
src/attime_star_api_python_sdk.egg-info/SOURCES.txt
|
|
13
13
|
src/attime_star_api_python_sdk.egg-info/dependency_links.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.0}/src/attime/star/api.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|