Skip to content

Commit 384c2c5

Browse files
author
f.fallah
committed
wip(chat): update chat client schema, add unseen count api
1 parent b8a2239 commit 384c2c5

File tree

4 files changed

+95
-177
lines changed

4 files changed

+95
-177
lines changed

src/basalam_sdk/chat/__init__.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from .models import (
99
Attachment,
1010
AttachmentFile,
11-
AttachmentFileTypeEnum,
12-
Channel,
1311
ChatListData,
1412
ChatListResponse,
1513
ChatResponse,
@@ -18,8 +16,6 @@
1816
GetChatsRequest,
1917
GetMessagesRequest,
2018
GetMessagesResponse,
21-
KeyboardButton,
22-
LastMessage,
2319
MessageContent,
2420
MessageFile,
2521
MessageInput,
@@ -29,22 +25,14 @@
2925
MessageTypeEnum,
3026
OrderByEnum,
3127
FiltersEnum,
32-
ReplyMarkup,
33-
# V3 models for get_chats
34-
ChatListDataV3,
35-
ChatListResponseV3,
36-
ChatResourceV3,
37-
MessageResourceV3,
38-
GroupMetadataV3,
39-
ChannelMetadataV3,
28+
ChatListResponse,
29+
UnseenChatCount,
4030
)
4131

4232
__all__ = [
4333
"ChatService",
4434
"Attachment",
4535
"AttachmentFile",
46-
"AttachmentFileTypeEnum",
47-
"Channel",
4836
"ChatListData",
4937
"ChatListResponse",
5038
"ChatResponse",
@@ -53,8 +41,6 @@
5341
"GetChatsRequest",
5442
"GetMessagesRequest",
5543
"GetMessagesResponse",
56-
"KeyboardButton",
57-
"LastMessage",
5844
"MessageContent",
5945
"MessageFile",
6046
"MessageInput",
@@ -64,12 +50,6 @@
6450
"MessageTypeEnum",
6551
"OrderByEnum",
6652
"FiltersEnum",
67-
"ReplyMarkup",
68-
# V3 models for get_chats
69-
"ChatListDataV3",
70-
"ChatListResponseV3",
71-
"ChatResourceV3",
72-
"MessageResourceV3",
73-
"GroupMetadataV3",
74-
"ChannelMetadataV3",
53+
"ChatListResponse",
54+
"UnseenChatCount",
7555
]

src/basalam_sdk/chat/client.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
GetMessagesRequest,
1313
GetMessagesResponse,
1414
GetChatsRequest,
15-
ChatListResponseV3
15+
UnseenChatCount
1616
)
1717
from ..base_client import BaseClient
1818

@@ -193,15 +193,15 @@ def get_messages_sync(
193193
async def get_chats(
194194
self,
195195
request: GetChatsRequest,
196-
) -> ChatListResponseV3:
196+
) -> ChatListResponse:
197197
"""
198198
Get list of chats.
199199
200200
Args:
201201
request: The get chats request model containing query parameters.
202202
203203
Returns:
204-
ChatListResponseV3: The list of chats based on OpenAPI specification.
204+
ChatListResponse: The list of chats based on OpenAPI specification.
205205
"""
206206
params = {
207207
"limit": request.limit,
@@ -219,20 +219,20 @@ async def get_chats(
219219
params["filters"] = request.filters.value
220220

221221
response = await self._get("/v3/chats", params=params)
222-
return ChatListResponseV3(**response)
222+
return ChatListResponse(**response)
223223

224224
def get_chats_sync(
225225
self,
226226
request: GetChatsRequest,
227-
) -> ChatListResponseV3:
227+
) -> ChatListResponse:
228228
"""
229229
Get list of chats (synchronous version).
230230
231231
Args:
232232
request: The get chats request model containing query parameters.
233233
234234
Returns:
235-
ChatListResponseV3: The list of chats based on OpenAPI specification.
235+
ChatListResponse: The list of chats based on OpenAPI specification.
236236
"""
237237
params = {
238238
"limit": request.limit,
@@ -250,4 +250,36 @@ def get_chats_sync(
250250
params["filters"] = request.filters.value
251251

252252
response = self._get_sync("/v3/chats", params=params)
253-
return ChatListResponseV3(**response)
253+
return ChatListResponse(**response)
254+
255+
async def get_unseen_chat_count(self, exceeds_limit: int = 30) -> 'UnseenChatCount':
256+
"""
257+
Get the count of unseen chats.
258+
259+
Args:
260+
exceeds_limit: The limit to check for exceeding unseen chats (default: 30).
261+
262+
Returns:
263+
UnseenChatCount: The unseen chat count response.
264+
"""
265+
endpoint = "/v3/chats/unseen_count"
266+
params = {"exceeds_limit": exceeds_limit}
267+
response = await self._get(endpoint, params=params)
268+
from .models import UnseenChatCount
269+
return UnseenChatCount(**response)
270+
271+
def get_unseen_chat_count_sync(self, exceeds_limit: int = 30) -> 'UnseenChatCount':
272+
"""
273+
Get the count of unseen chats (synchronous version).
274+
275+
Args:
276+
exceeds_limit: The limit to check for exceeding unseen chats (default: 30).
277+
278+
Returns:
279+
UnseenChatCount: The unseen chat count response.
280+
"""
281+
endpoint = "/v3/chats/unseen_count"
282+
params = {"exceeds_limit": exceeds_limit}
283+
response = self._get_sync(endpoint, params=params)
284+
from .models import UnseenChatCount
285+
return UnseenChatCount(**response)

0 commit comments

Comments
 (0)