itd-sdk 2.4.3__tar.gz → 2.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/PKG-INFO +105 -105
  2. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/README.md +103 -103
  3. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/__init__.py +14 -14
  4. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/_default.py +19 -17
  5. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/__init__.py +0 -0
  6. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/auth.py +45 -35
  7. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/comments.py +66 -44
  8. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/dwell.py +20 -19
  9. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/etc.py +19 -16
  10. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/files.py +22 -20
  11. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/hashtags.py +22 -19
  12. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/notifications.py +43 -39
  13. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/pins.py +26 -22
  14. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/platform.py +19 -17
  15. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/polls.py +17 -16
  16. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/posts.py +148 -112
  17. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/reports.py +20 -17
  18. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/search.py +14 -13
  19. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/sessions.py +26 -23
  20. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/subscription.py +50 -42
  21. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/users.py +139 -106
  22. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/api/verification.py +20 -17
  23. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/base.py +437 -414
  24. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/clan.py +39 -38
  25. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/client.py +371 -372
  26. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/comment.py +247 -265
  27. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/enums.py +224 -188
  28. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/exceptions.py +353 -290
  29. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/file.py +170 -168
  30. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/hashtag.py +74 -73
  31. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/logger.py +50 -52
  32. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/notification.py +208 -212
  33. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/pin.py +48 -48
  34. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/poll.py +149 -150
  35. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/post.py +829 -801
  36. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/report.py +35 -34
  37. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/request.py +136 -139
  38. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/session.py +90 -91
  39. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/span.py +10 -10
  40. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/user.py +603 -606
  41. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/utils.py +210 -219
  42. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/itd/version.py +74 -73
  43. {itd_sdk-2.4.3 → itd_sdk-2.4.4}/pyproject.toml +66 -58
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itd-sdk
3
- Version: 2.4.3
3
+ Version: 2.4.4
4
4
  Summary: ITD client for python
5
5
  Keywords: itd,itdsocial
6
6
  Author: firedotguy
@@ -17,7 +17,7 @@ Requires-Dist: sseclient-py~=1.9.0
17
17
  Requires-Dist: dateparser>=1.2.2 ; extra == 'date'
18
18
  Requires-Dist: filetype>=1.2.0 ; extra == 'filetype'
19
19
  Requires-Dist: rich>=15.0.0 ; extra == 'logs'
20
- Requires-Python: >=3.9
20
+ Requires-Python: >=3.10
21
21
  Project-URL: Homepage, https://itdsdk.qzz.io
22
22
  Project-URL: Documentation, https://itdsdk.qzz.io/docs
23
23
  Provides-Extra: date
@@ -25,107 +25,107 @@ Provides-Extra: filetype
25
25
  Provides-Extra: logs
26
26
  Description-Content-Type: text/markdown
27
27
 
