pysmarlaapi 0.2.4__tar.gz → 0.3.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.

Potentially problematic release.


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

Files changed (23) hide show
  1. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/PKG-INFO +1 -1
  2. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/__init__.py +1 -1
  3. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/classes/auth_token.py +9 -0
  4. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/classes/connection.py +3 -1
  5. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/tests/test.py +3 -3
  6. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/.gitignore +0 -0
  7. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/.pre-commit-config.yaml +0 -0
  8. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/.pypirc +0 -0
  9. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/.vscode/launch.json +0 -0
  10. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/.vscode/settings.json +0 -0
  11. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/README.md +0 -0
  12. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pyproject.toml +0 -0
  13. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/classes/__init__.py +0 -0
  14. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/connection_hub/__init__.py +0 -0
  15. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/federwiege/__init__.py +0 -0
  16. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/federwiege/classes/__init__.py +0 -0
  17. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/federwiege/classes/property.py +0 -0
  18. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/federwiege/classes/service.py +0 -0
  19. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/federwiege/services/__init__.py +0 -0
  20. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/federwiege/services/analyser_service.py +0 -0
  21. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/pysmarlaapi/federwiege/services/babywiege_service.py +0 -0
  22. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/requirements.txt +0 -0
  23. {pysmarlaapi-0.2.4 → pysmarlaapi-0.3.0}/requirements_dev.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pysmarlaapi
3
- Version: 0.2.4
3
+ Version: 0.3.0
4
4
  Summary: Swing2Sleep Smarla API
5
5
  Author-email: Robin Lintermann <robin.lintermann@explicatis.com>
6
6
  Requires-Python: >=3.11.9
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.4"
1
+ __version__ = "0.3.0"
2
2
 
3
3
  from .classes import Connection
4
4
  from .federwiege import Federwiege
@@ -1,3 +1,4 @@
1
+ import base64
1
2
  from dataclasses import dataclass
2
3
  from typing import Self
3
4
 
@@ -23,5 +24,13 @@ class AuthToken:
23
24
  def from_string(cls, value) -> Self:
24
25
  return AuthToken.from_json(jsonpickle.decode(value))
25
26
 
27
+ @classmethod
28
+ def from_base64(cls, value) -> Self:
29
+ token = base64.b64decode(value.encode()).decode()
30
+ return AuthToken.from_string(token)
31
+
26
32
  def get_string(self) -> str:
27
33
  return jsonpickle.encode(self, unpicklable=False)
34
+
35
+ def get_base64(self) -> str:
36
+ return base64.b64encode(self.get_string().encode()).decode()
@@ -6,7 +6,7 @@ from . import AuthToken
6
6
 
7
7
  class Connection:
8
8
 
9
- def __init__(self, url: str, token: AuthToken = None, token_str=None, token_json=None):
9
+ def __init__(self, url: str, token: AuthToken = None, token_str=None, token_json=None, token_b64=None):
10
10
  self.url = url
11
11
  if token is not None:
12
12
  self.token = token
@@ -14,6 +14,8 @@ class Connection:
14
14
  self.token = AuthToken.from_json(token_json)
15
15
  elif token_str is not None:
16
16
  self.token = AuthToken.from_string(token_str)
17
+ elif token_b64 is not None:
18
+ self.token = AuthToken.from_base64(token_b64)
17
19
  else:
18
20
  self.token = None
19
21
 
@@ -10,15 +10,15 @@ logging.basicConfig(level=20)
10
10
  from pysmarlaapi import Connection, Federwiege
11
11
 
12
12
  try:
13
- from config import AUTH_TOKEN_PERSONAL, HOST
13
+ from config import AUTH_TOKEN_B64, HOST
14
14
  except ImportError:
15
15
  print("config.py or mandatory variables missing, please add in root folder...")
16
- exit()
16
+ sys.exit()
17
17
 
18
18
  loop = asyncio.get_event_loop()
19
19
  async_thread = threading.Thread(target=loop.run_forever)
20
20
 
21
- connection = Connection(url=HOST, token_json=AUTH_TOKEN_PERSONAL)
21
+ connection = Connection(url=HOST, token_b64=AUTH_TOKEN_B64)
22
22
 
23
23
  federwiege = Federwiege(loop, connection)
24
24
 
File without changes
File without changes
File without changes
File without changes