lsrestclient 0.5.0__tar.gz → 0.6.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lsrestclient
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: REST Api Client
5
5
  Author: mba
6
6
  Author-email: bartel@electronic-shop.lu
@@ -38,3 +38,27 @@ class LsRestClientResponse:
38
38
  content=response.content.decode("utf8"),
39
39
  headers=response.headers,
40
40
  )
41
+
42
+ @classmethod
43
+ def from_dict(cls, status_code: int = 200, data: dict = None, headers: CaseInsensitiveDict = None):
44
+ """
45
+ Converts a dictionary into an instance of the LsRestClientResponse class.
46
+
47
+ :param status_code: The HTTP status code. Defaults to 200.
48
+ :param data: The data dictionary. Defaults to None.
49
+ :param headers: The headers dictionary. Defaults to None.
50
+ :return: An instance of the LsRestClientResponse class.
51
+
52
+ """
53
+ if data is None:
54
+ data = {}
55
+ if headers is None:
56
+ headers = {}
57
+
58
+ content = lsjsonclasses.LSoftJSONEncoder.dumps(data)
59
+
60
+ return cls(
61
+ status_code=status_code,
62
+ content=content,
63
+ headers=headers
64
+ )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "lsrestclient"
3
- version = "0.5.0"
3
+ version = "0.6.0"
4
4
  description = "REST Api Client"
5
5
  authors = ["mba <bartel@electronic-shop.lu>"]
6
6
  readme = "README.md"
File without changes