Skip to content

Commit 22d890b

Browse files
committed
Add missing method: delete_channel
1 parent fd24f81 commit 22d890b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

swibots/api/community/controllers/channel_controller.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ async def create_channel(self, channel: Channel) -> str:
2525
response = await self.client.post(BASE_PATH, data=channel.to_json_request())
2626
return response.data.get("result", {}).get("channelId")
2727

28+
async def delete_channel(self, channel_id: str) -> str:
29+
response = await self.client.delete(f"{BASE_PATH}/{channel_id}")
30+
# return response.data.get("result", {}).get("channelId")
31+
return (
32+
"Successfully deleted the channel."
33+
if response.status_code == 200
34+
else response.data.get("errorMessage")
35+
)
36+
2837
async def update_channel(self, channel: Channel) -> str:
2938
response = await self.client.put(BASE_PATH, data=channel.to_json_request())
3039
return response.data.get("result", {}).get("channelId")

swibots/api/community/methods/channel_methods.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ async def update_channel(self: "swibots.ApiClient", channel: Channel) -> str:
3737
"""
3838
return await self.community_service.channels.update_channel(channel)
3939

40+
async def delete_channel(self: "swibots.ApiClient", id: str) -> str:
41+
"""Delete channel
42+
43+
Args:
44+
:obj:`swibots.api.community.models.Channel`: The channel object.
45+
46+
Returns:
47+
str: status of channel
48+
49+
Raises:
50+
:obj:`switch.error.SwitchError`: If the channel could not be retrieved
51+
52+
This method does the same as :meth:`switch.api.community.controllers.ChannelController.delete_channel`.
53+
"""
54+
return await self.community_service.channels.delete_channel(id)
55+
4056
async def get_all_channels(
4157
self: "swibots.ApiClient", community_id: str
4258
) -> List[Channel]:

0 commit comments

Comments
 (0)