Skip to content

Commit 22ab1d9

Browse files
ruberVulpesseratch
authored andcommitted
changes from setup.py validate
1 parent 57921b5 commit 22ab1d9

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

slack/web/async_client.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@ async def views_open(
20452045
return await self.api_call("views.open", json=kwargs)
20462046

20472047
async def views_push(
2048-
self, *, trigger_id: str, view: dict, **kwargs
2048+
self, *, trigger_id: str, view: Union[dict, View], **kwargs
20492049
) -> AsyncSlackResponse:
20502050
"""Push a view onto the stack of a root view.
20512051
@@ -2059,13 +2059,22 @@ async def views_push(
20592059
Args:
20602060
trigger_id (str): Exchange a trigger to post to the user.
20612061
e.g. '12345.98765.abcd2358fdea'
2062-
view (dict): The view payload.
2062+
view (dict or View): The view payload.
20632063
"""
2064-
kwargs.update({"trigger_id": trigger_id, "view": view})
2064+
kwargs.update({"trigger_id": trigger_id})
2065+
if isinstance(view, View):
2066+
kwargs.update({"view": view.to_dict()})
2067+
else:
2068+
kwargs.update({"view": view})
20652069
return await self.api_call("views.push", json=kwargs)
20662070

20672071
async def views_update(
2068-
self, *, view: dict, external_id: str = None, view_id: str = None, **kwargs
2072+
self,
2073+
*,
2074+
view: Union[dict, View],
2075+
external_id: str = None,
2076+
view_id: str = None,
2077+
**kwargs
20692078
) -> AsyncSlackResponse:
20702079
"""Update an existing view.
20712080
@@ -2076,26 +2085,30 @@ async def views_update(
20762085
to learn more about updating views and avoiding race conditions with the hash argument.
20772086
20782087
Args:
2079-
view (dict): The view payload.
2088+
view (dict or View): The view payload.
20802089
external_id (str): A unique identifier of the view set by the developer.
20812090
e.g. 'bmarley_view2'
20822091
view_id (str): A unique identifier of the view to be updated.
20832092
e.g. 'VMM512F2U'
20842093
Raises:
20852094
SlackRequestError: Either view_id or external_id is required.
20862095
"""
2087-
kwargs.update({"view": view})
20882096
if external_id:
20892097
kwargs.update({"external_id": external_id})
20902098
elif view_id:
20912099
kwargs.update({"view_id": view_id})
20922100
else:
20932101
raise e.SlackRequestError("Either view_id or external_id is required.")
20942102

2103+
if isinstance(view, View):
2104+
kwargs.update({"view": view.to_dict()})
2105+
else:
2106+
kwargs.update({"view": view})
2107+
20952108
return await self.api_call("views.update", json=kwargs)
20962109

20972110
async def views_publish(
2098-
self, *, user_id: str, view: dict, **kwargs
2111+
self, *, user_id: str, view: Union[dict, View], **kwargs
20992112
) -> AsyncSlackResponse:
21002113
"""Publish a static view for a User.
21012114
Create or update the view that comprises an
@@ -2104,7 +2117,11 @@ async def views_publish(
21042117
Args:
21052118
user_id (str): id of the user you want publish a view to.
21062119
e.g. 'U0BPQUNTA'
2107-
view (dict): The view payload.
2120+
view (dict or View): The view payload.
21082121
"""
2109-
kwargs.update({"user_id": user_id, "view": view})
2122+
kwargs.update({"user_id": user_id})
2123+
if isinstance(view, View):
2124+
kwargs.update({"view": view.to_dict()})
2125+
else:
2126+
kwargs.update({"view": view})
21102127
return await self.api_call("views.publish", json=kwargs)

slack/web/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,12 @@ def views_push(
20672067
return self.api_call("views.push", json=kwargs)
20682068

20692069
def views_update(
2070-
self, *, view: Union[dict, View], external_id: str = None, view_id: str = None, **kwargs
2070+
self,
2071+
*,
2072+
view: Union[dict, View],
2073+
external_id: str = None,
2074+
view_id: str = None,
2075+
**kwargs
20712076
) -> Union[Future, SlackResponse]:
20722077
"""Update an existing view.
20732078

0 commit comments

Comments
 (0)