maxbot-api-client-python 1.1.2__py3-none-any.whl → 1.2.0__py3-none-any.whl

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.
@@ -1,445 +1,453 @@
1
- from maxbot_api_client_python.client import Client, decode, adecode
1
+ from typing import Any
2
+
3
+ from maxbot_api_client_python.client import Client
2
4
  from maxbot_api_client_python.types.constants import Paths
3
- from maxbot_api_client_python.types import models
5
+ from maxbot_api_client_python.types.models import (
6
+ AddMembersReq, AddMembersResp, ChatInfo, ChatMember, DeleteAdminReq, DeleteChatReq,
7
+ DeleteMemberReq, EditChatReq, GetChatAdminsReq, GetChatAdminsResp, GetChatMembersReq,
8
+ GetChatMembersResp, GetChatMembershipReq, GetChatReq, GetChatsReq, GetChatsResp,
9
+ GetPinnedMessageReq, LeaveChatReq, Message, PinMessageReq, SendActionReq,
10
+ SetChatAdminsReq, SimpleQueryResult, UnpinMessageReq, ChatAdmin
11
+ )
4
12
 
5
13
  class Chats:
6
14
  def __init__(self, client: Client):
7
15
  self.client = client
8
16
 
9
- def GetChats(self, **kwargs) -> models.GetChatsResp:
17
+ def get_chats(self, req: GetChatsReq) -> GetChatsResp:
10
18
  """
11
19
  Returns information about chats that the bot participated in: a result list and a marker pointing to the next page.
12
20
 
13
21
  Example:
14
- response = api.chats.GetChats(
22
+ response = bot.chats.get_chats(GetChatsReq(
15
23
  count=20
16
- )
24
+ ))
17
25
  """
18
- req = models.GetChatsReq(**kwargs)
19
- return decode(self.client, "GET", Paths.CHATS, models.GetChatsResp, query=req.model_dump(exclude_none=True))
26
+ query, payload = self.client.split_request(req)
27
+ return self.client.decode("GET", Paths.CHATS, GetChatsResp, query=query, payload=payload)
20
28
 
21
- def GetChat(self, **kwargs) -> models.ChatInfo:
29
+ def get_chat(self, req: GetChatReq) -> ChatInfo:
22
30
  """
23
31
  Returns info about a specific chat.
24
32
 
25
33
  Example:
26
- response = api.chats.GetChat(
34
+ response = bot.chats.get_chat(GetChatReq(
27
35
  chat_id=123456789
28
- )
36
+ ))
29
37
  """
30
- req = models.GetChatReq(**kwargs)
31
38
  path = Paths.CHATS_ID.format(req.chat_id)
32
- return decode(self.client, "GET", path, models.ChatInfo)
39
+ query, payload = self.client.split_request(req)
40
+ return self.client.decode("GET", path, ChatInfo, query=query, payload=payload)
33
41
 
34
- def EditChat(self, **kwargs) -> models.ChatInfo:
42
+ def edit_chat(self, req: EditChatReq) -> ChatInfo:
35
43
  """
36
44
  Modifies the properties of a chat, such as its title, icon, or notification settings.
37
45
 
38
46
  Example:
39
- response = api.chats.EditChat(
47
+ response = bot.chats.edit_chat(EditChatReq(
40
48
  chat_id=123456789,
41
49
  title="Updated Chat Title",
42
50
  notify=True
43
- )
51
+ ))
44
52
  """
45
- req = models.EditChatReq(**kwargs)
46
53
  path = Paths.CHATS_ID.format(req.chat_id)
47
- return decode(self.client, "PATCH", path, models.ChatInfo, payload=req)
54
+ query, payload = self.client.split_request(req)
55
+ return self.client.decode("PATCH", path, ChatInfo, query=query, payload=payload)
48
56
 
49
- def DeleteChat(self, **kwargs) -> models.SimpleQueryResult:
57
+ def delete_chat(self, req: DeleteChatReq) -> SimpleQueryResult:
50
58
  """
51
59
  Permanently deletes a chat for the bot.
52
60
 
53
61
  Example:
54
- response = api.chats.DeleteChat(
62
+ response = bot.chats.delete_chat(DeleteChatReq(
55
63
  chat_id=123456789
56
- )
64
+ ))
57
65
  """
