Skip to content

Commit 7ced36f

Browse files
committed
Handler find_user added
1 parent 4299736 commit 7ced36f

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

bugout/__init__.py

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

88
__email__ = "engineering@bugout.dev"
99
__license__ = "MIT"
10-
__version__ = "0.1.1"
10+
__version__ = "0.1.2"
1111

1212
__all__ = (
1313
"__author__",

bugout/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ def get_user_by_id(
7676
self.user.timeout = timeout
7777
return self.user.get_user_by_id(token=token, user_id=user_id)
7878

79+
def find_user(
80+
self,
81+
token: Union[str, uuid.UUID],
82+
username: str,
83+
timeout: float = REQUESTS_TIMEOUT,
84+
) -> data.BugoutUser:
85+
self.user.timeout = timeout
86+
return self.user.find_user(
87+
token=token,
88+
username=username,
89+
)
90+
7991
def confirm_email(
8092
self,
8193
token: Union[str, uuid.UUID],

bugout/data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class HolderType(Enum):
3636
class BugoutUser(BaseModel):
3737
id: uuid.UUID = Field(alias="user_id")
3838
username: str
39-
email: str
40-
normalized_email: str
41-
verified: bool
42-
autogenerated: bool
43-
created_at: datetime
44-
updated_at: datetime
39+
email: Optional[str]
40+
normalized_email: Optional[str]
41+
verified: Optional[bool]
42+
autogenerated: Optional[bool]
43+
created_at: Optional[datetime]
44+
updated_at: Optional[datetime]
4545

4646

4747
class BugoutUserShort(BaseModel):

bugout/user.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ def get_user_by_id(
7575
)
7676
return BugoutUser(**result)
7777

78+
def find_user(
79+
self,
80+
token: Union[str, uuid.UUID],
81+
username: str,
82+
) -> BugoutUser:
83+
find_user_path = f"user/find?username={username}"
84+
headers = {
85+
"Authorization": f"Bearer {token}",
86+
}
87+
result = self._call(method=Method.get, path=find_user_path, headers=headers)
88+
return BugoutUser(**result)
89+
7890
def confirm_email(
7991
self, token: Union[str, uuid.UUID], verification_code: str
8092
) -> BugoutUser:

0 commit comments

Comments
 (0)