infovist-python-sdk 1.0.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.
@@ -0,0 +1,5 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Seu Nome
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy...
@@ -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
File without changes
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "infovist-python-sdk"
7
+ version = "1.0.0"
8
+ description = "Client de comunicaçao c/ API da InfoVist"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {file = "LICENSE"}
12
+ authors = [
13
+ {name = "Filipe Coelho", email = "filipe@fmconsult.com.br"},
14
+ ]
15
+ keywords = ["sdk", "api", "infovist"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+
22
+ dependencies = []
23
+
24
+ [project.urls]
25
+ "Homepage" = "https://github.com/seuuser/minha-biblioteca"
26
+ "Bug Tracker" = "https://github.com/seuuser/minha-biblioteca/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
File without changes
@@ -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
@@ -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
@@ -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,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/__init__.py
5
+ src/infocar/__init__.py
6
+ src/infocar/infovist/__init__.py
7
+ src/infocar/infovist/api.py
8
+ src/infocar/infovist/apis/__init__.py
9
+ src/infocar/infovist/apis/vistoria.py
10
+ src/infocar/infovist/dtos/__init__.py
11
+ src/infocar/infovist/dtos/vistoria.py
12
+ src/infovist_python_sdk.egg-info/PKG-INFO
13
+ src/infovist_python_sdk.egg-info/SOURCES.txt
14
+ src/infovist_python_sdk.egg-info/dependency_links.txt
15
+ src/infovist_python_sdk.egg-info/top_level.txt