Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,25 +150,31 @@ Use a cloud server when you want to connect through the vendor’s public API. U
asyncio.run(main())
```

<!-- TODO: Rexel OAuth2 flow not fully working yet
=== "Rexel (cloud)"

Authentication to the Rexel cloud requires your mobile app username and password.
Authentication to the Rexel cloud uses OAuth2 authorization code flow.
You need an authorization code and redirect URI obtained from the Rexel OAuth2 consent flow.
Comment on lines +156 to +157

Use `Server.REXEL` with `UsernamePasswordCredentials` to authenticate.
Use `Server.REXEL` with `RexelOAuthCodeCredentials` to authenticate.

```python
import asyncio

from pyoverkiz.auth.credentials import UsernamePasswordCredentials
from pyoverkiz.auth.credentials import RexelOAuthCodeCredentials
from pyoverkiz.client import OverkizClient
from pyoverkiz.enums import Server

async def main() -> None:
async with OverkizClient(
server=Server.REXEL,
credentials=UsernamePasswordCredentials("you@example.com", "password"),
credentials=RexelOAuthCodeCredentials(
code="your-authorization-code",
redirect_uri="https://your-redirect-uri",
),
) as client:
await client.login()

asyncio.run(main())
```
-->
4 changes: 2 additions & 2 deletions pyoverkiz/action_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class ActionQueueSettings:
def validate(self) -> None:
"""Validate configuration values for the action queue."""
if self.delay <= 0:
raise ValueError(f"action_queue_delay must be positive, got {self.delay!r}")
raise ValueError(f"delay must be positive, got {self.delay!r}")
if self.max_actions < 1:
raise ValueError(
f"action_queue_max_actions must be at least 1, got {self.max_actions!r}"
f"max_actions must be at least 1, got {self.max_actions!r}"
)
Comment on lines 26 to 31


Expand Down
11 changes: 6 additions & 5 deletions pyoverkiz/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ def __init__(
) -> None:
"""Constructor.

:param server: ServerConfig
:param credentials: Credentials for authentication
:param verify_ssl: Enable SSL certificate verification
:param session: optional ClientSession
:param settings: behavioral settings for the client (default None)
Args:
server: ServerConfig, Server enum, or server key string.
credentials: Credentials for authentication.
verify_ssl: Enable SSL certificate verification.
session: Optional ClientSession.
settings: Behavioral settings for the client.
"""
self.server_config = self._normalize_server(server)

Expand Down
3 changes: 2 additions & 1 deletion pyoverkiz/response_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ async def check_response(response: ClientResponse) -> None:
if error_code:
# Error messages between cloud and local servers differ slightly in quoting and punctuation.
# Normalise so substring matching works across both variants.
message = message.strip('".') if (message := result.get("error")) else ""
raw_message = result.get("error")
message = raw_message.strip('".') if raw_message else ""

# 1. Primary dispatch: match on errorCode (+ optional message substring)
for code, pattern, error_class in _ERROR_CODE_MESSAGE_MAP:
Expand Down
Loading