infovist-python-sdk 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.
- __init__.py +0 -0
- infocar/__init__.py +0 -0
- infocar/infovist/__init__.py +0 -0
- infocar/infovist/api.py +45 -0
- infocar/infovist/apis/__init__.py +0 -0
- infocar/infovist/apis/vistoria.py +71 -0
- infocar/infovist/dtos/__init__.py +0 -0
- infocar/infovist/dtos/vistoria.py +35 -0
- infovist_python_sdk-1.0.0.dist-info/METADATA +21 -0
- infovist_python_sdk-1.0.0.dist-info/RECORD +13 -0
- infovist_python_sdk-1.0.0.dist-info/WHEEL +5 -0
- infovist_python_sdk-1.0.0.dist-info/licenses/LICENSE +5 -0
- infovist_python_sdk-1.0.0.dist-info/top_level.txt +2 -0
__init__.py
ADDED
|
File without changes
|
infocar/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
infocar/infovist/api.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import os, jsonpickle
|
|
2
|
+
from http import HTTPMethod
|
|
3
|
+
|
|
4
|
+
from fmconsult.http.api import ApiBase
|
|
5
|
+
from fmconsult.utils.url import UrlUtil
|
|
6
|
+
|
|
7
|
+
class InfoVistApi(ApiBase):
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
try:
|
|
11
|
+
self.api_environment = os.environ['attime.star.api.environment']
|
|
12
|
+
self.api_email = os.environ['attime.star.api.email']
|
|
13
|
+
self.api_password = os.environ['attime.star.api.password']
|
|
14
|
+
self.api_token = os.environ['attime.star.api.token']
|
|
15
|
+
|
|
16
|
+
api_sandbox_base_url = 'https://api.infovist.com.br/api/v1'
|
|
17
|
+
api_live_base_url = 'https://api.infovist.com.br/api/v1'
|
|
18
|
+
|
|
19
|
+
get_base_url = lambda env: api_live_base_url if env == 'live' else api_sandbox_base_url
|
|
20
|
+
|
|
21
|
+
self.base_url = get_base_url(self.api_environment)
|
|
22
|
+
|
|
23
|
+
self.__login()
|
|
24
|
+
except:
|
|
25
|
+
raise
|
|
26
|
+
def __login(self):
|
|
27
|
+
try:
|
|
28
|
+
res = self.call_request(
|
|
29
|
+
http_method = HTTPMethod.POST,
|
|
30
|
+
request_url = UrlUtil().make_url(self.base_url, ['auth','login']),
|
|
31
|
+
payload = {
|
|
32
|
+
'email': self.api_email,
|
|
33
|
+
'password': self.api_password,
|
|
34
|
+
'token': self.api_token
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
res = jsonpickle.decode(res)
|
|
38
|
+
if not('errors' in res):
|
|
39
|
+
self.token_type = res['data']['token_type']
|
|
40
|
+
self.access_token = res['data']['access_token']
|
|
41
|
+
self.headers['Authorization'] = f'{self.token_type} {self.access_token}'
|
|
42
|
+
else:
|
|
43
|
+
raise Exception(res['mensagem'])
|
|
44
|
+
except:
|
|
45
|
+
raise
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import logging, jsonpickle
|
|
2
|
+
from http import HTTPMethod
|
|
3
|
+
|
|
4
|
+
from fmconsult.utils.url import UrlUtil
|
|
5
|
+
from infocar.infovist.api import InfoVistApi
|
|
6
|
+
from infocar.infovist.dtos.vistoria import Vistoria, SearchCategory
|
|
7
|
+
|
|
8
|
+
class VistoriaApi(InfoVistApi):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
super().__init__()
|
|
11
|
+
self.endpoint_url = UrlUtil().make_url(self.base_url, ['inspection'])
|
|
12
|
+
|
|
13
|
+
def create(self, data:Vistoria):
|
|
14
|
+
logging.info(f'generating vistoria...')
|
|
15
|
+
try:
|
|
16
|
+
res = self.call_request(HTTPMethod.POST, self.endpoint_url, None, payload=data.to_dict())
|
|
17
|
+
res = jsonpickle.decode(res)
|
|
18
|
+
|
|
19
|
+
item = Vistoria(**res['data'])
|
|
20
|
+
|
|
21
|
+
return item
|
|
22
|
+
except:
|
|
23
|
+
raise
|
|
24
|
+
|
|
25
|
+
def get_by_protocol(self, protocol: str):
|
|
26
|
+
logging.info(f'getting vistoria by protocol numer...')
|
|
27
|
+
try:
|
|
28
|
+
endpoint_url = UrlUtil().make_url(self.endpoint_url, [protocol])
|
|
29
|
+
res = self.call_request(
|
|
30
|
+
http_method = HTTPMethod.GET,
|
|
31
|
+
request_url = endpoint_url
|
|
32
|
+
)
|
|
33
|
+
res = jsonpickle.decode(res)
|
|
34
|
+
|
|
35
|
+
if 'data' not in res:
|
|
36
|
+
raise Exception(res.get('message', 'Erro desconhecido'))
|
|
37
|
+
|
|
38
|
+
item = Vistoria(**res['data'])
|
|
39
|
+
|
|
40
|
+
return item
|
|
41
|
+
except:
|
|
42
|
+
raise
|
|
43
|
+
|
|
44
|
+
def get_all(self, page: int, limit: int, search: str=None, category: SearchCategory=None):
|
|
45
|
+
logging.info(f'getting vistorias list...')
|
|
46
|
+
try:
|
|
47
|
+
req_params = {
|
|
48
|
+
'page': page,
|
|
49
|
+
'limit': limit
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (search and category):
|
|
53
|
+
req_params['search'] = search
|
|
54
|
+
req_params['category'] = category.value
|
|
55
|
+
|
|
56
|
+
res = self.call_request(
|
|
57
|
+
http_method = HTTPMethod.GET,
|
|
58
|
+
request_url = self.endpoint_url,
|
|
59
|
+
params = req_params
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
res = jsonpickle.decode(res)
|
|
63
|
+
|
|
64
|
+
if 'data' not in res:
|
|
65
|
+
raise Exception(res.get('message', 'Erro desconhecido'))
|
|
66
|
+
|
|
67
|
+
items = [Vistoria(**item) for item in res['data']]
|
|
68
|
+
|
|
69
|
+
return items
|
|
70
|
+
except:
|
|
71
|
+
raise
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from dataclasses import dataclass, asdict
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from fmconsult.utils.enum import CustomEnum
|
|
5
|
+
from fmconsult.utils.object import CustomObject
|
|
6
|
+
|
|
7
|
+
class SearchCategory(CustomEnum):
|
|
8
|
+
PLATE = "Placa"
|
|
9
|
+
CHASSI = "Chassi"
|
|
10
|
+
CUSTOMER = "Cliente"
|
|
11
|
+
PROTOCOL = "Protocolo"
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class Status(CustomObject):
|
|
15
|
+
value: str
|
|
16
|
+
status_enum: str
|
|
17
|
+
created_at: str
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class Vistoria(CustomObject):
|
|
21
|
+
protocol: str
|
|
22
|
+
customer: str
|
|
23
|
+
plate: str
|
|
24
|
+
chassis: str
|
|
25
|
+
cellphone: Optional[str]
|
|
26
|
+
normal_plate: Optional[str]
|
|
27
|
+
mercosur_plate: Optional[str]
|
|
28
|
+
status: Optional[str]
|
|
29
|
+
status_enum: Optional[str]
|
|
30
|
+
notes: Optional[str]
|
|
31
|
+
statuses: Optional[List[Status]]
|
|
32
|
+
|
|
33
|
+
def to_dict(self):
|
|
34
|
+
data = asdict(self)
|
|
35
|
+
return data
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: infovist-python-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Client de comunicaçao c/ API da InfoVist
|
|
5
|
+
Author-email: Filipe Coelho <filipe@fmconsult.com.br>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Seu Nome
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy...
|
|
11
|
+
|
|
12
|
+
Project-URL: Homepage, https://github.com/seuuser/minha-biblioteca
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/seuuser/minha-biblioteca/issues
|
|
14
|
+
Keywords: sdk,api,infovist
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
infocar/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
infocar/infovist/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
infocar/infovist/api.py,sha256=4tDpVppznI9x-8yiIj-8uAvx8s__SfqbtHfqAVVu6mU,1431
|
|
5
|
+
infocar/infovist/apis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
infocar/infovist/apis/vistoria.py,sha256=2YyEB4nZhRJaIbXH2inZ2EkvgJteL3pRFsaNj0OZtWM,1761
|
|
7
|
+
infocar/infovist/dtos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
infocar/infovist/dtos/vistoria.py,sha256=TmYhQ-dDApFdPn0SbZ1Gku7xW0sb71Y1LU35OrrLnW4,789
|
|
9
|
+
infovist_python_sdk-1.0.0.dist-info/licenses/LICENSE,sha256=YZjQnFjzXGFa0D3iCQkNDwGBNuTGJREkRmItGX1B3YM,122
|
|
10
|
+
infovist_python_sdk-1.0.0.dist-info/METADATA,sha256=Y7E8oeN-NEtB_ZfEvrkT2_ITaWO7heyu07j1qVpCjME,765
|
|
11
|
+
infovist_python_sdk-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
12
|
+
infovist_python_sdk-1.0.0.dist-info/top_level.txt,sha256=AlISs1cuX0yLjU5oJXUIUSs0SUOA1StZDaxjNxfEPNM,17
|
|
13
|
+
infovist_python_sdk-1.0.0.dist-info/RECORD,,
|