Skip to content

Commit 36b163d

Browse files
committed
Move ssl to attribute
1 parent 5c57e7d commit 36b163d

File tree

3 files changed

+11
-39
lines changed

3 files changed

+11
-39
lines changed

pyoverkiz/clients/overkiz.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class OverkizClient(ABC):
7373
setup: Setup | None = field(default=None, init=False)
7474
devices: list[Device] = field(factory=list, init=False)
7575
gateways: list[Gateway] = field(factory=list, init=False)
76+
_ssl: bool = field(default=True, init=False)
7677

7778
@abstractmethod
7879
async def _login(
@@ -99,12 +100,11 @@ def _headers(self) -> dict[str, str]:
99100
async def get(
100101
self,
101102
path: str,
102-
ssl: bool = True,
103103
) -> Any:
104104
"""Make a GET request to the OverKiz API"""
105105

106106
async with self.session.get(
107-
f"{self.endpoint}{path}", headers=self._headers, ssl=ssl
107+
f"{self.endpoint}{path}", headers=self._headers, ssl=self._ssl
108108
) as response:
109109
await self.check_response(response)
110110
return await response.json()
@@ -114,7 +114,6 @@ async def post(
114114
path: str,
115115
payload: JSON | None = None,
116116
data: JSON | None = None,
117-
ssl: bool = True,
118117
) -> Any:
119118
"""Make a POST request to the OverKiz API"""
120119

@@ -123,20 +122,19 @@ async def post(
123122
data=data,
124123
json=payload,
125124
headers=self._headers,
126-
ssl=ssl,
125+
ssl=self._ssl,
127126
) as response:
128127
await self.check_response(response)
129128
return await response.json()
130129

131130
async def delete(
132131
self,
133132
path: str,
134-
ssl: bool = True,
135133
) -> None:
136134
"""Make a DELETE request to the OverKiz API"""
137135

138136
async with self.session.delete(
139-
f"{self.endpoint}{path}", headers=self._headers, ssl=ssl
137+
f"{self.endpoint}{path}", headers=self._headers, ssl=self._ssl
140138
) as response:
141139
await self.check_response(response)
142140

pyoverkiz/clients/somfy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SomfyClient(OverkizClient):
2424
def _headers(self) -> dict[str, str]:
2525
return {"Authorization": f"Bearer {self._access_token}"}
2626

27-
async def get(self, path: str, ssl: bool = True) -> Any:
27+
async def get(self, path: str) -> Any:
2828
"""Make a GET request to the OverKiz API"""
2929

3030
await self._refresh_token_if_expired()
@@ -35,14 +35,13 @@ async def post(
3535
path: str,
3636
payload: JSON | None = None,
3737
data: JSON | None = None,
38-
ssl: bool = True,
3938
) -> Any:
4039
"""Make a POST request to the OverKiz API"""
4140
if path != "login":
4241
await self._refresh_token_if_expired()
4342
return await super().post(path, payload=payload, data=data)
4443

45-
async def delete(self, path: str, ssl: bool = True) -> None:
44+
async def delete(self, path: str) -> None:
4645
"""Make a DELETE request to the OverKiz API"""
4746
await self._refresh_token_if_expired()
4847
return await super().delete(path)

pyoverkiz/clients/somfy_local.py

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,18 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from attr import field
44

55
from pyoverkiz.clients.overkiz import OverkizClient
6-
from pyoverkiz.types import JSON
76

87

98
class SomfyLocalClient(OverkizClient):
10-
async def _login(self, username: str, password: str) -> bool:
9+
10+
_ssl: bool = field(default=False, init=False)
11+
12+
async def _login(self, _username: str, _password: str) -> bool:
1113
"""There is no login for Somfy Local"""
1214
return True
1315

1416
@property
1517
def _headers(self) -> dict[str, str]:
1618
return {"Authorization": f"Bearer {self.password}"}
17-
18-
async def get(
19-
self,
20-
path: str,
21-
_ssl: bool = False,
22-
) -> Any:
23-
"""Make a GET request to the OverKiz API"""
24-
25-
return await super().get(path, ssl=False)
26-
27-
async def post(
28-
self,
29-
path: str,
30-
payload: JSON | None = None,
31-
data: JSON | None = None,
32-
_ssl: bool = False,
33-
) -> Any:
34-
"""Make a POST request to the OverKiz API"""
35-
return await super().post(path, payload=payload, data=data, ssl=False)
36-
37-
async def delete(
38-
self,
39-
path: str,
40-
_ssl: bool = False,
41-
) -> None:
42-
"""Make a DELETE request to the OverKiz API"""
43-
return await super().delete(path, ssl=False)

0 commit comments

Comments
 (0)