From 3fab2cb64934952ada02e2447f93bff881c3974b Mon Sep 17 00:00:00 2001 From: rmanach Date: Wed, 18 Dec 2024 14:45:31 +0100 Subject: [PATCH 1/3] update README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 76a15d8..62754b3 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,15 @@ In order to use the client you need to provide some environments variables defin Once it's done, you're good to use the client. +```python +from whereis_client import Client + +cli = Client.from_env() +lst_gps_positions = cli.get_gps_positions( + date_start="2022-12-25", date_end="2022-12-30" +) +``` + For some code samples on how to use the client, take a look at the [main.py](main.py) sample script. Enjoy ! From 46cbbd749c937142c6d958fcb74e801a38036eaf Mon Sep 17 00:00:00 2001 From: rmanach Date: Wed, 18 Dec 2024 14:58:08 +0100 Subject: [PATCH 2/3] fix typo --- src/client.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client.py b/src/client.py index d333cfe..6fbd58b 100644 --- a/src/client.py +++ b/src/client.py @@ -24,7 +24,7 @@ __all__ = ["Client", "OrderField"] def refresh(): """ Catch 401 status code (UnauthorizedException) - and refresh the access token and retry. + refresh the access token and retry. """ def decorator(func): @@ -183,7 +183,7 @@ class Client: Initialize the client from env variables (.env & global) and log in into the application. - If the login fails, and exception is raised. + If the login fails, an exception is raised. """ env_data = { "WHEREIS_API_EMAIL": os.getenv("WHEREIS_API_EMAIL", ""), @@ -337,7 +337,8 @@ class Client: @refresh() def delete_session(self, id_: UUID) -> None | WhereIsException: """ - Close and delete the session. Users can't be added anymore. + Close and delete the session. + NOTE: The GPS positions associated to the session are not deleted ! """ session_url = urljoin(self.base_url, f"/sessions/{id_}/") @@ -377,6 +378,7 @@ class Client: @refresh() def close_session(self, id_: UUID) -> dict[str, Any] | WhereIsException: + """Close the DEFINITIVELY the session. Users can't be added anymore.""" session_url = urljoin(self.base_url, f"/sessions/{id_}/close/") logging.info(f"close session: {session_url}") @@ -495,7 +497,9 @@ class Client: return None @refresh() - def _get_paginate_gps_postions(self, url: str) -> dict[str, Any] | WhereIsException: + def _get_paginate_gps_positions( + self, url: str + ) -> dict[str, Any] | WhereIsException: res = self.session.get(url) if res.status_code == 401: @@ -539,7 +543,7 @@ class Client: while gps_url is not None: logging.info(f"get gps data from: {gps_url}") - data = self._get_paginate_gps_postions(gps_url) + data = self._get_paginate_gps_positions(gps_url) lst_gps_positions.extend([d for d in data["results"]]) gps_url = data["next"] From 7196f5ce7a41b30d42e99ea0dc38e3ad430d6286 Mon Sep 17 00:00:00 2001 From: rmanach Date: Wed, 18 Dec 2024 15:01:27 +0100 Subject: [PATCH 3/3] bump version number --- src/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__init__.py b/src/__init__.py index 6160875..d714875 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -2,4 +2,4 @@ from .client import Client, OrderField __all__ = ["Client", "OrderField"] -VERSION = "0.1.0a0" +VERSION = "0.1.0"