28
- # itd-sdk
29
- Клиент ITD для python
30
- Документация (beta): https://itdsdk.qzz.io/docs
31
-
32
- ## Установка
33
-
34
- ```bash
35
- pip install itd-sdk
36
- ```
37
-
38
- ## Пример
39
-
40
- ```python
41
- from itd import ITDClient, Me
42
-
43
- c = ITDClient('token')
44
- print(Me())
45
- ```
46
- <!--
47
- > [!NOTE]
48
- > Берите refresh_token из запроса /auth/refresh. В остальных запросах нету refresh_token
49
- > ![cookie](cookie-screen.png) -->
50
-
51
- ### Получение cookies
52
-
53
- Для получения access_token требуются cookies с `refresh_token`. Как их получить:
54
-
55
- 1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
56
- 2. Откройте DevTools (F12)
57
- 3. Перейдите на вкладку **Network**
58
- 4. Обновите страницу
59
- 5. Найдите запрос к `/auth/refresh`
60
- 6. Скопируйте значение **refresh_token** из **Cookie** из Request Headers
61
-
62
- ![cookie](cookie-screen.png)
63
-
64
-
65
- ## API
66
- ```python
67
- from itd import Me, User, Post, Posts, File, Hashtag, Notifications
68
-
69
- me = Me() # получить себя
70
- me.privacy.update(is_private=True)
71
-
72
- user = User('itd_sdk') # получить пользователя
73
- user.follow()
74
-
75
- post = Post('725681ba-2aaa-42d8-87fb-490c0f44e162') # получить пост
76
- post.like()
77
- post.add_comment('тест комент 6 7')
78
-
79
- posts = Posts() # получить посты из ленты
80
- for i, post in enumerate(Posts()):
81
- post.like() # встроенные защиты, из-за которых рейт-лимит будет получить сложнее + авто ожидание окончания рейт лимита
82
- if i > 10:
83
- break
84
-
85
- post = user.posts[5] # индексация, авто-получение до нужного значения
86
- post.repost()
87
-
88
- file = File.from_path('1.jpg') # загрузка файлов
89
- Post.new('всем привет!', attachments=file) # attachments может быть списком, файлом, или UUID
90
-
91
- hashtag = Hashtag('тестапи') # получить данные хэштэга
92
- print(hashtag.posts_count)
93
- hashtag.posts[0].like()
94
-
95
- notifications = Notifications() # получить уведы
96
- notifications[30].read()
97
- notifications.read_all()
98
- for notification in notifications.stream(): # SSE уведомлений
99
- print(notification.type.value)
100
- break
101
-
102
- def on_like(notification):
103
- print('лайк от', notification.actor.username)
104
- notifications.stop_stream()
105
- notifications.on_like = on_like
106
- stream = notifications.stream_bg() # background SSE
107
-
108
- Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
109
-
110
- ```
111
-
112
- ### Кастомные запросы
113
-
114
- ```python
115
- from itd.request import fetch
116
-
117
- fetch(c, 'метод', 'эндпоинт', {'данные': 'данные'})
118
- ```
119
- Из методов поддерживается `get`, `post`, `put` итд, которые есть в `requests`
120
- К названию эндпоинта добавляется домен итд и `api`, то есть в этом примере отправится `https://xn--d1ah4a.com/api/эндпоинт`.
121
-
122
- > [!NOTE]
123
- > `xn--d1ah4a.com` - punycode от "итд.com"
124
-
125
- ## Прочее
126
- - Лицезия: [MIT](./LICENSE)
127
- - Автор:
128
- - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
129
- - ТГ: [@desicars](https://t.me/desicars)
130
-
28
+ # itd-sdk
29
+ Клиент ITD для python
30
+ Документация (beta): https://itdsdk.qzz.io/docs
31
+
32
+ ## Установка
33
+
34
+ ```bash
35
+ pip install itd-sdk
36
+ ```
37
+
38
+ ## Пример
39
+
40
+ ```python
41
+ from itd import ITDClient, Me
42
+
43
+ c = ITDClient('token')
44
+ print(Me())
45
+ ```
46
+ <!--
47
+ > [!NOTE]
48
+ > Берите refresh_token из запроса /auth/refresh. В остальных запросах нету refresh_token
49
+ > ![cookie](cookie-screen.png) -->
50
+
51
+ ### Получение cookies
52
+
53
+ Для получения access_token требуются cookies с `refresh_token`. Как их получить:
54
+
55
+ 1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
56
+ 2. Откройте DevTools (F12)
57
+ 3. Перейдите на вкладку **Network**
58
+ 4. Обновите страницу
59
+ 5. Найдите запрос к `/auth/refresh`
60
+ 6. Скопируйте значение **refresh_token** из **Cookie** из Request Headers
61
+
62
+ ![cookie](cookie-screen.png)
63
+
64
+
65
+ ## API
66
+ ```python
67
+ from itd import Me, User, Post, Posts, File, Hashtag, Notifications
68
+
69
+ me = Me() # получить себя
70
+ me.privacy.update(is_private=True)
71
+
72
+ user = User('itd_sdk') # получить пользователя
73
+ user.follow()
74
+
75
+ post = Post('725681ba-2aaa-42d8-87fb-490c0f44e162') # получить пост
76
+ post.like()
77
+ post.add_comment('тест комент 6 7')
78
+
79
+ posts = Posts() # получить посты из ленты
80
+ for i, post in enumerate(Posts()):
81
+ post.like() # встроенные защиты, из-за которых рейт-лимит будет получить сложнее + авто ожидание окончания рейт лимита
82
+ if i > 10:
83
+ break
84
+
85
+ post = user.posts[5] # индексация, авто-получение до нужного значения
86
+ post.repost()
87
+
88
+ file = File.from_path('1.jpg') # загрузка файлов
89
+ Post.new('всем привет!', attachments=file) # attachments может быть списком, файлом, или UUID
90
+
91
+ hashtag = Hashtag('тестапи') # получить данные хэштэга
92
+ print(hashtag.posts_count)
93
+ hashtag.posts[0].like()
94
+
95
+ notifications = Notifications() # получить уведы
96
+ notifications[30].read()
97
+ notifications.read_all()
98
+ for notification in notifications.stream(): # SSE уведомлений
99
+ print(notification.type.value)
100
+ break
101
+
102
+ def on_like(notification):
103
+ print('лайк от', notification.actor.username)
104
+ notifications.stop_stream()
105
+ notifications.on_like = on_like
106
+ stream = notifications.stream_bg() # background SSE
107
+
108
+ Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
109
+
110
+ ```
111
+
112
+ ### Кастомные запросы
113
+
114
+ ```python
115
+ from itd.request import fetch
116
+
117
+ fetch(c, 'метод', 'эндпоинт', {'данные': 'данные'})
118
+ ```
119
+ Из методов поддерживается `get`, `post`, `put` итд, которые есть в `requests`
120
+ К названию эндпоинта добавляется домен итд и `api`, то есть в этом примере отправится `https://xn--d1ah4a.com/api/эндпоинт`.
121
+
122
+ > [!NOTE]
123
+ > `xn--d1ah4a.com` - punycode от "итд.com"
124
+
125
+ ## Прочее
126
+ - Лицезия: [MIT](./LICENSE)
127
+ - Автор:
128
+ - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
129
+ - ТГ: [@desicars](https://t.me/desicars)
130
+
131
131
  [![Star History Chart](https://api.star-history.com/chart?repos=itd-sdk/itd-sdk&type=date&legend=top-left)](https://www.star-history.com/?repos=itd-sdk%2Fitd-sdk&type=date&legend=top-left)
@@ -1,104 +1,104 @@
1
- # itd-sdk
2
- Клиент ITD для python
3
- Документация (beta): https://itdsdk.qzz.io/docs
4
-
5
- ## Установка
6
-
7
- ```bash
8
- pip install itd-sdk
9
- ```
10
-
11
- ## Пример
12
-
13
- ```python
14
- from itd import ITDClient, Me
15
-
16
- c = ITDClient('token')
17
- print(Me())
18
- ```
19
- <!--
20
- > [!NOTE]
21
- > Берите refresh_token из запроса /auth/refresh. В остальных запросах нету refresh_token
22
- > ![cookie](cookie-screen.png) -->
23
-
24
- ### Получение cookies
25
-
26
- Для получения access_token требуются cookies с `refresh_token`. Как их получить:
27
-
28
- 1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
29
- 2. Откройте DevTools (F12)
30
- 3. Перейдите на вкладку **Network**
31
- 4. Обновите страницу
32
- 5. Найдите запрос к `/auth/refresh`
33
- 6. Скопируйте значение **refresh_token** из **Cookie** из Request Headers
34
-
35
- ![cookie](cookie-screen.png)
36
-
37
-
38
- ## API
39
- ```python
40
- from itd import Me, User, Post, Posts, File, Hashtag, Notifications
41
-
42
- me = Me() # получить себя
43
- me.privacy.update(is_private=True)
44
-
45
- user = User('itd_sdk') # получить пользователя
46
- user.follow()
47
-
48
- post = Post('725681ba-2aaa-42d8-87fb-490c0f44e162') # получить пост
49
- post.like()
50
- post.add_comment('тест комент 6 7')
51
-
52
- posts = Posts() # получить посты из ленты
53
- for i, post in enumerate(Posts()):
54
- post.like() # встроенные защиты, из-за которых рейт-лимит будет получить сложнее + авто ожидание окончания рейт лимита
55
- if i > 10:
56
- break
57
-
58
- post = user.posts[5] # индексация, авто-получение до нужного значения
59
- post.repost()
60
-
61
- file = File.from_path('1.jpg') # загрузка файлов
62
- Post.new('всем привет!', attachments=file) # attachments может быть списком, файлом, или UUID
63
-
64
- hashtag = Hashtag('тестапи') # получить данные хэштэга
65
- print(hashtag.posts_count)
66
- hashtag.posts[0].like()
67
-
68
- notifications = Notifications() # получить уведы
69
- notifications[30].read()
70
- notifications.read_all()
71
- for notification in notifications.stream(): # SSE уведомлений
72
- print(notification.type.value)
73
- break
74
-
75
- def on_like(notification):
76
- print('лайк от', notification.actor.username)
77
- notifications.stop_stream()
78
- notifications.on_like = on_like
79
- stream = notifications.stream_bg() # background SSE
80
-
81
- Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
82
-
83
- ```
84
-
85
- ### Кастомные запросы
86
-
87
- ```python
88
- from itd.request import fetch
89
-
90
- fetch(c, 'метод', 'эндпоинт', {'данные': 'данные'})
91
- ```
92
- Из методов поддерживается `get`, `post`, `put` итд, которые есть в `requests`
93
- К названию эндпоинта добавляется домен итд и `api`, то есть в этом примере отправится `https://xn--d1ah4a.com/api/эндпоинт`.
94
-
95
- > [!NOTE]
96
- > `xn--d1ah4a.com` - punycode от "итд.com"
97
-
98
- ## Прочее
99
- - Лицезия: [MIT](./LICENSE)
100
- - Автор:
101
- - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
102
- - ТГ: [@desicars](https://t.me/desicars)
103
-
1
+ # itd-sdk
2
+ Клиент ITD для python
3
+ Документация (beta): https://itdsdk.qzz.io/docs
4
+
5
+ ## Установка
6
+
7
+ ```bash
8
+ pip install itd-sdk
9
+ ```
10
+
11
+ ## Пример
12
+
13
+ ```python
14
+ from itd import ITDClient, Me
15
+
16
+ c = ITDClient('token')
17
+ print(Me())
18
+ ```
19
+ <!--
20
+ > [!NOTE]
21
+ > Берите refresh_token из запроса /auth/refresh. В остальных запросах нету refresh_token
22
+ > ![cookie](cookie-screen.png) -->
23
+
24
+ ### Получение cookies
25
+
26
+ Для получения access_token требуются cookies с `refresh_token`. Как их получить:
27
+
28
+ 1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
29
+ 2. Откройте DevTools (F12)
30
+ 3. Перейдите на вкладку **Network**
31
+ 4. Обновите страницу
32
+ 5. Найдите запрос к `/auth/refresh`
33
+ 6. Скопируйте значение **refresh_token** из **Cookie** из Request Headers
34
+
35
+ ![cookie](cookie-screen.png)
36
+
37
+
38
+ ## API
39
+ ```python
40
+ from itd import Me, User, Post, Posts, File, Hashtag, Notifications
41
+
42
+ me = Me() # получить себя
43
+ me.privacy.update(is_private=True)
44
+
45
+ user = User('itd_sdk') # получить пользователя
46
+ user.follow()
47
+
48
+ post = Post('725681ba-2aaa-42d8-87fb-490c0f44e162') # получить пост
49
+ post.like()
50
+ post.add_comment('тест комент 6 7')
51
+
52
+ posts = Posts() # получить посты из ленты
53
+ for i, post in enumerate(Posts()):
54
+ post.like() # встроенные защиты, из-за которых рейт-лимит будет получить сложнее + авто ожидание окончания рейт лимита
55
+ if i > 10:
56
+ break
57
+
58
+ post = user.posts[5] # индексация, авто-получение до нужного значения
59
+ post.repost()
60
+
61
+ file = File.from_path('1.jpg') # загрузка файлов
62
+ Post.new('всем привет!', attachments=file) # attachments может быть списком, файлом, или UUID
63
+
64
+ hashtag = Hashtag('тестапи') # получить данные хэштэга
65
+ print(hashtag.posts_count)
66
+ hashtag.posts[0].like()
67
+
68
+ notifications = Notifications() # получить уведы
69
+ notifications[30].read()
70
+ notifications.read_all()
71
+ for notification in notifications.stream(): # SSE уведомлений
72
+ print(notification.type.value)
73
+ break
74
+
75
+ def on_like(notification):
76
+ print('лайк от', notification.actor.username)
77
+ notifications.stop_stream()
78
+ notifications.on_like = on_like
79
+ stream = notifications.stream_bg() # background SSE
80
+
81
+ Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
82
+
83
+ ```
84
+
85
+ ### Кастомные запросы
86
+
87
+ ```python
88
+ from itd.request import fetch
89
+
90
+ fetch(c, 'метод', 'эндпоинт', {'данные': 'данные'})
91
+ ```
92
+ Из методов поддерживается `get`, `post`, `put` итд, которые есть в `requests`
93
+ К названию эндпоинта добавляется домен итд и `api`, то есть в этом примере отправится `https://xn--d1ah4a.com/api/эндпоинт`.
94
+
95
+ > [!NOTE]
96
+ > `xn--d1ah4a.com` - punycode от "итд.com"
97
+
98
+ ## Прочее
99
+ - Лицезия: [MIT](./LICENSE)
100
+ - Автор:
101
+ - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
102
+ - ТГ: [@desicars](https://t.me/desicars)
103
+
104
104
  [![Star History Chart](https://api.star-history.com/chart?repos=itd-sdk/itd-sdk&type=date&legend=top-left)](https://www.star-history.com/?repos=itd-sdk%2Fitd-sdk&type=date&legend=top-left)
@@ -1,14 +1,14 @@
1
- from importlib.metadata import version
2
-
3
- __version__ = version("itd-sdk")
4
-
5
- from itd.version import Changelog, Apps
6
- from itd.client import Client as ITDClient, Config as ITDConfig
7
- from itd.clan import Clan, TopClans
8
- from itd.file import File
9
- from itd.hashtag import Hashtag, Hashtags
10
- from itd.notification import Notifications
11
- from itd.post import Post, Posts, UserPosts, HashtagPosts, LikedPosts
12
- from itd.poll import NewPoll
13
- from itd.session import Sessions
14
- from itd.user import User, Me
1
+ from importlib.metadata import version
2
+
3
+ __version__ = version("itd-sdk")
4
+
5
+ from itd.version import Changelog, Apps
6
+ from itd.client import Client as ITDClient, Config as ITDConfig
7
+ from itd.clan import Clan, TopClans
8
+ from itd.file import File
9
+ from itd.hashtag import Hashtag, Hashtags
10
+ from itd.notification import Notifications
11
+ from itd.post import Post, Posts, UserPosts, HashtagPosts, LikedPosts
12
+ from itd.poll import NewPoll
13
+ from itd.session import Sessions
14
+ from itd.user import User, Me
@@ -1,17 +1,19 @@
1
- from __future__ import annotations
2
- from typing import TYPE_CHECKING
3
-
4
- if TYPE_CHECKING:
5
- from itd.client import Client
6
-
7
- _default_client: Client | None = None
8
-
9
- def get_default_client() -> Client:
10
- global _default_client
11
- if _default_client is None:
12
- raise
13
- return _default_client
14
-
15
- def set_default_client(client: Client):
16
- global _default_client
17
- _default_client = client
1
+ from __future__ import annotations
2
+ from typing import TYPE_CHECKING
3
+
4
+ if TYPE_CHECKING:
5
+ from itd.client import Client
6
+
7
+ _default_client: Client | None = None
8
+
9
+
10
+ def get_default_client() -> Client:
11
+ global _default_client
12
+ if _default_client is None:
13
+ raise
14
+ return _default_client
15
+
16
+
17
+ def set_default_client(client: Client):
18
+ global _default_client
19
+ _default_client = client
File without changes
@@ -1,35 +1,45 @@
1
- from __future__ import annotations
2
- from typing import TYPE_CHECKING
3
-
4
- from requests import Response
5
-
6
- from itd.base import catch_errors, rate_limit
7
- from itd.enums import AuthLevel
8
- from itd.exceptions import (
9
- InvalidPasswordError, SamePasswordError, InvalidOldPasswordError, SessionNotFoundError,
10
- SessionExpiredError, SessionRevokedError, InvalidCredentials, CaptchaFailedError,
11
- EmailDomainNotAllowed
12
- )
13
- if TYPE_CHECKING:
14
- from itd.client import Client
15
-
16
- @rate_limit()
17
- @catch_errors(SessionExpiredError(), SessionNotFoundError(), SessionRevokedError())
18
- def refresh_token(client: Client) -> Response:
19
- return client.request('post', 'v1/auth/refresh', level=AuthLevel.REFRESH)
20
-
21
- @rate_limit()
22
- @catch_errors(InvalidPasswordError(), SamePasswordError(), InvalidOldPasswordError())
23
- def change_password(client: Client, old: str, new: str) -> Response:
24
- return client.request('post', 'v1/auth/change-password', {'newPassword': new, 'oldPassword': old})
25
-
26
- @rate_limit()
27
- @catch_errors()
28
- def logout(client: Client) -> Response:
29
- return client.request('post', 'v1/auth/logout', level=AuthLevel.REFRESH)
30
-
31
-
32
- @rate_limit()
33
- @catch_errors(InvalidCredentials(), CaptchaFailedError(), EmailDomainNotAllowed())
34
- def sign_in(client: Client, email: str, password: str, turnstile: str):
35
- return client.request('post', 'v1/auth/sign-in', {'email': email, 'password': password, 'turnstileToken': turnstile}, level=AuthLevel.NO)
1
+ from __future__ import annotations
2
+ from typing import TYPE_CHECKING
3
+
4
+ from requests import Response
5
+
6
+ from itd.base import catch_errors, rate_limit
7
+ from itd.enums import AuthLevel
8
+ from itd.exceptions import (
9
+ InvalidPasswordError,
10
+ SamePasswordError,
11
+ InvalidOldPasswordError,
12
+ SessionNotFoundError,
13
+ SessionExpiredError,
14
+ SessionRevokedError,
15
+ InvalidCredentials,
16
+ CaptchaFailedError,
17
+ EmailDomainNotAllowed
18
+ )
19
+
20
+ if TYPE_CHECKING:
21
+ from itd.client import Client
22
+
23
+
24
+ @rate_limit()
25
+ @catch_errors(SessionExpiredError(), SessionNotFoundError(), SessionRevokedError())
26
+ def refresh_token(client: Client) -> Response:
27
+ return client.request('post', 'v1/auth/refresh', level=AuthLevel.REFRESH)
28
+
29
+
30
+ @rate_limit()
31
+ @catch_errors(InvalidPasswordError(), SamePasswordError(), InvalidOldPasswordError())
32
+ def change_password(client: Client, old: str, new: str) -> Response:
33
+ return client.request('post', 'v1/auth/change-password', {'newPassword': new, 'oldPassword': old})
34
+
35
+
36
+ @rate_limit()
37
+ @catch_errors()
38
+ def logout(client: Client) -> Response:
39
+ return client.request('post', 'v1/auth/logout', level=AuthLevel.REFRESH)
40
+
41
+
42
+ @rate_limit()
43
+ @catch_errors(InvalidCredentials(), CaptchaFailedError(), EmailDomainNotAllowed())
44
+ def sign_in(client: Client, email: str, password: str, turnstile: str):
45
+ return client.request('post', 'v1/auth/sign-in', {'email': email, 'password': password, 'turnstileToken': turnstile}, level=AuthLevel.NO)