|
4 | 4 | from .calls import make_request |
5 | 5 | from .data import AuthType, BugoutToken, BugoutUser, BugoutUserTokens, Method, TokenType |
6 | 6 | from .exceptions import InvalidUrlSpec, TokenInvalidParameters |
7 | | -from .settings import REQUESTS_TIMEOUT |
| 7 | +from .settings import REQUESTS_TIMEOUT, BUGOUT_APPLICATION_ID_HEADER |
8 | 8 |
|
9 | 9 |
|
10 | 10 | class User: |
@@ -52,25 +52,33 @@ def create_user( |
52 | 52 | return BugoutUser(**result) |
53 | 53 |
|
54 | 54 | def get_user( |
55 | | - self, token: Union[str, uuid.UUID], auth_type: AuthType = AuthType.bearer |
| 55 | + self, |
| 56 | + token: Union[str, uuid.UUID], |
| 57 | + application_id: Optional[Union[str, uuid.UUID]] = None, |
| 58 | + auth_type: AuthType = AuthType.bearer, |
56 | 59 | ) -> BugoutUser: |
57 | 60 | get_user_path = "user" |
58 | 61 | headers = { |
59 | 62 | "Authorization": f"{auth_type.value} {token}", |
60 | 63 | } |
| 64 | + if auth_type == AuthType.web3 and application_id is not None: |
| 65 | + headers[BUGOUT_APPLICATION_ID_HEADER] = str(application_id) |
61 | 66 | result = self._call(method=Method.get, path=get_user_path, headers=headers) |
62 | 67 | return BugoutUser(**result) |
63 | 68 |
|
64 | 69 | def get_user_by_id( |
65 | 70 | self, |
66 | 71 | token: Union[str, uuid.UUID], |
67 | 72 | user_id: Union[str, uuid.UUID], |
| 73 | + application_id: Optional[Union[str, uuid.UUID]] = None, |
68 | 74 | auth_type: AuthType = AuthType.bearer, |
69 | 75 | ) -> BugoutUser: |
70 | 76 | get_user_by_id_path = f"user/{user_id}" |
71 | 77 | headers = { |
72 | 78 | "Authorization": f"{auth_type.value} {token}", |
73 | 79 | } |
| 80 | + if auth_type == AuthType.web3 and application_id is not None: |
| 81 | + headers[BUGOUT_APPLICATION_ID_HEADER] = str(application_id) |
74 | 82 | result = self._call( |
75 | 83 | method=Method.get, path=get_user_by_id_path, headers=headers |
76 | 84 | ) |
|
0 commit comments