hyundai-kia-connect-api 3.42.4__tar.gz → 3.42.11__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 (49) hide show
  1. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/PKG-INFO +2 -3
  2. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/README.rst +1 -2
  3. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/ApiImplType1.py +15 -2
  4. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/KiaUvoApiCA.py +1 -3
  5. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/KiaUvoApiEU.py +5 -4
  6. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api.egg-info/PKG-INFO +2 -3
  7. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/requirements.txt +1 -1
  8. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/setup.py +1 -1
  9. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/AUTHORS.rst +0 -0
  10. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/CONTRIBUTING.rst +0 -0
  11. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/HISTORY.rst +0 -0
  12. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/LICENSE +0 -0
  13. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/MANIFEST.in +0 -0
  14. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/Makefile +0 -0
  15. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/authors.rst +0 -0
  16. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/conf.py +0 -0
  17. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/contributing.rst +0 -0
  18. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/history.rst +0 -0
  19. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/index.rst +0 -0
  20. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/installation.rst +0 -0
  21. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/make.bat +0 -0
  22. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/readme.rst +0 -0
  23. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/docs/usage.rst +0 -0
  24. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/ApiImpl.py +0 -0
  25. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py +0 -0
  26. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/KiaUvoApiAU.py +0 -0
  27. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/KiaUvoApiCN.py +0 -0
  28. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/KiaUvoApiIN.py +0 -0
  29. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/KiaUvoApiUSA.py +0 -0
  30. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/Token.py +0 -0
  31. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/Vehicle.py +0 -0
  32. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/VehicleManager.py +0 -0
  33. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/__init__.py +0 -0
  34. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/bluelink.py +0 -0
  35. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/const.py +0 -0
  36. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/exceptions.py +0 -0
  37. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api/utils.py +0 -0
  38. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api.egg-info/SOURCES.txt +0 -0
  39. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api.egg-info/dependency_links.txt +0 -0
  40. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api.egg-info/entry_points.txt +0 -0
  41. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api.egg-info/not-zip-safe +0 -0
  42. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api.egg-info/requires.txt +0 -0
  43. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/hyundai_kia_connect_api.egg-info/top_level.txt +0 -0
  44. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/setup.cfg +0 -0
  45. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/tests/__init__.py +0 -0
  46. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/tests/au_login_test.py +0 -0
  47. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/tests/ca_login_test.py +0 -0
  48. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/tests/eu_check_response_for_errors_test.py +0 -0
  49. {hyundai_kia_connect_api-3.42.4 → hyundai_kia_connect_api-3.42.11}/tests/eu_login_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.42.4
3
+ Version: 3.42.11
4
4
  Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
5
5
  Home-page: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api
6
6
  Author: Fuat Akgun
@@ -37,7 +37,7 @@ Dynamic: summary
37
37
  Code Maintainers Wanted
38
38
  =======================
39
39
 
40
- I no longer have a Kia or Hyundai so don't maintain this like I used to. Others who are interested in jumping in are welcome to join the project! Even just pull requests are appreciated!
40
+ I no longer have a Kia or Hyundai so don't maintain this like I used to. Others who are interested in jumping in are welcome to join the project! Even just pull requests are appreciated!
41
41
 
42
42
  Introduction
43
43
  ============
