Skip to content

Commit 8d1f032

Browse files
committed
Find user by id, email, username and application id
1 parent 0262a33 commit 8d1f032

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

bugout/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
__email__ = "engineering@bugout.dev"
1010
__license__ = "MIT"
11-
__version__ = "0.2.15"
11+
__version__ = "0.2.16"
1212

1313
__all__ = (
1414
"__author__",

bugout/app.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,23 @@ def get_user_by_id(
9090

9191
def find_user(
9292
self,
93-
username: str,
93+
user_id: Optional[Union[str, uuid.UUID]] = None,
94+
email: Optional[str] = None,
95+
username: Optional[str] = None,
96+
application_id: Optional[Union[str, uuid.UUID]] = None,
9497
token: Optional[Union[str, uuid.UUID]] = None,
9598
timeout: float = REQUESTS_TIMEOUT,
9699
**kwargs: Dict[str, Any],
97100
) -> data.BugoutUser:
98101
self.user.timeout = timeout
99-
return self.user.find_user(username=username, token=token, **kwargs)
102+
return self.user.find_user(
103+
user_id=user_id,
104+
email=email,
105+
username=username,
106+
application_id=application_id,
107+
token=token,
108+
**kwargs,
109+
)
100110

101111
def confirm_email(
102112
self,

bugout/user.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,33 @@ def get_user_by_id(
8686

8787
def find_user(
8888
self,
89-
username: str,
89+
user_id: Optional[Union[str, uuid.UUID]] = None,
90+
email: Optional[str] = None,
91+
username: Optional[str] = None,
92+
application_id: Optional[Union[str, uuid.UUID]] = None,
9093
token: Optional[Union[str, uuid.UUID]] = None,
9194
**kwargs: Dict[str, Any],
9295
) -> BugoutUser:
93-
find_user_path = f"user/find?username={username}"
96+
find_user_path = f"user/find"
97+
98+
query_params = {}
99+
if user_id is not None:
100+
query_params.update({"user_id": str(user_id)})
101+
if email is not None:
102+
query_params.update({"email": email})
103+
if username is not None:
104+
query_params.update({"username": username})
105+
if application_id is not None:
106+
query_params.update({"application_id": application_id})
107+
94108
headers = {}
95109
if token is not None:
96110
headers.update({"Authorization": f"Bearer {token}"})
97111
if "headers" in kwargs.keys():
98112
headers.update(kwargs["headers"])
99-
result = self._call(method=Method.get, path=find_user_path, headers=headers)
113+
result = self._call(
114+
method=Method.get, path=find_user_path, params=query_params, headers=headers
115+
)
100116
return BugoutUser(**result)
101117

102118
def confirm_email(

0 commit comments

Comments
 (0)