-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .auth_user import AuthUser | ||
from .auth_result import AuthResult | ||
|
||
__all__ = ["AuthUser"] | ||
__all__ = ["AuthUser", "AuthResult"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Optional, List | ||
from swibots.base.switch_object import SwitchObject | ||
from swibots.utils.types import JSONDict | ||
|
||
|
||
class AuthResult(SwitchObject): | ||
def __init__( | ||
self, | ||
access_token: Optional[str] = None, | ||
refresh_token: Optional[str] = None, | ||
user_id: Optional[int] = None, | ||
is_bot: Optional[bool] = False, | ||
roles: Optional[List[str]] = None, | ||
active: Optional[bool] = False | ||
): | ||
self.access_token = access_token | ||
self.refresh_token = refresh_token | ||
self.user_id = user_id | ||
self.is_bot = is_bot | ||
self.roles = roles | ||
self.active = active | ||
|
||
def from_json(self, data: Optional[JSONDict]) -> "AuthResult": | ||
super().from_json(data) | ||
if data is not None: | ||
self.access_token = data.get("access_token") | ||
self.refresh_token = data.get("refresh_token") | ||
self.user_id = data.get("user_id") | ||
self.is_bot = data.get("is_bot") | ||
self.roles = data.get("roles") | ||
self.active = data.get("active") | ||
return self |