58
- req = models.DeleteChatReq(**kwargs)
59
66
  path = Paths.CHATS_ID.format(req.chat_id)
60
- return decode(self.client, "DELETE", path, models.SimpleQueryResult)
67
+ query, payload = self.client.split_request(req)
68
+ return self.client.decode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
61
69
 
62
- def SendAction(self, **kwargs) -> models.SimpleQueryResult:
70
+ def send_action(self, req: SendActionReq) -> SimpleQueryResult:
63
71
  """
64
72
  Broadcasts a temporary status action (e.g., "typing...", "recording video...") to the chat participants.
65
73
 
66
74
  Example:
67
- response = api.chats.SendAction(
75
+ response = bot.chats.send_action(SendActionReq(
68
76
  chat_id=123456789,
69
77
  action="mark_seen"
70
- )
78
+ ))
71
79
  """
72
- req = models.SendActionReq(**kwargs)
73
80
  path = Paths.CHATS_ACTIONS.format(req.chat_id)
74
- return decode(self.client, "POST", path, models.SimpleQueryResult, payload=req)
81
+ query, payload = self.client.split_request(req)
82
+ return self.client.decode("POST", path, SimpleQueryResult, query=query, payload=payload)
75
83
 
76
- def GetPinnedMessage(self, **kwargs) -> models.Message:
84
+ def get_pinned_message(self, req: GetPinnedMessageReq) -> Message:
77
85
  """
78
86
  Retrieves the currently pinned message in the specified chat.
79
87
 
80
88
  Example:
81
- response = api.chats.GetPinnedMessage(
89
+ response = bot.chats.get_pinned_message(GetPinnedMessageReq(
82
90
  chat_id=123456789
83
- )
91
+ ))
84
92
  """
85
- req = models.GetPinnedMessageReq(**kwargs)
86
93
  path = Paths.CHATS_PIN.format(req.chat_id)
87
- return decode(self.client, "GET", path, models.Message)
94
+ query, payload = self.client.split_request(req)
95
+ return self.client.decode("GET", path, Message, query=query, payload=payload)
88
96
 
89
- def PinMessage(self, **kwargs) -> models.SimpleQueryResult:
97
+ def pin_message(self, req: PinMessageReq) -> SimpleQueryResult:
90
98
  """
91
99
  Pins a specific message in the chat.
92
100
  You can optionally specify whether to notify chat members about the new pinned message.
93
101
 
94
102
  Example:
95
- response = api.chats.PinMessage(
103
+ response = bot.chats.pin_message(PinMessageReq(
96
104
  chat_id=123456789,
97
105
  message_id="mid:987654321...",
98
106
  notify=True
99
- )
107
+ ))
100
108
  """
101
- req = models.PinMessageReq(**kwargs)
102
109
  path = Paths.CHATS_PIN.format(req.chat_id)
103
- return decode(self.client, "PUT", path, models.SimpleQueryResult, payload=req)
110
+ query, payload = self.client.split_request(req)
111
+ return self.client.decode("PUT", path, SimpleQueryResult, query=query, payload=payload)
104
112
 
105
- def UnpinMessage(self, **kwargs) -> models.SimpleQueryResult:
113
+ def unpin_message(self, req: UnpinMessageReq) -> SimpleQueryResult:
106
114
  """
107
115
  Removes the pinned message from the specified chat.
108
116
 
109
117
  Example:
110
- response = api.chats.UnpinMessage(
118
+ response = bot.chats.unpin_message(UnpinMessageReq(
111
119
  chat_id=123456789
112
- )
120
+ ))
113
121
  """
114
- req = models.UnpinMessageReq(**kwargs)
115
122
  path = Paths.CHATS_PIN.format(req.chat_id)
116
- return decode(self.client, "DELETE", path, models.SimpleQueryResult)
123
+ query, payload = self.client.split_request(req)
124
+ return self.client.decode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
117
125
 
118
- def GetChatMembership(self, **kwargs) -> models.ChatMember:
126
+ def get_chat_membership(self, req: GetChatMembershipReq) -> ChatMember:
119
127
  """
120
128
  Returns chat membership info for the current bot.
121
129
 
122
130
  Example:
123
- response = api.chats.GetChatMembership(
131
+ response = bot.chats.get_chat_membership(GetChatMembershipReq(
124
132
  chat_id=123456789
125
- )
133
+ ))
126
134
  """
