Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOD-337] added team parameter to blocklist endpoints #182

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions stream_chat/async_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,23 +503,42 @@ async def send_file(
return await self._parse_response(response)

async def create_blocklist(
self, name: str, words: Iterable[str], type: str = "word"
self,
name: str,
words: Iterable[str],
type: str = "word",
team: Optional[str] = None,
) -> StreamResponse:
params = {"team": team} if team is not None else {}
return await self.post(
"blocklists", data={"name": name, "words": words, "type": type}
"blocklists",
data={"name": name, "words": words, "type": type},
params=params,
)

async def list_blocklists(self) -> StreamResponse:
return await self.get("blocklists")
async def list_blocklists(self, team: Optional[str] = None) -> StreamResponse:
params = {"team": team} if team is not None else {}
return await self.get("blocklists", params)

async def get_blocklist(self, name: str) -> StreamResponse:
return await self.get(f"blocklists/{name}")
async def get_blocklist(
self, name: str, team: Optional[str] = None
) -> StreamResponse:
params = {"team": team} if team is not None else {}
return await self.get(f"blocklists/{name}", params)

async def update_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse:
return await self.put(f"blocklists/{name}", data={"words": words})
async def update_blocklist(
self, name: str, words: Iterable[str], team: Optional[str] = None
) -> StreamResponse:
params = {"team": team} if team is not None else {}
return await self.put(
f"blocklists/{name}", data={"words": words}, params=params
)

async def delete_blocklist(self, name: str) -> StreamResponse:
return await self.delete(f"blocklists/{name}")
async def delete_blocklist(
self, name: str, team: Optional[str] = None
) -> StreamResponse:
params = {"team": team} if team is not None else {}
return await self.delete(f"blocklists/{name}", params)

async def check_push(self, push_data: Dict) -> StreamResponse:
return await self.post("check_push", data=push_data)
Expand Down
33 changes: 23 additions & 10 deletions stream_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,23 +480,36 @@ def send_file(
return self._parse_response(response)

def create_blocklist(
self, name: str, words: Iterable[str], type: str = "word"
self,
name: str,
words: Iterable[str],
type: str = "word",
team: Optional[str] = None,
) -> StreamResponse:
params = {"team": team} if team is not None else {}
return self.post(
"blocklists", data={"name": name, "words": words, "type": type}
"blocklists",
data={"name": name, "words": words, "type": type},
params=params,
)

def list_blocklists(self) -> StreamResponse:
return self.get("blocklists")
def list_blocklists(self, team: Optional[str] = None) -> StreamResponse:
params = {"team": team} if team is not None else {}
return self.get("blocklists", params)

def get_blocklist(self, name: str) -> StreamResponse:
return self.get(f"blocklists/{name}")
def get_blocklist(self, name: str, team: Optional[str] = None) -> StreamResponse:
params = {"team": team} if team is not None else {}
return self.get(f"blocklists/{name}", params)

def update_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse:
return self.put(f"blocklists/{name}", data={"words": words})
def update_blocklist(
self, name: str, words: Iterable[str], team: Optional[str] = None
) -> StreamResponse:
params = {"team": team} if team is not None else {}
return self.put(f"blocklists/{name}", data={"words": words}, params=params)

def delete_blocklist(self, name: str) -> StreamResponse:
return self.delete(f"blocklists/{name}")
def delete_blocklist(self, name: str, team: Optional[str] = None) -> StreamResponse:
params = {"team": team} if team is not None else {}
return self.delete(f"blocklists/{name}", params)

def check_push(self, push_data: Dict) -> StreamResponse:
return self.post("check_push", data=push_data)
Expand Down
Loading