hyundai-kia-connect-api 3.42.4__py2.py3-none-any.whl → 3.42.11__py2.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.
@@ -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
 
@@ -1,10 +1,10 @@
1
1
  hyundai_kia_connect_api/ApiImpl.py,sha256=UeG2FH4KCdU5LvGp5Ks793vrWbwBx8MN_DedbVRRouM,9612
2
- hyundai_kia_connect_api/ApiImplType1.py,sha256=9o0Ioxwah_trqe99c5H2oNS5WfRLLhCTGMeItB857fk,38605
2
+ hyundai_kia_connect_api/ApiImplType1.py,sha256=aNVNnTzYOgahN-MCnJ0-bNKfHj_dZzJijUCkvA_51L8,39221
3
3
  hyundai_kia_connect_api/HyundaiBlueLinkApiUSA.py,sha256=8S57iex0zecJOqKPg9xA6pGMVvGlybn9vcxLIAxbycY,37209
4
4
  hyundai_kia_connect_api/KiaUvoApiAU.py,sha256=433Db-rp3drhyY8ZvN-GiVP85pl90Wwu4A2uAdkYH1c,36100
5
- hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=OvnyBdwkj9fFYGp2dqNSXVO8W6b7bhPcEg7zbKOSzF0,34584
5
+ hyundai_kia_connect_api/KiaUvoApiCA.py,sha256=IkpxawiPHQBJyCZGGwEtQm3nEQ9EsjPAOfPPSaeZWms,34519
6
6
  hyundai_kia_connect_api/KiaUvoApiCN.py,sha256=WP-rRI3wZmjuLYZmPXeOSk2NNNc6UhTrpOMuYMG6-iE,47043
7
- hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=E9-teu7OVjLu-hGT3B8aGBfrKDTwFmei7uLt09LJZtE,50285
7
+ hyundai_kia_connect_api/KiaUvoApiEU.py,sha256=-4QWgGFRVTYddd2wXm2gZDBQ0wnpueEAfHdFELz9pas,50340
8
8
  hyundai_kia_connect_api/KiaUvoApiIN.py,sha256=82DBrXoREUrmYsK165QHg5brSDclLQTdm9OaruQIjss,36960
9
9
  hyundai_kia_connect_api/KiaUvoApiUSA.py,sha256=XLi63R7OWXh8_VEbK8Kpn75p2XTgjroR3mpnSlsAqqI,31416
10
10
  hyundai_kia_connect_api/Token.py,sha256=ZsPvXh1ID7FUTGHAqhZUZyrKT7xVbOtIn6FRJn4Ygf0,370
@@ -15,10 +15,10 @@ hyundai_kia_connect_api/bluelink.py,sha256=JiNIHl-Qi8zwqyN6ywKg5CdXOLT74WkvpjVcn
15
15
  hyundai_kia_connect_api/const.py,sha256=ImISRt4QarbN8BOBlDGYRB3F69NKCcGu8ddFvNPhhXU,2370
16
16
  hyundai_kia_connect_api/exceptions.py,sha256=0dwKEPXN8KQVTeueDj2fL3E-TQMU7LjTEJbhcq8Mjx8,1467
17
17
  hyundai_kia_connect_api/utils.py,sha256=k-zSgLdMMLu_h4GJNDRtjbfgZyla_Qhd13pDrtUAu4M,2700
18
- hyundai_kia_connect_api-3.42.4.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
19
- hyundai_kia_connect_api-3.42.4.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
20
- hyundai_kia_connect_api-3.42.4.dist-info/METADATA,sha256=diqhgQpbWBSbRCULh9khznfUi5-PsD1F49Q2J06xDDM,7193
21
- hyundai_kia_connect_api-3.42.4.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
22
- hyundai_kia_connect_api-3.42.4.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
23
- hyundai_kia_connect_api-3.42.4.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
24
- hyundai_kia_connect_api-3.42.4.dist-info/RECORD,,
18
+ hyundai_kia_connect_api-3.42.11.dist-info/licenses/AUTHORS.rst,sha256=T77OE1hrQF6YyDE6NbdMKyL66inHt7dnjHAzblwuk2A,155
19
+ hyundai_kia_connect_api-3.42.11.dist-info/licenses/LICENSE,sha256=49hmc755oyMwKdZ-2epiorjStRB0PfcZR1w5_NXZPgs,1068
20
+ hyundai_kia_connect_api-3.42.11.dist-info/METADATA,sha256=3_OPxvVAshnAmZjfHOa8_cgnctX43IS9fZ1MwHT5CUs,7191
21
+ hyundai_kia_connect_api-3.42.11.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
22
+ hyundai_kia_connect_api-3.42.11.dist-info/entry_points.txt,sha256=XfrroRdyC_9q9VXjEZe5SdRPhkQyCCE4S7ZK6XSKelA,67
23
+ hyundai_kia_connect_api-3.42.11.dist-info/top_level.txt,sha256=otZ7J_fN-s3EW4jD-kAearIo2OIzhQLR8DNEHIaFfds,24
24
+ hyundai_kia_connect_api-3.42.11.dist-info/RECORD,,