127
- req = models.GetChatMembershipReq(**kwargs)
128
135
  path = Paths.CHATS_MEMBERS_ME.format(req.chat_id)
129
- return decode(self.client, "GET", path, models.ChatMember)
136
+ query, payload = self.client.split_request(req)
137
+ return self.client.decode("GET", path, ChatMember, query=query, payload=payload)
130
138
 
131
- def LeaveChat(self, **kwargs) -> models.SimpleQueryResult:
139
+ def leave_chat(self, req: LeaveChatReq) -> SimpleQueryResult:
132
140
  """
133
141
  Removes the bot from chat members.
134
142
 
135
143
  Example:
136
- response = api.chats.LeaveChat(
144
+ response = bot.chats.leave_chat(LeaveChatReq(
137
145
  chat_id=123456789
138
- )
146
+ ))
139
147
  """
140
- req = models.LeaveChatReq(**kwargs)
141
148
  path = Paths.CHATS_MEMBERS_ME.format(req.chat_id)
142
- return decode(self.client, "DELETE", path, models.SimpleQueryResult)
149
+ query, payload = self.client.split_request(req)
150
+ return self.client.decode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
143
151
 
144
- def GetChatAdmins(self, **kwargs) -> models.GetChatAdminsResp:
152
+ def get_chat_admins(self, req: GetChatAdminsReq) -> GetChatAdminsResp:
145
153
  """
146
154
  Retrieves a list of administrators for the specified group chat.
147
155
 
148
156
  Example:
149
- response = api.chats.GetChatAdmins(
157
+ response = bot.chats.get_chat_admins(GetChatAdminsReq(
150
158
  chat_id=123456789
151
- )
159
+ ))
152
160
  """
153
- req = models.GetChatAdminsReq(**kwargs)
154
161
  path = Paths.CHATS_MEMBERS_ADMIN.format(req.chat_id)
155
- return decode(self.client, "GET", path, models.GetChatAdminsResp)
162
+ query, payload = self.client.split_request(req)
163
+ return self.client.decode("GET", path, GetChatAdminsResp, query=query, payload=payload)
156
164
 
157
- def SetChatAdmins(self, **kwargs) -> models.SimpleQueryResult:
165
+ def set_chat_admins(self, req: SetChatAdminsReq) -> SimpleQueryResult:
158
166
  """
159
167
  Assigns administrator rights to specific users in a group chat.
160
168
 
161
169
  Example:
162
- response = api.chats.SetChatAdmins(
170
+ response = bot.chats.set_chat_admins(SetChatAdminsReq(
163
171
  chat_id=123456789,
164
172
  admins=[
165
173
  ChatAdmin(user_id=98765, role="admin"),
166
174
  ChatAdmin(user_id=43210, role="admin")
167
175
  ]
168
- )
176
+ ))
169
177
  """
170
- req = models.SetChatAdminsReq(**kwargs)
171
178
  path = Paths.CHATS_MEMBERS_ADMIN.format(req.chat_id)
172
- return decode(self.client, "POST", path, models.SimpleQueryResult, payload=req)
179
+ query, payload = self.client.split_request(req)
180
+ return self.client.decode("POST", path, SimpleQueryResult, query=query, payload=payload)
173
181
 
174
- def DeleteAdmin(self, **kwargs) -> models.SimpleQueryResult:
182
+ def delete_admin(self, req: DeleteAdminReq) -> SimpleQueryResult:
175
183
  """
176
184
  Revokes administrator rights from a specific user in a group chat.
177
185
 
178
186
  Example:
179
- response = api.chats.DeleteAdmin(
187
+ response = bot.chats.delete_admin(DeleteAdminReq(
180
188
  chat_id=123456789,
181
189
  user_id=98765
182
- )
190
+ ))
183
191
  """
184
- req = models.DeleteAdminReq(**kwargs)
185
192
  path = Paths.CHATS_MEMBERS_ADMIN_ID.format(req.chat_id, req.user_id)
186
- return decode(self.client, "DELETE", path, models.SimpleQueryResult)
193
+ query, payload = self.client.split_request(req)
194
+ return self.client.decode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
187
195
 
