Skip to content

Commit

Permalink
changes from setup.py validate
Browse files Browse the repository at this point in the history
  • Loading branch information
ruberVulpes authored and seratch committed Aug 13, 2020
1 parent 57921b5 commit 22ab1d9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
35 changes: 26 additions & 9 deletions slack/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ async def views_open(
return await self.api_call("views.open", json=kwargs)

async def views_push(
self, *, trigger_id: str, view: dict, **kwargs
self, *, trigger_id: str, view: Union[dict, View], **kwargs
) -> AsyncSlackResponse:
"""Push a view onto the stack of a root view.
Expand All @@ -2059,13 +2059,22 @@ async def views_push(
Args:
trigger_id (str): Exchange a trigger to post to the user.
e.g. '12345.98765.abcd2358fdea'
view (dict): The view payload.
view (dict or View): The view payload.
"""
kwargs.update({"trigger_id": trigger_id, "view": view})
kwargs.update({"trigger_id": trigger_id})
if isinstance(view, View):
kwargs.update({"view": view.to_dict()})
else:
kwargs.update({"view": view})
return await self.api_call("views.push", json=kwargs)

async def views_update(
self, *, view: dict, external_id: str = None, view_id: str = None, **kwargs
self,
*,
view: Union[dict, View],
external_id: str = None,
view_id: str = None,
**kwargs
) -> AsyncSlackResponse:
"""Update an existing view.
Expand All @@ -2076,26 +2085,30 @@ async def views_update(
to learn more about updating views and avoiding race conditions with the hash argument.
Args:
view (dict): The view payload.
view (dict or View): The view payload.
external_id (str): A unique identifier of the view set by the developer.
e.g. 'bmarley_view2'
view_id (str): A unique identifier of the view to be updated.
e.g. 'VMM512F2U'
Raises:
SlackRequestError: Either view_id or external_id is required.
"""
kwargs.update({"view": view})
if external_id:
kwargs.update({"external_id": external_id})
elif view_id:
kwargs.update({"view_id": view_id})
else:
raise e.SlackRequestError("Either view_id or external_id is required.")

if isinstance(view, View):
kwargs.update({"view": view.to_dict()})
else:
kwargs.update({"view": view})

return await self.api_call("views.update", json=kwargs)

async def views_publish(
self, *, user_id: str, view: dict, **kwargs
self, *, user_id: str, view: Union[dict, View], **kwargs
) -> AsyncSlackResponse:
"""Publish a static view for a User.
Create or update the view that comprises an
Expand All @@ -2104,7 +2117,11 @@ async def views_publish(
Args:
user_id (str): id of the user you want publish a view to.
e.g. 'U0BPQUNTA'
view (dict): The view payload.
view (dict or View): The view payload.
"""
kwargs.update({"user_id": user_id, "view": view})
kwargs.update({"user_id": user_id})
if isinstance(view, View):
kwargs.update({"view": view.to_dict()})
else:
kwargs.update({"view": view})
return await self.api_call("views.publish", json=kwargs)
7 changes: 6 additions & 1 deletion slack/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,12 @@ def views_push(
return self.api_call("views.push", json=kwargs)

def views_update(
self, *, view: Union[dict, View], external_id: str = None, view_id: str = None, **kwargs
self,
*,
view: Union[dict, View],
external_id: str = None,
view_id: str = None,
**kwargs
) -> Union[Future, SlackResponse]:
"""Update an existing view.
Expand Down

0 comments on commit 22ab1d9

Please sign in to comment.