|
1 | | -"""Typestubs for secret Curious variables.""" |
| 1 | +"""Curious variables (secret).""" |
2 | 2 |
|
3 | 3 | from typing import Optional |
| 4 | +from warnings import deprecated |
4 | 5 |
|
5 | 6 | from ...utility_functions import ( |
6 | 7 | ApiProtocol, |
7 | 8 | Credentials as CredentialsABC, |
| 9 | + CuriousApplets, |
8 | 10 | CuriousId, |
9 | 11 | Endpoints as EndpointsABC, |
10 | 12 | Tokens as TokensABC, |
11 | 13 | ) |
12 | 14 |
|
13 | | -class AppletCredentials(CredentialsABC): |
14 | | - hbn_mindlogger: dict[str, dict[str, str]] |
| 15 | +applets: CuriousApplets |
| 16 | + |
| 17 | +class _ActivityIds(type): |
| 18 | + """Metaclass for deprecating `applet_ids` module-level global variable.""" |
| 19 | + |
| 20 | + _data: dict[str, str] |
| 21 | + def __getitem__(cls, key: str) -> CuriousId: ... |
| 22 | + |
| 23 | +@deprecated("Deprecated in v1.9.0. Use `applets[applet_name].activities`.") |
| 24 | +class activity_ids(metaclass=_ActivityIds): # noqa: N801 |
| 25 | + """Curious activity IDs.""" |
| 26 | + |
| 27 | + @classmethod |
| 28 | + def __getitem__(cls, key: str) -> CuriousId: ... |
| 29 | + |
| 30 | +class _AppletIds(type): |
| 31 | + """Metaclass for deprecating `applet_ids` module-level global variable.""" |
| 32 | + |
| 33 | + _data: dict[str, str] |
| 34 | + def __getitem__(cls, key: str) -> CuriousId: ... |
| 35 | + |
| 36 | +applet_ids: _AppletIds # type: ignore[no-redef] |
| 37 | + |
| 38 | +@deprecated("Deprecated in v1.9.0. Use `applets`.") |
| 39 | +class applet_ids(metaclass=_AppletIds): # type: ignore[no-redef] # noqa: N801 |
| 40 | + """Curious applet IDs.""" |
15 | 41 |
|
| 42 | + @classmethod |
| 43 | + def __getitem__(cls, key: str) -> CuriousId: ... |
| 44 | + |
| 45 | +@deprecated("Deprecated in v1.9.0. Use `AppletCredentials`.") |
16 | 46 | class Credentials(CredentialsABC): |
| 47 | + """API login credentials for 'hbn_mindlogger'.""" |
| 48 | + |
| 49 | + @staticmethod |
| 50 | + @deprecated("Deprecated in v1.9.0. Use `AppletCredentials[applet_name]`.") |
| 51 | + def _hbn_mindlogger() -> dict[str, str]: |
| 52 | + """ |
| 53 | + Applet credentials for decryption. |
| 54 | +
|
| 55 | + .. version-deprecated:: 1.9.0 |
| 56 | + Use `AppletCredentials[applet_name]` |
| 57 | + """ |
| 58 | + |
17 | 59 | hbn_mindlogger: dict[str, str] |
| 60 | + """API login credentials for 'hbn_mindlogger'. |
| 61 | +
|
| 62 | + .. version-deprecated:: 1.9.0 |
| 63 | + Use `AppletCredentials[applet_name]` |
| 64 | + """ |
| 65 | + _hbn_mindlogger() |
| 66 | + |
| 67 | +class AppletCredentials(CredentialsABC): |
| 68 | + """Applet credentials for decryption.""" |
| 69 | + |
| 70 | + def __init__(self) -> None: |
| 71 | + """Initialize Applet Credentials.""" |
| 72 | + |
| 73 | + @staticmethod |
| 74 | + @deprecated("Deprecated in v1.9.0. Use `AppletCredentials[applet_name]`.") |
| 75 | + def _hbn_mindlogger() -> dict[str, dict[str, str]]: |
| 76 | + """ |
| 77 | + Applet credentials for decryption. |
| 78 | +
|
| 79 | + .. version-deprecated:: 1.9.0 |
| 80 | + Use `AppletCredentials[applet_name]` |
| 81 | + """ |
| 82 | + |
| 83 | + hbn_mindlogger: dict[str, dict[str, str]] |
| 84 | + """Applet credentials for decryption. |
| 85 | +
|
| 86 | + .. version-deprecated:: 1.9.0 |
| 87 | + Use `AppletCredentials[applet_name]` |
| 88 | + """ |
| 89 | + _hbn_mindlogger() |
| 90 | + |
| 91 | + def __getitem__(self, key: str) -> dict[str, str]: |
| 92 | + """Get applet credentials for given applet name.""" |
18 | 93 |
|
19 | 94 | class Endpoints(EndpointsABC): |
20 | | - def __init__(self, host: str = ..., protocol: ApiProtocol = ...) -> None: ... |
21 | | - def activity(self, activity_id: CuriousId) -> str: ... |
| 95 | + """Curious endpoints.""" |
| 96 | + |
| 97 | + def __init__( |
| 98 | + self, host: str = "api-v2.gettingcurious.com", protocol: ApiProtocol = "https" |
| 99 | + ) -> None: |
| 100 | + """Initialize Curious API Endpoints.""" |
| 101 | + self.host: str |
| 102 | + self.protocol: ApiProtocol |
| 103 | + |
| 104 | + def activity(self, activity_id: CuriousId) -> str: |
| 105 | + """Endpoint for activities.""" |
| 106 | + |
22 | 107 | @property |
23 | | - def alerts(self) -> str: ... |
24 | | - def applet(self, applet_id: CuriousId) -> str: ... |
| 108 | + def alerts(self) -> str: |
| 109 | + """Endpoint for alerts.""" |
| 110 | + |
| 111 | + def applet(self, applet_id: CuriousId) -> str: |
| 112 | + """Return applet encryption info.""" |
| 113 | + |
25 | 114 | def applet_activity_answers_list( |
26 | 115 | self, applet_id: CuriousId, activity_id: CuriousId |
27 | | - ) -> str: ... |
| 116 | + ) -> str: |
| 117 | + """Return applet activity answers list endpoint.""" |
| 118 | + |
28 | 119 | @property |
29 | | - def auth(self) -> str: ... |
30 | | - def invitation_statuses(self, owner_id: CuriousId, applet_id: CuriousId) -> str: ... |
| 120 | + def auth(self) -> str: |
| 121 | + """Return authentication endpoint.""" |
| 122 | + |
31 | 123 | @property |
32 | | - def login(self) -> str: ... |
| 124 | + def _base_url(self) -> str: |
| 125 | + """Base URL for Curious API calls.""" |
33 | 126 |
|
34 | | -activity_ids: dict[str, CuriousId] |
35 | | -applet_ids: dict[str, CuriousId] |
36 | | -owner_ids: dict[str, CuriousId] |
| 127 | + @_base_url.setter |
| 128 | + def _base_url(self, url: str) -> None: |
| 129 | + """Raise exception ― _base_url is calculated for Curious endpoints.""" |
| 130 | + |
| 131 | + def invitation_statuses(self, owner_id: CuriousId, applet_id: CuriousId) -> str: |
| 132 | + """Return invitation statuses endpoint.""" |
37 | 133 |
|
38 | | -def headers(token: Optional[str] = None) -> dict[str, str]: ... |
| 134 | + @property |
| 135 | + def login(self) -> str: |
| 136 | + """Curious authentication endpoint.""" |
| 137 | + |
| 138 | +def headers(token: Optional[str]) -> dict[str, str]: |
| 139 | + """Return Curious headers.""" |
| 140 | + |
| 141 | +owner_ids: dict[str, CuriousId] |
| 142 | +"""Curious project owner IDs.""" |
39 | 143 |
|
40 | 144 | class Tokens(TokensABC): |
41 | | - access: str |
42 | | - endpoints: Endpoints |
43 | | - refresh: str |
| 145 | + """Curious tokens.""" |
44 | 146 |
|
45 | | - def __init__(self, endpoints: Endpoints, credentials: dict[str, str]) -> None: ... |
| 147 | + def __init__(self, endpoints: Endpoints, credentials: dict[str, str]) -> None: |
| 148 | + """Initialize Curious tokens.""" |
| 149 | + self.endpoints: Endpoints |
| 150 | + self.access: str |
| 151 | + self.refresh: str |
0 commit comments