getrak-python-sdk 1.1.0__tar.gz → 1.2.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.
Files changed (21) hide show
  1. {getrak_python_sdk-1.1.0/src/getrak_python_sdk.egg-info → getrak_python_sdk-1.2.0}/PKG-INFO +1 -1
  2. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/pyproject.toml +1 -1
  3. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/apis/recebidos.py +5 -1
  4. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/errors.py +4 -0
  5. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0/src/getrak_python_sdk.egg-info}/PKG-INFO +1 -1
  6. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/tests/test_client.py +23 -1
  7. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/LICENSE +0 -0
  8. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/README.md +0 -0
  9. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/setup.cfg +0 -0
  10. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/__init__.py +0 -0
  11. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/api.py +0 -0
  12. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/apis/__init__.py +0 -0
  13. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/apis/localizacoes.py +0 -0
  14. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/__init__.py +0 -0
  15. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/models/__init__.py +0 -0
  16. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/models/dataexplained.py +0 -0
  17. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak/database/models/vehicle.py +0 -0
  18. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/SOURCES.txt +0 -0
  19. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/dependency_links.txt +0 -0
  20. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/requires.txt +0 -0
  21. {getrak_python_sdk-1.1.0 → getrak_python_sdk-1.2.0}/src/getrak_python_sdk.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: getrak-python-sdk
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Client de comunicaçao c/ API da Getrak
5
5
  Author-email: Filipe Coelho <filipe@fmconsult.com.br>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "getrak-python-sdk"
7
- version = "1.1.0"
7
+ version = "1.2.0"
8
8
  description = "Client de comunicaçao c/ API da Getrak"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -6,7 +6,7 @@ import jsonpickle
6
6
  from http import HTTPMethod
7
7
  from fmconsult.utils.url import UrlUtil
8
8
  from getrak.api import GetrakApi
9
- from getrak.errors import GetrakError, InvalidVehicleId
9
+ from getrak.errors import GetrakError, InvalidVehicleId, VehicleNotFound
10
10
 
11
11
  VEHICLE_ID_RE = re.compile(r"^[A-Za-z0-9_-]+$")
12
12
 
@@ -34,6 +34,10 @@ class Recebidos(GetrakApi):
34
34
  body = json.loads(raw)
35
35
  except ValueError:
36
36
  raise GetrakError("resposta de recebidos não é JSON") from None
37
+ if isinstance(body, dict):
38
+ message = body.get("error") if isinstance(body.get("error"), str) else ""
39
+ if "não encontrado" in message.casefold():
40
+ raise VehicleNotFound(message)
37
41
  if not isinstance(body, list):
38
42
  raise GetrakError("resposta de recebidos não é uma lista")
39
43
  if not all(isinstance(item, dict) for item in body):
@@ -6,5 +6,9 @@ class InvalidVehicleId(GetrakError):
6
6
  pass
7
7
 
8
8
 
9
+ class VehicleNotFound(GetrakError):
10
+ """A conta não tem esse veículo. Não há lista de posições para gravar."""
11
+
12
+
9
13
  class AuthenticationFailed(GetrakError):
10
14
  """A Getrak recusou as credenciais. Vale para as chamadas seguintes desta instância."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: getrak-python-sdk
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Client de comunicaçao c/ API da Getrak
5
5
  Author-email: Filipe Coelho <filipe@fmconsult.com.br>
6
6
  License: MIT License
@@ -6,7 +6,7 @@ import responses
6
6
  from responses import registries
7
7
 
8
8
  from getrak.apis.recebidos import Recebidos
9
- from getrak.errors import AuthenticationFailed, GetrakError, InvalidVehicleId
9
+ from getrak.errors import AuthenticationFailed, GetrakError, InvalidVehicleId, VehicleNotFound
10
10
 
11
11
  BASE = "https://api.getrak.com"
12
12
  AUTH = f"{BASE}/newkoauth/oauth/token"
@@ -114,3 +114,25 @@ def test_non_list_is_an_error():
114
114
  )
115
115
  with pytest.raises(GetrakError):
116
116
  client.fetch("12345", "2026-10-04T03:00:00", "2026-10-05T02:59:59")
117
+
118
+
119
+ def test_unknown_vehicle_is_a_specific_error():
120
+ with responses.RequestsMock() as http:
121
+ http.add(responses.POST, AUTH, json={"access_token": "tok"}, status=200)
122
+ http.add(
123
+ responses.GET,
124
+ POS,
125
+ json={"error": "Veículo não encontrado para o cliente informado", "status": 404},
126
+ status=200,
127
+ )
128
+ client = Recebidos(
129
+ auth_code=AUTH_CODE,
130
+ login="usuario",
131
+ password=PASSWORD,
132
+ grant_type="password",
133
+ authenticate_on_init=False,
134
+ verbose=False,
135
+ log_requests=False,
136
+ )
137
+ with pytest.raises(VehicleNotFound):
138
+ client.fetch("12345", "2026-10-04T03:00:00", "2026-10-05T02:59:59")