@@ -2276,7 +2276,7 @@ def views_open(
22762276 return self .api_call ("views.open" , json = kwargs )
22772277
22782278 def views_push (
2279- self , * , trigger_id : str , view : dict , ** kwargs
2279+ self , * , trigger_id : str , view : Union [ dict , View ] , ** kwargs
22802280 ) -> Union [Future , SlackResponse ]:
22812281 """Push a view onto the stack of a root view.
22822282
@@ -2290,13 +2290,22 @@ def views_push(
22902290 Args:
22912291 trigger_id (str): Exchange a trigger to post to the user.
22922292 e.g. '12345.98765.abcd2358fdea'
2293- view (dict): The view payload.
2293+ view (dict or View ): The view payload.
22942294 """
22952295 kwargs .update ({"trigger_id" : trigger_id , "view" : view })
2296+ if isinstance (view , View ):
2297+ kwargs .update ({"view" : view .to_dict ()})
2298+ else :
2299+ kwargs .update ({"view" : view })
22962300 return self .api_call ("views.push" , json = kwargs )
22972301
22982302 def views_update (
2299- self , * , view : dict , external_id : str = None , view_id : str = None , ** kwargs
2303+ self ,
2304+ * ,
2305+ view : Union [dict , View ],
2306+ external_id : str = None ,
2307+ view_id : str = None ,
2308+ ** kwargs
23002309 ) -> Union [Future , SlackResponse ]:
23012310 """Update an existing view.
23022311
@@ -2307,15 +2316,18 @@ def views_update(
23072316 to learn more about updating views and avoiding race conditions with the hash argument.
23082317
23092318 Args:
2310- view (dict): The view payload.
2319+ view (dict or View ): The view payload.
23112320 external_id (str): A unique identifier of the view set by the developer.
23122321 e.g. 'bmarley_view2'
23132322 view_id (str): A unique identifier of the view to be updated.
23142323 e.g. 'VMM512F2U'
23152324 Raises:
23162325 SlackRequestError: Either view_id or external_id is required.
23172326 """
2318- kwargs .update ({"view" : view })
2327+ if isinstance (view , View ):
2328+ kwargs .update ({"view" : view .to_dict ()})
2329+ else :
2330+ kwargs .update ({"view" : view })
23192331 if external_id :
23202332 kwargs .update ({"external_id" : external_id })
23212333 elif view_id :
@@ -2326,7 +2338,7 @@ def views_update(
23262338 return self .api_call ("views.update" , json = kwargs )
23272339
23282340 def views_publish (
2329- self , * , user_id : str , view : dict , ** kwargs
2341+ self , * , user_id : str , view : Union [ dict , View ] , ** kwargs
23302342 ) -> Union [Future , SlackResponse ]:
23312343 """Publish a static view for a User.
23322344 Create or update the view that comprises an
@@ -2335,9 +2347,13 @@ def views_publish(
23352347 Args:
23362348 user_id (str): id of the user you want publish a view to.
23372349 e.g. 'U0BPQUNTA'
2338- view (dict): The view payload.
2350+ view (dict or View ): The view payload.
23392351 """
2340- kwargs .update ({"user_id" : user_id , "view" : view })
2352+ kwargs .update ({"user_id" : user_id })
2353+ if isinstance (view , View ):
2354+ kwargs .update ({"view" : view .to_dict ()})
2355+ else :
2356+ kwargs .update ({"view" : view })
23412357 return self .api_call ("views.publish" , json = kwargs )
23422358
23432359 def workflows_stepCompleted (
0 commit comments