@@ -158,7 +158,6 @@ Example of getting trip info of the current month and day (vm is VehicleManager
158
158
  for trip in reversed(vehicle.day_trip_info.trip_list): # show oldest first
159
159
  print(f"{day.yyyymmdd},{trip.hhmmss},{trip.drive_time},{trip.idle_time},{trip.distance},{trip.avg_speed},{trip.max_speed}")
160
160
 
161
-
162
161
  CLI Usage
163
162
  =========
164
163
 
@@ -1,7 +1,7 @@
1
1
  Code Maintainers Wanted
2
2
  =======================
3
3
 
4
- I no longer have a Kia or Hyundai so don't maintain this like I used to. Others who are interested in jumping in are welcome to join the project! Even just pull requests are appreciated!
4
+ I no longer have a Kia or Hyundai so don't maintain this like I used to. Others who are interested in jumping in are welcome to join the project! Even just pull requests are appreciated!
5
5
 
6
6
  Introduction
7
7
  ============
@@ -122,7 +122,6 @@ Example of getting trip info of the current month and day (vm is VehicleManager
122
122
  for trip in reversed(vehicle.day_trip_info.trip_list): # show oldest first
123
123
  print(f"{day.yyyymmdd},{trip.hhmmss},{trip.drive_time},{trip.idle_time},{trip.distance},{trip.avg_speed},{trip.max_speed}")
124
124
 
125
-
126
125
  CLI Usage
127
126
  =========
128
127
 
@@ -34,6 +34,7 @@ from .const import (
34
34
 
35
35
  from .exceptions import (
36
36
  APIError,
37
+ AuthenticationError,
37
38
  DuplicateRequestError,
38
39
  RequestTimeoutError,
39
40
  ServiceTemporaryUnavailable,
@@ -79,16 +80,28 @@ def _check_response_for_errors(response: dict) -> None:
79
80
  "9999": RequestTimeoutError,
80
81
  }
81
82
 
82
- if not any(x in response for x in ["retCode", "resCode", "resMsg"]):
83
+ error_message_to_exception_mapping = {
84
+ "Key not authorized: Token is expired": AuthenticationError
85
+ }
86
+
87
+ if not any(x in response for x in ["retCode", "resCode", "resMsg", "error"]):
83
88
  _LOGGER.error(f"Unknown API response format: {response}")
84
89
  raise InvalidAPIResponseError()
85
90
 
86
- if response["retCode"] == "F":
91
+ if "retCode" in response and response["retCode"] == "F":
87
92
  if response["resCode"] in error_code_mapping:
88
93
  raise error_code_mapping[response["resCode"]](response["resMsg"])
89
94
  raise APIError(
90
95
  f"Server returned: '{response['resCode']}' '{response['resMsg']}'"
91
96
  )
97
+ elif "error" in response:
98
+ error_reason = response["error"]
99
+ if error_reason in error_message_to_exception_mapping:
100
+ _LOGGER.error(f"API error: {error_reason}")
101
+ raise error_message_to_exception_mapping[error_reason](error_reason)
102
+ else:
103
+ _LOGGER.error(f"Unknown error in API response: {error_reason}")
104
+ raise APIError(f"Unknown error in API response: {error_reason}")
92
105
 
93
106
 
94
107
  class ApiImplType1(ApiImpl):
@@ -80,9 +80,7 @@ class KiaUvoApiCA(ApiImpl):
80
80
  @property
81
81
  def sessions(self):
82
82
  if not self._sessions:
83
- self._sessions = cloudscraper.create_scraper(
84
- browser={"custom": "okhttp/4.12.0"}
85
- )
83
+ self._sessions = cloudscraper.create_scraper()
86
84
  return self._sessions
87
85
 
88
86
  def _check_response_for_errors(self, response: dict) -> None:
@@ -36,7 +36,6 @@ from .const import (
36
36
  DISTANCE_UNITS,
37
37
  DOMAIN,
38
38
  ENGINE_TYPES,
39
- LOGIN_TOKEN_LIFETIME,
40
39
  SEAT_STATUS,
41
40
  TEMPERATURE_UNITS,
42
41
  VALET_MODE_ACTION,
@@ -193,11 +192,12 @@ class KiaUvoApiEU(ApiImplType1):
193
192
  if authorization_code is None:
194
193
  raise AuthenticationError("Login Failed")
195
194
 
196
- _, access_token, authorization_code = self._get_access_token(
195
+ _, access_token, authorization_code, expires_in = self._get_access_token(
197
196
  stamp, authorization_code
198
197
  )
198
+ valid_until = dt.datetime.now(pytz.utc) + dt.timedelta(seconds=expires_in)
199
+
199
200
  _, refresh_token = self._get_refresh_token(stamp, authorization_code)
200
- valid_until = dt.datetime.now(pytz.utc) + LOGIN_TOKEN_LIFETIME
201
201
 
202
202
  return Token(
203
203
  username=username,
@@ -1226,7 +1226,8 @@ class KiaUvoApiEU(ApiImplType1):
1226
1226
  token_type = response["token_type"]
1227
1227
  access_token = token_type + " " + response["access_token"]
1228
1228
  authorization_code = response["refresh_token"]
1229
- return token_type, access_token, authorization_code
1229
+ expires_in = response["expires_in"]
1230
+ return token_type, access_token, authorization_code, expires_in
1230
1231
 
1231
1232
  def _get_refresh_token(self, stamp, authorization_code):
1232
1233
  # Get Refresh Token #
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyundai_kia_connect_api
3
- Version: 3.42.4
3
+ Version: 3.42.11
4
4
  Summary: Python Boilerplate contains all the boilerplate you need to create a Python package.
5
5
  Home-page: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api
6
6
  Author: Fuat Akgun
@@ -37,7 +37,7 @@ Dynamic: summary
37
37
  Code Maintainers Wanted
38
38
  =======================
39
39
 
40
- I no longer have a Kia or Hyundai so don't maintain this like I used to. Others who are interested in jumping in are welcome to join the project! Even just pull requests are appreciated!
40
+ I no longer have a Kia or Hyundai so don't maintain this like I used to. Others who are interested in jumping in are welcome to join the project! Even just pull requests are appreciated!
41
41
 
42
42
  Introduction
43
43
  ============
@@ -158,7 +158,6 @@ Example of getting trip info of the current month and day (vm is VehicleManager
158
158
  for trip in reversed(vehicle.day_trip_info.trip_list): # show oldest first
159
159
  print(f"{day.yyyymmdd},{trip.hhmmss},{trip.drive_time},{trip.idle_time},{trip.distance},{trip.avg_speed},{trip.max_speed}")
160
160
 
161
-
162
161
  CLI Usage
163
162
  =========
164
163
 
@@ -4,4 +4,4 @@ python-dateutil
4
4
  pytz>=2021.3
5
5
  certifi>=2024.6.2
6
6
  geopy >= 2.2.0
7
- cloudscraper>=1.2.60
7
+ cloudscraper >= 1.2.60
@@ -47,6 +47,6 @@ setup(
47
47
  test_suite="tests",
48
48
  tests_require=test_requirements,
49
49
  url="https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api",
50
- version="3.42.4",
50
+ version="3.42.11",
51
51
  zip_safe=False,
52
52
  )