188
- def GetChatMembers(self, **kwargs) -> models.GetChatAdminsResp:
196
+ def get_chat_members(self, req: GetChatMembersReq) -> GetChatMembersResp:
189
197
  """
190
198
  Returns users participated in the chat.
191
199
 
192
200
  Example:
193
- response = api.chats.GetChatMembers(
201
+ response = bot.chats.get_chat_members(GetChatMembersReq(
194
202
  chat_id=123456789,
195
203
  count=20
196
- )
204
+ ))
197
205
  """
198
- req = models.GetChatMembersReq(**kwargs)
199
206
  path = Paths.CHATS_MEMBERS.format(req.chat_id)
200
- return decode(self.client, "GET", path, models.GetChatAdminsResp, query=req.model_dump(exclude_none=True))
207
+ query, payload = self.client.split_request(req)
208
+ return self.client.decode("GET", path, GetChatMembersResp, query=query, payload=payload)
201
209
 
202
- def AddMembers(self, **kwargs) -> models.AddMembersResp:
210
+ def add_members(self, req: AddMembersReq) -> AddMembersResp:
203
211
  """
204
212
  Adds one or more users to a group chat.
205
213
 
206
214
  Example:
207
- response = api.chats.AddMembers(
215
+ response = bot.chats.add_members(AddMembersReq(
208
216
  chat_id=123456789,
209
217
  user_ids=[11111, 22222]
210
- )
218
+ ))
211
219
  """
212
- req = models.AddMembersReq(**kwargs)
213
220
  path = Paths.CHATS_MEMBERS.format(req.chat_id)
214
- return decode(self.client, "POST", path, models.AddMembersResp, payload=req)
221
+ query, payload = self.client.split_request(req)
222
+ return self.client.decode("POST", path, AddMembersResp, query=query, payload=payload)
215
223
 
216
- def DeleteMember(self, **kwargs) -> models.SimpleQueryResult:
224
+ def delete_member(self, req: DeleteMemberReq) -> SimpleQueryResult:
217
225
  """
218
226
  Removes a specific user from a group chat.
219
227
  You can optionally block the user from rejoining.
220
228
 
221
229
  Example:
222
- response = api.chats.DeleteMember(
230
+ response = bot.chats.delete_member(DeleteMemberReq(
223
231
  chat_id=123456789,
224
232
  user_id=98765,
225
233
  block=True
226
- )
234
+ ))
227
235
  """
228
- req = models.DeleteMemberReq(**kwargs)
229
236
  path = Paths.CHATS_MEMBERS.format(req.chat_id)
230
- return decode(self.client, "DELETE", path, models.SimpleQueryResult, query=req.model_dump(exclude_none=True))
237
+ query, payload = self.client.split_request(req)
238
+ return self.client.decode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
231
239
 
232
- async def GetChatsAsync(self, **kwargs) -> models.GetChatsResp:
240
+ async def get_chats_async(self, req: GetChatsReq) -> GetChatsResp:
233
241
  """
234
- Async version of GetChats.
242
+ Async version of get_chats.
235
243
 
236
244
  Example:
237
- response = await api.chats.GetChatsAsync(
245
+ response = await bot.chats.get_chats_async(GetChatsReq(
238
246
  count=20
239
- )
247
+ ))
240
248
  """
241
- req = models.GetChatsReq(**kwargs)
242
- return await adecode(self.client, "GET", Paths.CHATS, models.GetChatsResp, query=req.model_dump(exclude_none=True))
249
+ query, payload = self.client.split_request(req)
250
+ return await self.client.adecode("GET", Paths.CHATS, GetChatsResp, query=query, payload=payload)
243
251
 
244
- async def GetChatAsync(self, **kwargs) -> models.ChatInfo:
252
+ async def get_chat_async(self, req: GetChatReq) -> ChatInfo:
245
253
  """
246
- Async version of GetChat.
254
+ Async version of get_chat.
247
255
 
248
256
  Example:
249
- response = await api.chats.GetChatAsync(
257
+ response = await bot.chats.get_chat_async(GetChatReq(
250
258
  chat_id=123456789
251
- )
259
+ ))
252
260
  """
253
- req = models.GetChatReq(**kwargs)
254
261
  path = Paths.CHATS_ID.format(req.chat_id)
