pysmarlaapi 0.7.1__tar.gz → 0.7.2__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.

Potentially problematic release.


This version of pysmarlaapi might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pysmarlaapi
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: Swing2Sleep Smarla API
5
5
  Author-email: Robin Lintermann <robin.lintermann@explicatis.com>
6
6
  Requires-Python: >=3.11
@@ -1,4 +1,4 @@
1
- __version__ = "0.7.1"
1
+ __version__ = "0.7.2"
2
2
 
3
3
  from .classes import Connection
4
4
  from .federwiege import Federwiege
@@ -27,22 +27,26 @@ class Connection:
27
27
  async def refresh_token(self) -> bool:
28
28
  try:
29
29
  async with aiohttp.ClientSession(self.url) as session:
30
- response = await session.post(
31
- "/api/AppParing/getToken",
32
- headers={"accept": "*/*", "Content-Type": "application/json"},
33
- data=jsonpickle.encode(self.token, unpicklable=False),
34
- )
30
+ content = await self._get_token(session)
35
31
  except (aiohttp.ClientError, asyncio.TimeoutError):
36
32
  return False
37
33
 
38
- if response.status != 200:
34
+ if not content:
39
35
  return False
40
36
 
41
- content = await response.json()
42
-
43
37
  try:
44
38
  self.token = AuthToken.from_json(content)
45
39
  except ValueError:
46
40
  return False
47
41
 
48
42
  return True
43
+
44
+ async def _get_token(self, session: aiohttp.ClientSession):
45
+ async with await session.post(
46
+ "/api/AppParing/getToken",
47
+ headers={"accept": "*/*", "Content-Type": "application/json"},
48
+ data=jsonpickle.encode(self.token, unpicklable=False),
49
+ ) as response:
50
+ if response.status != 200:
51
+ return None
52
+ return await response.json()
File without changes
File without changes
File without changes