From 62982e3be35e0150194c23f45a53c7174587ef6a Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Tue, 14 Nov 2023 11:42:24 +0100 Subject: [PATCH 1/4] feat: add type support in create_blocklist() payload --- stream_chat/async_chat/client.py | 4 ++-- stream_chat/base/client.py | 3 ++- stream_chat/client.py | 4 ++-- stream_chat/tests/test_client.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/stream_chat/async_chat/client.py b/stream_chat/async_chat/client.py index e57c144..a855554 100644 --- a/stream_chat/async_chat/client.py +++ b/stream_chat/async_chat/client.py @@ -472,8 +472,8 @@ async def send_file( ) as response: return await self._parse_response(response) - async def create_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse: - return await self.post("blocklists", data={"name": name, "words": words}) + async def create_blocklist(self, name: str, words: Iterable[str], blocklist_type: str = None) -> StreamResponse: + return await self.post("blocklists", data={"name": name, "words": words, "type": blocklist_type}) async def list_blocklists(self) -> StreamResponse: return await self.get("blocklists") diff --git a/stream_chat/base/client.py b/stream_chat/base/client.py index e325b60..44f0446 100644 --- a/stream_chat/base/client.py +++ b/stream_chat/base/client.py @@ -753,13 +753,14 @@ def send_file( @abc.abstractmethod def create_blocklist( - self, name: str, words: Iterable[str] + self, name: str, words: Iterable[str], blocklist_type: str = None ) -> Union[StreamResponse, Awaitable[StreamResponse]]: """ Create a blocklist :param name: the name of the blocklist :param words: list of blocked words + :param blocklist_type: blocklist type :return: """ pass diff --git a/stream_chat/client.py b/stream_chat/client.py index badaf4c..c90feb4 100644 --- a/stream_chat/client.py +++ b/stream_chat/client.py @@ -456,8 +456,8 @@ def send_file( ) return self._parse_response(response) - def create_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse: - return self.post("blocklists", data={"name": name, "words": words}) + def create_blocklist(self, name: str, words: Iterable[str], blocklist_type: str = None) -> StreamResponse: + return self.post("blocklists", data={"name": name, "words": words, "type": blocklist_type}) def list_blocklists(self) -> StreamResponse: return self.get("blocklists") diff --git a/stream_chat/tests/test_client.py b/stream_chat/tests/test_client.py index f3b0564..21db613 100644 --- a/stream_chat/tests/test_client.py +++ b/stream_chat/tests/test_client.py @@ -549,7 +549,7 @@ def test_query_channels_members_in( assert len(response["channels"][0]["members"]) == 9 def test_create_blocklist(self, client: StreamChat): - client.create_blocklist(name="Foo", words=["fudge", "heck"]) + client.create_blocklist(name="Foo", words=["fudge", "heck"], blocklist_type="regular") def test_list_blocklists(self, client: StreamChat): response = client.list_blocklists() From 383fbb6045ca625ceaab1f37d6958248a22eac42 Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Tue, 14 Nov 2023 12:53:56 +0100 Subject: [PATCH 2/4] feat: fix linters --- stream_chat/async_chat/client.py | 8 ++++++-- stream_chat/client.py | 8 ++++++-- stream_chat/tests/test_client.py | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/stream_chat/async_chat/client.py b/stream_chat/async_chat/client.py index a855554..1a31ac4 100644 --- a/stream_chat/async_chat/client.py +++ b/stream_chat/async_chat/client.py @@ -472,8 +472,12 @@ async def send_file( ) as response: return await self._parse_response(response) - async def create_blocklist(self, name: str, words: Iterable[str], blocklist_type: str = None) -> StreamResponse: - return await self.post("blocklists", data={"name": name, "words": words, "type": blocklist_type}) + async def create_blocklist( + self, name: str, words: Iterable[str], blocklist_type: str = None + ) -> StreamResponse: + return await self.post( + "blocklists", data={"name": name, "words": words, "type": blocklist_type} + ) async def list_blocklists(self) -> StreamResponse: return await self.get("blocklists") diff --git a/stream_chat/client.py b/stream_chat/client.py index c90feb4..fdba200 100644 --- a/stream_chat/client.py +++ b/stream_chat/client.py @@ -456,8 +456,12 @@ def send_file( ) return self._parse_response(response) - def create_blocklist(self, name: str, words: Iterable[str], blocklist_type: str = None) -> StreamResponse: - return self.post("blocklists", data={"name": name, "words": words, "type": blocklist_type}) + def create_blocklist( + self, name: str, words: Iterable[str], blocklist_type: str = None + ) -> StreamResponse: + return self.post( + "blocklists", data={"name": name, "words": words, "type": blocklist_type} + ) def list_blocklists(self) -> StreamResponse: return self.get("blocklists") diff --git a/stream_chat/tests/test_client.py b/stream_chat/tests/test_client.py index 21db613..5ceff7c 100644 --- a/stream_chat/tests/test_client.py +++ b/stream_chat/tests/test_client.py @@ -549,7 +549,9 @@ def test_query_channels_members_in( assert len(response["channels"][0]["members"]) == 9 def test_create_blocklist(self, client: StreamChat): - client.create_blocklist(name="Foo", words=["fudge", "heck"], blocklist_type="regular") + client.create_blocklist( + name="Foo", words=["fudge", "heck"], blocklist_type="regular" + ) def test_list_blocklists(self, client: StreamChat): response = client.list_blocklists() From 1167cd8ca3b42f510f23992ec7106e8dee71e84e Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Thu, 16 Nov 2023 15:47:31 +0100 Subject: [PATCH 3/4] feat: rename param to type in payload --- stream_chat/async_chat/client.py | 4 ++-- stream_chat/base/client.py | 4 ++-- stream_chat/client.py | 4 ++-- stream_chat/tests/test_client.py | 4 +--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/stream_chat/async_chat/client.py b/stream_chat/async_chat/client.py index 1a31ac4..debe1cb 100644 --- a/stream_chat/async_chat/client.py +++ b/stream_chat/async_chat/client.py @@ -473,10 +473,10 @@ async def send_file( return await self._parse_response(response) async def create_blocklist( - self, name: str, words: Iterable[str], blocklist_type: str = None + self, name: str, words: Iterable[str], type: str = None ) -> StreamResponse: return await self.post( - "blocklists", data={"name": name, "words": words, "type": blocklist_type} + "blocklists", data={"name": name, "words": words, "type": type} ) async def list_blocklists(self) -> StreamResponse: diff --git a/stream_chat/base/client.py b/stream_chat/base/client.py index 44f0446..454e0bb 100644 --- a/stream_chat/base/client.py +++ b/stream_chat/base/client.py @@ -753,14 +753,14 @@ def send_file( @abc.abstractmethod def create_blocklist( - self, name: str, words: Iterable[str], blocklist_type: str = None + self, name: str, words: Iterable[str], type: str = None ) -> Union[StreamResponse, Awaitable[StreamResponse]]: """ Create a blocklist :param name: the name of the blocklist :param words: list of blocked words - :param blocklist_type: blocklist type + :param type: blocklist type :return: """ pass diff --git a/stream_chat/client.py b/stream_chat/client.py index fdba200..d2aa44c 100644 --- a/stream_chat/client.py +++ b/stream_chat/client.py @@ -457,10 +457,10 @@ def send_file( return self._parse_response(response) def create_blocklist( - self, name: str, words: Iterable[str], blocklist_type: str = None + self, name: str, words: Iterable[str], type: str = None ) -> StreamResponse: return self.post( - "blocklists", data={"name": name, "words": words, "type": blocklist_type} + "blocklists", data={"name": name, "words": words, "type": type} ) def list_blocklists(self) -> StreamResponse: diff --git a/stream_chat/tests/test_client.py b/stream_chat/tests/test_client.py index 5ceff7c..97ca9c4 100644 --- a/stream_chat/tests/test_client.py +++ b/stream_chat/tests/test_client.py @@ -549,9 +549,7 @@ def test_query_channels_members_in( assert len(response["channels"][0]["members"]) == 9 def test_create_blocklist(self, client: StreamChat): - client.create_blocklist( - name="Foo", words=["fudge", "heck"], blocklist_type="regular" - ) + client.create_blocklist(name="Foo", words=["fudge", "heck"], type="regular") def test_list_blocklists(self, client: StreamChat): response = client.list_blocklists() From 7b8b8275cc9926cd97d7b109f9865a94637e6597 Mon Sep 17 00:00:00 2001 From: Viktor Apostolski Date: Mon, 20 Nov 2023 13:22:00 +0100 Subject: [PATCH 4/4] change to explicit regular type as default --- stream_chat/async_chat/client.py | 2 +- stream_chat/base/client.py | 2 +- stream_chat/client.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stream_chat/async_chat/client.py b/stream_chat/async_chat/client.py index debe1cb..bf28d93 100644 --- a/stream_chat/async_chat/client.py +++ b/stream_chat/async_chat/client.py @@ -473,7 +473,7 @@ async def send_file( return await self._parse_response(response) async def create_blocklist( - self, name: str, words: Iterable[str], type: str = None + self, name: str, words: Iterable[str], type: str = "regular" ) -> StreamResponse: return await self.post( "blocklists", data={"name": name, "words": words, "type": type} diff --git a/stream_chat/base/client.py b/stream_chat/base/client.py index 454e0bb..11ceaa6 100644 --- a/stream_chat/base/client.py +++ b/stream_chat/base/client.py @@ -753,7 +753,7 @@ def send_file( @abc.abstractmethod def create_blocklist( - self, name: str, words: Iterable[str], type: str = None + self, name: str, words: Iterable[str], type: str = "regular" ) -> Union[StreamResponse, Awaitable[StreamResponse]]: """ Create a blocklist diff --git a/stream_chat/client.py b/stream_chat/client.py index d2aa44c..c0cd5e4 100644 --- a/stream_chat/client.py +++ b/stream_chat/client.py @@ -457,7 +457,7 @@ def send_file( return self._parse_response(response) def create_blocklist( - self, name: str, words: Iterable[str], type: str = None + self, name: str, words: Iterable[str], type: str = "regular" ) -> StreamResponse: return self.post( "blocklists", data={"name": name, "words": words, "type": type}