255
- return await adecode(self.client, "GET", path, models.ChatInfo)
256
-
257
- async def EditChatAsync(self, **kwargs) -> models.ChatInfo:
262
+ query, payload = self.client.split_request(req)
263
+ return await self.client.adecode("GET", path, ChatInfo, query=query, payload=payload)
264
+
265
+ async def edit_chat_async(self, req: EditChatReq) -> ChatInfo:
258
266
  """
259
267
  Async version of EditChat.
260
268
 
261
269
  Example:
262
- response = await api.chats.EditChatAsync(
270
+ response = await bot.chats.edit_chat_async(EditChatReq(
263
271
  chat_id=123456789,
264
272
  title="Updated Chat Title"
265
- )
273
+ ))
266
274
  """
267
- req = models.EditChatReq(**kwargs)
268
275
  path = Paths.CHATS_ID.format(req.chat_id)
269
- return await adecode(self.client, "PATCH", path, models.ChatInfo, payload=req)
276
+ query, payload = self.client.split_request(req)
277
+ return await self.client.adecode("PATCH", path, ChatInfo, query=query, payload=payload)
270
278
 
271
- async def DeleteChatAsync(self, **kwargs) -> models.SimpleQueryResult:
279
+ async def delete_chat_async(self, req: DeleteChatReq) -> SimpleQueryResult:
272
280
  """
273
281
  Async version of DeleteChat.
274
282
 
275
283
  Example:
276
- response = await api.chats.DeleteChatAsync(
284
+ response = await bot.chats.delete_chat_async(DeleteChatReq(
277
285
  chat_id=123456789
278
- )
286
+ ))
279
287
  """
280
- req = models.DeleteChatReq(**kwargs)
281
288
  path = Paths.CHATS_ID.format(req.chat_id)
282
- return await adecode(self.client, "DELETE", path, models.SimpleQueryResult)
289
+ query, payload = self.client.split_request(req)
290
+ return await self.client.adecode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
283
291
 
284
- async def SendActionAsync(self, **kwargs) -> models.SimpleQueryResult:
292
+ async def send_action_async(self, req: SendActionReq) -> SimpleQueryResult:
285
293
  """
286
294
  Async version of SendAction.
287
295
 
288
296
  Example:
289
- response = await api.chats.SendActionAsync(
297
+ response = await bot.chats.send_action_async(SendActionReq(
290
298
  chat_id=123456789,
291
299
  action="typing"
292
- )
300
+ ))
293
301
  """
294
- req = models.SendActionReq(**kwargs)
295
302
  path = Paths.CHATS_ACTIONS.format(req.chat_id)
296
- return await adecode(self.client, "POST", path, models.SimpleQueryResult, payload=req)
303
+ query, payload = self.client.split_request(req)
304
+ return await self.client.adecode("POST", path, SimpleQueryResult, query=query, payload=payload)
297
305
 
298
- async def GetPinnedMessageAsync(self, **kwargs) -> models.Message:
306
+ async def get_pinned_message_async(self, req: GetPinnedMessageReq) -> Message:
299
307
  """
300
308
  Async version of GetPinnedMessage.
301
309
 
302
310
  Example:
303
- response = await api.chats.GetPinnedMessageAsync(
311
+ response = await bot.chats.get_pinned_message_async(GetPinnedMessageReq(
304
312
  chat_id=123456789
305
- )
313
+ ))
306
314
  """
307
- req = models.GetPinnedMessageReq(**kwargs)
308
315
  path = Paths.CHATS_PIN.format(req.chat_id)
309
- return await adecode(self.client, "GET", path, models.Message)
316
+ query, payload = self.client.split_request(req)
317
+ return await self.client.adecode("GET", path, Message, query=query, payload=payload)
310
318
 
311
- async def PinMessageAsync(self, **kwargs) -> models.SimpleQueryResult:
319
+ async def pin_message_async(self, req: PinMessageReq) -> SimpleQueryResult:
312
320
  """
313
321
  Async version of PinMessage.
314
322
 
315
323
  Example:
316
- response = await api.chats.PinMessageAsync(
324
+ response = await bot.chats.pin_message_async(PinMessageReq(
317
325
  chat_id=123456789,
318
326
  message_id="mid:987654321..."
319
- )
327
+ ))
320
328
  """
321
- req = models.PinMessageReq(**kwargs)
322
329
  path = Paths.CHATS_PIN.format(req.chat_id)
323
- return await adecode(self.client, "PUT", path, models.SimpleQueryResult, payload=req)
330
+ query, payload = self.client.split_request(req)
331
+ return await self.client.adecode("PUT", path, SimpleQueryResult, query=query, payload=payload)
324
332
 
