stream-chat 4.19.0__py3-none-any.whl → 4.20.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.
stream_chat/__pkg__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  __author__ = "Tommaso Barbugli"
2
2
  __copyright__ = "Copyright 2019-2022, Stream.io, Inc"
3
- __version__ = "4.19.0"
3
+ __version__ = "4.20.0"
4
4
  __maintainer__ = "Tommaso Barbugli"
5
5
  __email__ = "support@getstream.io"
6
6
  __status__ = "Production"
@@ -2,6 +2,7 @@ import json
2
2
  from typing import Any, Dict, Iterable, List, Union
3
3
 
4
4
  from stream_chat.base.channel import ChannelInterface, add_user_id
5
+ from stream_chat.base.exceptions import StreamChannelException
5
6
  from stream_chat.types.stream_response import StreamResponse
6
7
 
7
8
 
@@ -209,3 +210,40 @@ class Channel(ChannelInterface):
209
210
  "channel_cid": self.cid,
210
211
  }
211
212
  return await self.client.post("moderation/unmute/channel", data=params)
213
+
214
+ async def pin(self, user_id: str) -> StreamResponse:
215
+ if not user_id:
216
+ raise StreamChannelException("user_id must not be empty")
217
+
218
+ payload = {"set": {"pinned": True}}
219
+ return await self.client.patch(f"{self.url}/member/{user_id}", data=payload)
220
+
221
+ async def unpin(self, user_id: str) -> StreamResponse:
222
+ if not user_id:
223
+ raise StreamChannelException("user_id must not be empty")
224
+
225
+ payload = {"set": {"pinned": False}}
226
+ return await self.client.patch(f"{self.url}/member/{user_id}", data=payload)
227
+
228
+ async def archive(self, user_id: str) -> StreamResponse:
229
+ if not user_id:
230
+ raise StreamChannelException("user_id must not be empty")
231
+
232
+ payload = {"set": {"archived": True}}
233
+ return await self.client.patch(f"{self.url}/member/{user_id}", data=payload)
234
+
235
+ async def unarchive(self, user_id: str) -> StreamResponse:
236
+ if not user_id:
237
+ raise StreamChannelException("user_id must not be empty")
238
+
239
+ payload = {"set": {"archived": False}}
240
+ return await self.client.patch(f"{self.url}/member/{user_id}", data=payload)
241
+
242
+ async def update_member_partial(
243
+ self, user_id: str, to_set: Dict = None, to_unset: Iterable[str] = None
244
+ ) -> StreamResponse:
245
+ if not user_id:
246
+ raise StreamChannelException("user_id must not be empty")
247
+
248
+ payload = {"set": to_set or {}, "unset": to_unset or []}
249
+ return await self.client.patch(f"{self.url}/member/{user_id}", data=payload)
@@ -440,6 +440,52 @@ class ChannelInterface(abc.ABC):
440
440
  """
441
441
  pass
442
442
 
443
+ @abc.abstractmethod
444
+ def pin(self, user_id: str) -> Union[StreamResponse, Awaitable[StreamResponse]]:
445
+ """
446
+ Pins a channel
447
+ Allows a user to pin the channel (only for themselves)
448
+ """
449
+ pass
450
+
451
+ @abc.abstractmethod
452
+ def unpin(self, user_id: str) -> Union[StreamResponse, Awaitable[StreamResponse]]:
453
+ """
454
+ Unpins a channel
455
+ Allows a user to unpin the channel (only for themselves)
456
+ """
457
+ pass
458
+
459
+ @abc.abstractmethod
460
+ def archive(self, user_id: str) -> Union[StreamResponse, Awaitable[StreamResponse]]:
461
+ """
462
+ Pins a channel
463
+ Allows a user to archive the channel (only for themselves)
464
+ """
465
+ pass
466
+
467
+ @abc.abstractmethod
468
+ def unarchive(
469
+ self, user_id: str
470
+ ) -> Union[StreamResponse, Awaitable[StreamResponse]]:
471
+ """
472
+ Unpins a channel
473
+ Allows a user to unpin the channel (only for themselves)
474
+ """
475
+ pass
476
+
477
+ @abc.abstractmethod
478
+ def update_member_partial(
479
+ self, user_id: str, to_set: Dict = None, to_unset: Iterable[str] = None
480
+ ) -> Union[StreamResponse, Awaitable[StreamResponse]]:
481
+ """
482
+ Update channel member partially
483
+
484
+ :param to_set: a dictionary of key/value pairs to set or to override
485
+ :param to_unset: a list of keys to clear
486
+ """
487
+ pass
488
+
443
489
 
444
490
  def add_user_id(payload: Dict, user_id: str) -> Dict:
445
491
  return {**payload, "user": {"id": user_id}}
stream_chat/channel.py CHANGED
@@ -2,6 +2,7 @@ import json
2
2
  from typing import Any, Dict, Iterable, List, Union
3
3
 
4
4
  from stream_chat.base.channel import ChannelInterface, add_user_id
5
+ from stream_chat.base.exceptions import StreamChannelException
5
6
  from stream_chat.types.stream_response import StreamResponse
6
7
 
7
8
 
@@ -210,3 +211,40 @@ class Channel(ChannelInterface):
210
211
  "channel_cid": self.cid,
211
212
  }
212
213
  return self.client.post("moderation/unmute/channel", data=params)
214
+
215
+ def pin(self, user_id: str) -> StreamResponse:
216
+ if not user_id:
217
+ raise StreamChannelException("user_id must not be empty")
218
+
219
+ payload = {"set": {"pinned": True}}
220
+ return self.client.patch(f"{self.url}/member/{user_id}", data=payload)
221
+
222
+ def unpin(self, user_id: str) -> StreamResponse:
223
+ if not user_id:
224
+ raise StreamChannelException("user_id must not be empty")
225
+
226
+ payload = {"set": {"pinned": False}}
227
+ return self.client.patch(f"{self.url}/member/{user_id}", data=payload)
228
+
229
+ def archive(self, user_id: str) -> StreamResponse:
230
+ if not user_id:
231
+ raise StreamChannelException("user_id must not be empty")
232
+
233
+ payload = {"set": {"archived": True}}
234
+ return self.client.patch(f"{self.url}/member/{user_id}", data=payload)
235
+
236
+ def unarchive(self, user_id: str) -> StreamResponse:
237
+ if not user_id:
238
+ raise StreamChannelException("user_id must not be empty")
239
+
240
+ payload = {"set": {"archived": False}}
241
+ return self.client.patch(f"{self.url}/member/{user_id}", data=payload)
242
+
243
+ def update_member_partial(
244
+ self, user_id: str, to_set: Dict = None, to_unset: Iterable[str] = None
245
+ ) -> StreamResponse:
246
+ if not user_id:
247
+ raise StreamChannelException("user_id must not be empty")
248
+
249
+ payload = {"set": to_set or {}, "unset": to_unset or []}
250
+ return self.client.patch(f"{self.url}/member/{user_id}", data=payload)
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stream-chat
3
- Version: 4.19.0
3
+ Version: 4.20.0
4
4
  Summary: Client for Stream Chat.
5
5
  Home-page: https://github.com/GetStream/stream-chat-python
6
6
  Author: Tommaso Barbugli
7
7
  Author-email: support@getstream.io
8
8
  Project-URL: Bug Tracker, https://github.com/GetStream/stream-chat-python/issues
9
9
  Project-URL: Documentation, https://getstream.io/activity-feeds/docs/python/?language=python
10
- Project-URL: Release Notes, https://github.com/GetStream/stream-chat-python/releases/tag/v4.19.0
10
+ Project-URL: Release Notes, https://github.com/GetStream/stream-chat-python/releases/tag/v4.20.0
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Intended Audience :: System Administrators
13
13
  Classifier: Operating System :: OS Independent
@@ -1,18 +1,18 @@
1
1
  stream_chat/__init__.py,sha256=xYQuC8xcPLJxJnFWzaNaO-sVUc7IJZYe13OIPRaDBEA,116
2
- stream_chat/__pkg__.py,sha256=wO-i7ei-UR40ccvRBP_bEnEmY_H5yrmrmKqJ3hny_N8,206
2
+ stream_chat/__pkg__.py,sha256=nbHjOBD-I3lllsWmxhsUEY33qm1NUrxGwdeYQsEJczw,206
3
3
  stream_chat/campaign.py,sha256=Z7bBo2rGMs02JkA1k9_206J0spcSLecjdhQuRnrc2Eo,2156
4
- stream_chat/channel.py,sha256=FMX7dWHvljwE4P7d0fofL3dN63ihuWLvYHbFLSoIL4M,7952
4
+ stream_chat/channel.py,sha256=LnlHx1CDDnoxq4fCQ2sqlgjzIgPt0MmtKqph4240Uyg,9489
5
5
  stream_chat/client.py,sha256=sQH_Jkg06saa6BLtjXEwcu51GKdxtlqPDMGBL8jQAvY,29003
6
6
  stream_chat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  stream_chat/segment.py,sha256=MD1de83rVsaqxcyPy8wTXDudFjxz5Mvr70z4pTkW3P0,2691
8
8
  stream_chat/async_chat/__init__.py,sha256=V6x7yDCdXbP3vMuSan6Xm7RE_njZUvflImqOxfKRt4Y,67
9
9
  stream_chat/async_chat/campaign.py,sha256=Bc3iHZigxserUycZK4wDuXU0wXVH2G6fIDiYNVYPkeE,1885
10
- stream_chat/async_chat/channel.py,sha256=vJRyMV0p19a911sOdRQtkzoJxlwQxRpA7_aWkCfcRlk,8322
10
+ stream_chat/async_chat/channel.py,sha256=-n-Fq3MrIhGy6DzyHwOOHijSrDAudUxV0Akp-OVn7V0,9919
11
11
  stream_chat/async_chat/client.py,sha256=X7GagduhTgwac8jugISwZxdBAijq14rTzaKWiTS9Q8k,31260
12
12
  stream_chat/async_chat/segment.py,sha256=G_YEwW2SXIE7huTW3Zu_rim2XkYcuFNYekLZZGDjFkA,2777
13
13
  stream_chat/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  stream_chat/base/campaign.py,sha256=dAVkTYyirEpgyOPn8JyDebNMKeJu02vTuqgmPvdQoWU,1449
15
- stream_chat/base/channel.py,sha256=Jwsfuac2aU6Yipc8ven8U77iTGXIyA1b2WqZfIjB0SA,14315
15
+ stream_chat/base/channel.py,sha256=bK-bbDFQquPskktXSu3UspWgOsH0EOBaHVpyg4vt2VM,15684
16
16
  stream_chat/base/client.py,sha256=LRV136gyHAt4LkVct8wvpWYwQJ6hvcB4swz3b6AKihA,41387
17
17
  stream_chat/base/exceptions.py,sha256=eh1qW5d6zjUrlgsHNEBebAr0jVH2UupZ06w8sp2cseI,819
18
18
  stream_chat/base/segment.py,sha256=X82DX8Y-cERJ1OvF2tz9iIM4CBNW6tx8HGaTEXBva9I,2364
@@ -22,8 +22,8 @@ stream_chat/types/campaign.py,sha256=JyAn08oMaEsxPSqmVTdsfJK4xpfErPQV7Xr7zLQm99M
22
22
  stream_chat/types/rate_limit.py,sha256=v3Z4Ur0yoEdFLiHa1CNABEej2nxPlHQ6Bpy2XxW-TYQ,165
23
23
  stream_chat/types/segment.py,sha256=KzOi5N-VzLfj0m4zeZ9U_29ey9dxDtewtcNv9g4Aums,1273
24
24
  stream_chat/types/stream_response.py,sha256=jWKPrOU7u6dZ2SyOK53uQCXTstrL1HshO9fA7R6Bt_A,2391
25
- stream_chat-4.19.0.dist-info/LICENSE,sha256=H66SBDuPWSRHzKPEdyjAk3C0THQRcGPfqqve4naQuu0,14424
26
- stream_chat-4.19.0.dist-info/METADATA,sha256=LBWGUmMdeUP5TV7VqmaPH9RKQUSAYQ0EW0aO5raCiUI,7405
27
- stream_chat-4.19.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
28
- stream_chat-4.19.0.dist-info/top_level.txt,sha256=26uTfg4bWcEaFrVKlzGGgfONH1p5DDe21G07EKfYSvo,12
29
- stream_chat-4.19.0.dist-info/RECORD,,
25
+ stream_chat-4.20.0.dist-info/LICENSE,sha256=H66SBDuPWSRHzKPEdyjAk3C0THQRcGPfqqve4naQuu0,14424
26
+ stream_chat-4.20.0.dist-info/METADATA,sha256=XDxL4bY8cfSqKSslYRxkpV4eaMeR3ifTVvmZE2ORum4,7405
27
+ stream_chat-4.20.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
28
+ stream_chat-4.20.0.dist-info/top_level.txt,sha256=26uTfg4bWcEaFrVKlzGGgfONH1p5DDe21G07EKfYSvo,12
29
+ stream_chat-4.20.0.dist-info/RECORD,,