From f0392ea5aeefa651db4bfcf3cf82fbd5df98009d Mon Sep 17 00:00:00 2001 From: Brian Savelkouls Date: Tue, 2 Apr 2024 16:58:17 +0100 Subject: [PATCH 1/3] Bump version to 0.1.5 and update OUTSETAPY_VERSION constant --- pyproject.toml | 2 +- src/outsetapy/static.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cb4ebbb..95e3130 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "outsetapy" -version = "0.1.4a" +version = "0.1.5" authors = [ { name="Roborian, Inc", email="info@roborian.com" }, diff --git a/src/outsetapy/static.py b/src/outsetapy/static.py index 594bdde..fe0e937 100644 --- a/src/outsetapy/static.py +++ b/src/outsetapy/static.py @@ -1 +1 @@ -OUTSETAPY_VERSION = "0.1.4a" +OUTSETAPY_VERSION = "0.1.5" From 8339887b35cd066ed62ec84e5cfe8a8237e08d22 Mon Sep 17 00:00:00 2001 From: Brian Savelkouls Date: Tue, 2 Apr 2024 17:36:45 +0100 Subject: [PATCH 2/3] Refactor User class in __init__.py to use UserCredentials and update Profile class in profile.py to pass store argument to Person constructor --- src/outsetapy/api/user/__init__.py | 12 ++++++------ src/outsetapy/api/user/profile.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/outsetapy/api/user/__init__.py b/src/outsetapy/api/user/__init__.py index 6aaabab..d70d412 100644 --- a/src/outsetapy/api/user/__init__.py +++ b/src/outsetapy/api/user/__init__.py @@ -1,5 +1,6 @@ from outsetapy.util.store import Store from outsetapy.util.request import Request +from outsetapy.util.credentials import UserCredentials from .profile import Profile from .password import Password @@ -21,17 +22,16 @@ async def login(self, username: str, password: str) -> LoginResponse: request = Request(self.store, "tokens").with_body( { "username": username, - "password": password, - "grant_type": "password", - "client_id": "outseta_auth_widget", + "password": password } ) - response = await request.post() + response = request.post() if not response.ok: - raise Exception(response) + raise Exception(response.content) response_body = response.json() - self.store.user_auth.access_token = response_body["access_token"] + + self.store.user_auth = UserCredentials(response_body["access_token"]) return response_body async def impersonate(self, username: str) -> LoginResponse: diff --git a/src/outsetapy/api/user/profile.py b/src/outsetapy/api/user/profile.py index 22b6374..3dcc597 100644 --- a/src/outsetapy/api/user/profile.py +++ b/src/outsetapy/api/user/profile.py @@ -24,11 +24,11 @@ async def get(self, fields: Optional[str] = None) -> Person: if not response.ok: raise Exception(response) - return Person(response.json()) + return Person(response.json(), self.store) async def update( self, profile: ProfileUpdate - ) -> Union[Person, ValidationError[Person]]: + ) -> Person: request = ( Request(self.store, "profile").authenticate_as_user().with_body(profile) ) @@ -37,6 +37,6 @@ async def update( if response.status == 400: raise Exception(response.json()) elif response.ok: - return Person(response.json()) + return Person(response.json(), self.store) else: raise Exception(response) From 95bb110e50bc5c74793606f5c4f442ef028561fe Mon Sep 17 00:00:00 2001 From: radomangutic Date: Thu, 4 Apr 2024 17:32:48 +0200 Subject: [PATCH 3/3] Fix request.post() method call in User class --- src/outsetapy/api/user/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/outsetapy/api/user/__init__.py b/src/outsetapy/api/user/__init__.py index d70d412..e96355b 100644 --- a/src/outsetapy/api/user/__init__.py +++ b/src/outsetapy/api/user/__init__.py @@ -47,7 +47,7 @@ async def impersonate(self, username: str) -> LoginResponse: } ) ) - response = await request.post() + response = request.post() if not response.ok: raise Exception(response)