325
- async def UnpinMessageAsync(self, **kwargs) -> models.SimpleQueryResult:
333
+ async def unpin_message_async(self, req: UnpinMessageReq) -> SimpleQueryResult:
326
334
  """
327
335
  Async version of UnpinMessage.
328
336
 
329
337
  Example:
330
- response = await api.chats.UnpinMessageAsync(
338
+ response = await bot.chats.unpin_message_async(UnpinMessageReq(
331
339
  chat_id=123456789
332
- )
340
+ ))
333
341
  """
334
- req = models.UnpinMessageReq(**kwargs)
335
342
  path = Paths.CHATS_PIN.format(req.chat_id)
336
- return await adecode(self.client, "DELETE", path, models.SimpleQueryResult)
343
+ query, payload = self.client.split_request(req)
344
+ return await self.client.adecode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
337
345
 
338
- async def GetChatMembershipAsync(self, **kwargs) -> models.ChatMember:
346
+ async def get_chat_membership_async(self, req: GetChatMembershipReq) -> ChatMember:
339
347
  """
340
348
  Async version of GetChatMembership.
341
349
 
342
350
  Example:
343
- response = await api.chats.GetChatMembershipAsync(
351
+ response = await bot.chats.get_chat_membership_async(GetChatMembershipReq(
344
352
  chat_id=123456789
345
- )
353
+ ))
346
354
  """
347
- req = models.GetChatMembershipReq(**kwargs)
348
355
  path = Paths.CHATS_MEMBERS_ME.format(req.chat_id)
349
- return await adecode(self.client, "GET", path, models.ChatMember)
356
+ query, payload = self.client.split_request(req)
357
+ return await self.client.adecode("GET", path, ChatMember, query=query, payload=payload)
350
358
 
351
- async def LeaveChatAsync(self, **kwargs) -> models.SimpleQueryResult:
359
+ async def leave_chat_async(self, req: LeaveChatReq) -> SimpleQueryResult:
352
360
  """
353
361
  Async version of LeaveChat.
354
362
 
355
363
  Example:
356
- response = await api.chats.LeaveChatAsync(
364
+ response = await bot.chats.leave_chat_async(LeaveChatReq(
357
365
  chat_id=123456789
358
- )
366
+ ))
359
367
  """
360
- req = models.LeaveChatReq(**kwargs)
361
368
  path = Paths.CHATS_MEMBERS_ME.format(req.chat_id)
362
- return await adecode(self.client, "DELETE", path, models.SimpleQueryResult)
369
+ query, payload = self.client.split_request(req)
370
+ return await self.client.adecode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
363
371
 
364
- async def GetChatAdminsAsync(self, **kwargs) -> models.GetChatAdminsResp:
372
+ async def get_chat_admins_async(self, req: GetChatAdminsReq) -> GetChatAdminsResp:
365
373
  """
366
- Async version of GetChatAdmins.
374
+ Async version of get_chatAdmins.
367
375
 
368
376
  Example:
369
- response = await api.chats.GetChatAdminsAsync(
377
+ response = await bot.chats.get_chat_admins_async(GetChatAdminsReq(
370
378
  chat_id=123456789
371
- )
379
+ ))
372
380
  """
373
- req = models.GetChatAdminsReq(**kwargs)
374
381
  path = Paths.CHATS_MEMBERS_ADMIN.format(req.chat_id)
375
- return await adecode(self.client, "GET", path, models.GetChatAdminsResp)
382
+ query, payload = self.client.split_request(req)
383
+ return await self.client.adecode("GET", path, GetChatAdminsResp, query=query, payload=payload)
376
384
 
377
- async def SetChatAdminsAsync(self, **kwargs) -> models.SimpleQueryResult:
385
+ async def set_chat_admins_async(self, req: SetChatAdminsReq) -> SimpleQueryResult:
378
386
  """
379
387
  Async version of SetChatAdmins.
380
388
 
381
389
  Example:
382
- response = await api.chats.SetChatAdminsAsync(
390
+ response = await bot.chats.set_chat_admins_async(SetChatAdminsReq(
383
391
  chat_id=123456789,
384
- admins=[ChatAdmin(user_id=98765, role="admin")]
385
- )
392
+ admins=[ChatAdmin(user_id=98765, permissions=["admin"])]
393
+ ))
386
394
  """
