python-chargepoint 2.3.1__py3-none-any.whl → 2.4.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.
@@ -13,7 +13,6 @@ from .constants import _LOGGER
13
13
  from .exceptions import CommunicationError, InvalidSession, LoginError
14
14
  from .types import MapFilter, ZoomBounds
15
15
 
16
-
17
16
  # ---------------------------------------------------------------------------
18
17
  # Helpers
19
18
  # ---------------------------------------------------------------------------
@@ -41,6 +41,7 @@ USER_AGENT = f"{MODULE_NAME}/{MODULE_VERSION}"
41
41
  COULOMB_SESSION = "coulomb_sess"
42
42
  SSO_SESSION = "auth-session"
43
43
  COOKIE_DOMAIN = ".chargepoint.com"
44
+ _COULOMB_SESSION_MAX_AGE = 10 * 365 * 24 * 3600
44
45
 
45
46
 
46
47
  def _require_login(func):
@@ -60,11 +61,13 @@ class ChargePoint:
60
61
  username: str,
61
62
  coulomb_token: str = "",
62
63
  session: Optional[aiohttp.ClientSession] = None,
64
+ user_agent: Optional[str] = None,
63
65
  ):
64
66
  self._username = username
65
67
  self._user_id: Optional[int] = None
66
68
  self._global_config: GlobalConfiguration
67
- self._request_headers = {"user-agent": USER_AGENT}
69
+ self._user_agent = user_agent or USER_AGENT
70
+ self._request_headers = {"user-agent": self._user_agent}
68
71
  self._owns_session = session is None
69
72
 
70
73
  if session is not None:
@@ -81,8 +84,9 @@ class ChargePoint:
81
84
  username: str,
82
85
  coulomb_token: str = "",
83
86
  session: Optional[aiohttp.ClientSession] = None,
87
+ user_agent: Optional[str] = None,
84
88
  ) -> ChargePoint:
85
- client = cls(username, coulomb_token, session)
89
+ client = cls(username, coulomb_token, session, user_agent)
86
90
  client._global_config = await client._get_configuration(username)
87
91
  if coulomb_token:
88
92
  await client._init_account_parameters()
@@ -115,6 +119,7 @@ class ChargePoint:
115
119
  cookie[COULOMB_SESSION] = parsed
116
120
  cookie[COULOMB_SESSION]["domain"] = COOKIE_DOMAIN
117
121
  cookie[COULOMB_SESSION]["path"] = "/"
122
+ cookie[COULOMB_SESSION]["max-age"] = str(_COULOMB_SESSION_MAX_AGE)
118
123
  self._session.cookie_jar.update_cookies(
119
124
  cookie, response_url=URL(f"https://account{COOKIE_DOMAIN}/")
120
125
  )
@@ -202,7 +207,9 @@ class ChargePoint:
202
207
  _LOGGER.debug(
203
208
  "Attempting client login (%s) with user: %s", login_url, self._username
204
209
  )
205
- async with self._session.post(login_url, json=request) as login:
210
+ async with self._session.post(
211
+ login_url, json=request, headers={"user-agent": self._user_agent}
212
+ ) as login:
206
213
  cookie_morsel = login.cookies.get(COULOMB_SESSION)
207
214
  if login.status == 200 and cookie_morsel:
208
215
  self._set_coulomb_token(cookie_morsel.value)
@@ -234,7 +241,11 @@ class ChargePoint:
234
241
  self._global_config.endpoints.portal_domain_endpoint
235
242
  / "index.php/nghelper/getSession"
236
243
  )
237
- async with self._session.get(url, cookies={SSO_SESSION: sso_jwt}) as response:
244
+ async with self._session.get(
245
+ url,
246
+ cookies={SSO_SESSION: sso_jwt},
247
+ headers={"user-agent": self._user_agent},
248
+ ) as response:
238
249
  cookie_morsel = response.cookies.get(COULOMB_SESSION)
239
250
  if response.status == 200 and cookie_morsel:
240
251
  self._set_coulomb_token(cookie_morsel.value)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-chargepoint
3
- Version: 2.3.1
3
+ Version: 2.4.0
4
4
  Summary: A simple, Pythonic wrapper for the ChargePoint API.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
17
18
  Requires-Dist: aiohttp (>=3.9,<4.0)
18
19
  Requires-Dist: click (>=8.1,<9.0)
19
20
  Requires-Dist: pydantic (>=2.12,<3.0)
@@ -1,13 +1,13 @@
1
1
  python_chargepoint/__init__.py,sha256=feCQnVAAkCZr5iz9BWOl6YrwcKmcEnpH598Js0w-hxk,46
2
- python_chargepoint/__main__.py,sha256=GRyJ8N9-lJ8BtKu2631guQjCexUBWPVnRNxT38hbPKo,25642
3
- python_chargepoint/client.py,sha256=89yoXFPp_YjFRF08AGplllhVeofLlzZnoJiTXo0PnDM,19967
2
+ python_chargepoint/__main__.py,sha256=ESNHXnAVYtaLPYvDnv4sAe9Ef2e2MiyPvavfrNwlFtE,25641
3
+ python_chargepoint/client.py,sha256=OEUMNsO3e1D_jjY40HvuU1KhqC4w8V3W-PfDVFjKv7Y,20401
4
4
  python_chargepoint/constants.py,sha256=mu_-syPG4BGtFbhuIjWYqGMmwyxvPoz9g9WP7UmCMT4,172
5
5
  python_chargepoint/exceptions.py,sha256=b1UwI6NdpCNWjlbB_5onh0bgVP0xz8587hpPPOt0l7Y,1030
6
6
  python_chargepoint/global_config.py,sha256=8ysnnz5iQNMsuxgd_P8fkO-1pHP2kLcFoKvFJ7EeYR0,2532
7
7
  python_chargepoint/session.py,sha256=OqC39dhGxW7YZgDMQYRNHY-3E_5zOEQwQNXAixh4dmQ,9321
8
8
  python_chargepoint/types.py,sha256=W_WsF6pTgH9L8GDWHeJZRn-MAbFf-LTmpZzClx_AttE,13258
9
- python_chargepoint-2.3.1.dist-info/METADATA,sha256=aiecv7TT7xVCoT3XpfTNJFj_557Tndr0bDD4onRFy-8,11423
10
- python_chargepoint-2.3.1.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
11
- python_chargepoint-2.3.1.dist-info/entry_points.txt,sha256=OxFvfpoOLgWQvG2FWRgL_HwBmQXRmYxAJ0OUiFI3Fw0,63
12
- python_chargepoint-2.3.1.dist-info/licenses/LICENSE,sha256=GoS0DqJF8iBnSxm3URezwTm7rsUxhBv1-odhHhLlg8I,1054
13
- python_chargepoint-2.3.1.dist-info/RECORD,,
9
+ python_chargepoint-2.4.0.dist-info/METADATA,sha256=IfdxqCL3CgGWwNqH2QhstfvxXRzIGYNjowbei9EKFok,11474
10
+ python_chargepoint-2.4.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
11
+ python_chargepoint-2.4.0.dist-info/entry_points.txt,sha256=OxFvfpoOLgWQvG2FWRgL_HwBmQXRmYxAJ0OUiFI3Fw0,63
12
+ python_chargepoint-2.4.0.dist-info/licenses/LICENSE,sha256=GoS0DqJF8iBnSxm3URezwTm7rsUxhBv1-odhHhLlg8I,1054
13
+ python_chargepoint-2.4.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.3.1
2
+ Generator: poetry-core 2.5.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any