attime-star-api-python-sdk 1.2.0__tar.gz → 1.3.1__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.1}/PKG-INFO +1 -1
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/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.1/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.1/src/attime/star/dtos/bvix.py +26 -12
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1/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.1}/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.1}/LICENSE +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/README.md +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/setup.cfg +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/src/attime/star/api.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/src/attime/star/apis/__init__.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/src/attime/star/apis/infocar.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/src/attime/star/dtos/__init__.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/src/attime/star/dtos/infocar.py +0 -0
- {attime_star_api_python_sdk-1.2.0 → attime_star_api_python_sdk-1.3.1}/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.1}/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
|
|
@@ -16,6 +16,7 @@ class ValoresCobertura:
|
|
|
16
16
|
is_Cobertura: Optional[float] = None
|
|
17
17
|
taxa: Optional[float] = None
|
|
18
18
|
premio: Optional[float] = None
|
|
19
|
+
franquia: Optional[float] = None
|
|
19
20
|
|
|
20
21
|
def to_dict(self):
|
|
21
22
|
return {k: v for k, v in asdict(self).items() if v is not None}
|
|
@@ -49,7 +50,7 @@ class ValoresCoberturaServico:
|
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
@dataclass
|
|
52
|
-
class
|
|
53
|
+
class APIBvix001DTO:
|
|
53
54
|
tipoItem: int | TipoItem
|
|
54
55
|
numeroContrato: str
|
|
55
56
|
cpf: Optional[str] = None
|
|
@@ -62,10 +63,9 @@ class APIOxxy001DTO:
|
|
|
62
63
|
inicioVigencia: Optional[str] = None
|
|
63
64
|
fimVigencia: Optional[str] = None
|
|
64
65
|
destino: Optional[str] = None
|
|
65
|
-
placa: Optional[str] = None
|
|
66
|
-
chassi: Optional[str] = None
|
|
67
66
|
valoresCoberturas: Optional[list[ValoresCobertura]] = None
|
|
68
67
|
valoresCoberturasServico: Optional[list[ValoresCoberturaServico]] = None
|
|
68
|
+
caracteristicas: Optional[dict[str, str]] = None
|
|
69
69
|
|
|
70
70
|
def to_dict(self):
|
|
71
71
|
raw = asdict(self)
|
|
@@ -75,6 +75,14 @@ class APIOxxy001DTO:
|
|
|
75
75
|
continue
|
|
76
76
|
if isinstance(value, IntEnum):
|
|
77
77
|
result[key] = int(value)
|
|
78
|
+
elif key == 'caracteristicas' and isinstance(value, dict):
|
|
79
|
+
cleaned = {
|
|
80
|
+
str(k): str(v)
|
|
81
|
+
for k, v in value.items()
|
|
82
|
+
if v is not None and str(v) != ''
|
|
83
|
+
}
|
|
84
|
+
if cleaned:
|
|
85
|
+
result[key] = cleaned
|
|
78
86
|
elif isinstance(value, list):
|
|
79
87
|
result[key] = [
|
|
80
88
|
{k: v for k, v in item.items() if v is not None} if isinstance(item, dict) else item
|
|
@@ -85,11 +93,18 @@ class APIOxxy001DTO:
|
|
|
85
93
|
return result
|
|
86
94
|
|
|
87
95
|
@classmethod
|
|
88
|
-
def from_dict(cls, data: dict |
|
|
96
|
+
def from_dict(cls, data: dict | APIBvix001DTO) -> APIBvix001DTO:
|
|
89
97
|
if isinstance(data, cls):
|
|
90
98
|
return data
|
|
91
99
|
coberturas = data.get('valoresCoberturas')
|
|
92
100
|
servicos = data.get('valoresCoberturasServico')
|
|
101
|
+
caracteristicas = data.get('caracteristicas')
|
|
102
|
+
if isinstance(caracteristicas, dict):
|
|
103
|
+
caracteristicas = {
|
|
104
|
+
str(k): str(v) for k, v in caracteristicas.items() if v is not None and str(v) != ''
|
|
105
|
+
} or None
|
|
106
|
+
else:
|
|
107
|
+
caracteristicas = None
|
|
93
108
|
return cls(
|
|
94
109
|
tipoItem=data.get('tipoItem'),
|
|
95
110
|
numeroContrato=data.get('numeroContrato'),
|
|
@@ -103,10 +118,9 @@ class APIOxxy001DTO:
|
|
|
103
118
|
inicioVigencia=data.get('inicioVigencia'),
|
|
104
119
|
fimVigencia=data.get('fimVigencia'),
|
|
105
120
|
destino=data.get('destino'),
|
|
106
|
-
placa=data.get('placa'),
|
|
107
|
-
chassi=data.get('chassi'),
|
|
108
121
|
valoresCoberturas=[ValoresCobertura.from_dict(i) for i in coberturas] if coberturas else None,
|
|
109
122
|
valoresCoberturasServico=[ValoresCoberturaServico.from_dict(i) for i in servicos] if servicos else None,
|
|
123
|
+
caracteristicas=caracteristicas,
|
|
110
124
|
)
|
|
111
125
|
|
|
112
126
|
@classmethod
|
|
@@ -125,7 +139,8 @@ class APIOxxy001DTO:
|
|
|
125
139
|
numeroSorte: Optional[str] = None,
|
|
126
140
|
valoresCoberturas: Optional[list[ValoresCobertura]] = None,
|
|
127
141
|
valoresCoberturasServico: Optional[list[ValoresCoberturaServico]] = None,
|
|
128
|
-
|
|
142
|
+
caracteristicas: Optional[dict[str, str]] = None,
|
|
143
|
+
) -> APIBvix001DTO:
|
|
129
144
|
return cls(
|
|
130
145
|
tipoItem=TipoItem.VIDA_VIAGEM,
|
|
131
146
|
numeroContrato=numeroContrato,
|
|
@@ -141,14 +156,13 @@ class APIOxxy001DTO:
|
|
|
141
156
|
numeroSorte=numeroSorte,
|
|
142
157
|
valoresCoberturas=valoresCoberturas,
|
|
143
158
|
valoresCoberturasServico=valoresCoberturasServico,
|
|
159
|
+
caracteristicas=caracteristicas,
|
|
144
160
|
)
|
|
145
161
|
|
|
146
162
|
@classmethod
|
|
147
163
|
def for_automovel(
|
|
148
164
|
cls,
|
|
149
165
|
numeroContrato: str,
|
|
150
|
-
placa: Optional[str] = None,
|
|
151
|
-
chassi: Optional[str] = None,
|
|
152
166
|
cpf: Optional[str] = None,
|
|
153
167
|
nome: Optional[str] = None,
|
|
154
168
|
dataNascimento: Optional[str] = None,
|
|
@@ -160,12 +174,11 @@ class APIOxxy001DTO:
|
|
|
160
174
|
numeroSorte: Optional[str] = None,
|
|
161
175
|
valoresCoberturas: Optional[list[ValoresCobertura]] = None,
|
|
162
176
|
valoresCoberturasServico: Optional[list[ValoresCoberturaServico]] = None,
|
|
163
|
-
|
|
177
|
+
caracteristicas: Optional[dict[str, str]] = None,
|
|
178
|
+
) -> APIBvix001DTO:
|
|
164
179
|
return cls(
|
|
165
180
|
tipoItem=TipoItem.AUTOMOVEL,
|
|
166
181
|
numeroContrato=numeroContrato,
|
|
167
|
-
placa=placa,
|
|
168
|
-
chassi=chassi,
|
|
169
182
|
cpf=cpf,
|
|
170
183
|
nome=nome,
|
|
171
184
|
dataNascimento=dataNascimento,
|
|
@@ -177,4 +190,5 @@ class APIOxxy001DTO:
|
|
|
177
190
|
numeroSorte=numeroSorte,
|
|
178
191
|
valoresCoberturas=valoresCoberturas,
|
|
179
192
|
valoresCoberturasServico=valoresCoberturasServico,
|
|
193
|
+
caracteristicas=caracteristicas,
|
|
180
194
|
)
|
|
@@ -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.1}/src/attime/star/api.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|