387
- req = models.SetChatAdminsReq(**kwargs)
388
395
  path = Paths.CHATS_MEMBERS_ADMIN.format(req.chat_id)
389
- return await adecode(self.client, "POST", path, models.SimpleQueryResult, payload=req)
396
+ query, payload = self.client.split_request(req)
397
+ return await self.client.adecode("POST", path, SimpleQueryResult, query=query, payload=payload)
390
398
 
391
- async def DeleteAdminAsync(self, **kwargs) -> models.SimpleQueryResult:
399
+ async def delete_admin_async(self, req: DeleteAdminReq) -> SimpleQueryResult:
392
400
  """
393
401
  Async version of DeleteAdmin.
394
402
 
395
403
  Example:
396
- response = await api.chats.DeleteAdminAsync(
404
+ response = await bot.chats.delete_admin_async(DeleteAdminReq(
397
405
  chat_id=123456789,
398
406
  user_id=98765
399
- )
407
+ ))
400
408
  """
401
- req = models.DeleteAdminReq(**kwargs)
402
409
  path = Paths.CHATS_MEMBERS_ADMIN_ID.format(req.chat_id, req.user_id)
403
- return await adecode(self.client, "DELETE", path, models.SimpleQueryResult)
410
+ query, payload = self.client.split_request(req)
411
+ return await self.client.adecode("DELETE", path, SimpleQueryResult, query=query, payload=payload)
404
412
 
405
- async def GetChatMembersAsync(self, **kwargs) -> models.GetChatAdminsResp:
413
+ async def get_chat_members_async(self, req: GetChatMembersReq) -> GetChatMembersResp:
406
414
  """
407
415
  Async version of GetChatMembers.
408
416
 
409
417
  Example:
410
- response = await api.chats.GetChatMembersAsync(
418
+ response = await bot.chats.get_chat_members_async(GetChatMembersReq(
411
419
  chat_id=123456789,
412
420
  count=20
413
- )
421
+ ))
414
422
  """
415
- req = models.GetChatMembersReq(**kwargs)
416
423
  path = Paths.CHATS_MEMBERS.format(req.chat_id)
417
- return await adecode(self.client, "GET", path, models.GetChatAdminsResp, query=req.model_dump(exclude_none=True))
424
+ query, payload = self.client.split_request(req)
425
+ return await self.client.adecode("GET", path, GetChatMembersResp, query=query, payload=payload)
418
426
 
419
- async def AddMembersAsync(self, **kwargs) -> models.AddMembersResp:
427
+ async def add_members_async(self, req: AddMembersReq) -> AddMembersResp:
420
428
  """
421
429
  Async version of AddMembers.
422
430
 
423
431
  Example:
424
- response = await api.chats.AddMembersAsync(
432
+ response = await bot.chats.add_members_async(AddMembersReq(
425
433
  chat_id=123456789,
426
434
  user_ids=[11111, 22222]
427
- )
435
+ ))
428
436
  """
429
- req = models.AddMembersReq(**kwargs)
430
437
  path = Paths.CHATS_MEMBERS.format(req.chat_id)
431
- return await adecode(self.client, "POST", path, models.AddMembersResp, payload=req)
438
+ query, payload = self.client.split_request(req)
439
+ return await self.client.adecode("POST", path, AddMembersResp, query=query, payload=payload)
432
440
 
433
- async def DeleteMemberAsync(self, **kwargs) -> models.SimpleQueryResult:
441
+ async def delete_member_async(self, req: DeleteMemberReq) -> SimpleQueryResult:
434
442
  """
435
443
  Async version of DeleteMember.
436
444
 
437
445
  Example:
438
- response = await api.chats.DeleteMemberAsync(
446
+ response = await bot.chats.delete_member_async(DeleteMemberReq(
439
447
  chat_id=123456789,
440
448
  user_id=98765
441
- )
449
+ ))
442
450
  """
443
- req = models.DeleteMemberReq(**kwargs)
444
451
  path = Paths.CHATS_MEMBERS.format(req.chat_id)
445
- return await adecode(self.client, "DELETE", path, models.SimpleQueryResult, query=req.model_dump(exclude_none=True))
452
+ query, payload = self.client.split_request(req)
453
+ return await self.client.adecode("DELETE", path, SimpleQueryResult, query=query, payload=payload)