@@ -34,21 +34,29 @@ def __init__(self, request_adapter: RequestAdapter, error_map: Optional[Dict[str
3434 async def post (
3535 self ,
3636 batch_request_content : Union [BatchRequestContent , BatchRequestContentCollection ],
37+ response_type : Optional [T ] = None ,
3738 error_map : Optional [Dict [str , int ]] = None ,
38- ) -> BatchResponseContent :
39+ ) -> Union [ T , BatchResponseContentCollection ] :
3940 """
4041 Sends a batch request and returns the batch response content.
4142
4243 Args:
43- batch_request_content (BatchRequestContent): The batch request content.
44+ batch_request_content (Union[BatchRequestContent,
45+ BatchRequestContentCollection]): The batch request content.
46+ response_type (Optional[T]): The type to deserialize the response into.
4447 error_map: Dict[str, int] = {}:
4548 Error mappings for response handling.
4649
4750 Returns:
48- BatchResponseContent: The batch response content.
51+ Union[T, BatchResponseContentCollection]: The batch response content
52+ or the specified response type.
53+
4954 """
5055 if batch_request_content is None :
5156 raise ValueError ("batch_request_content cannot be Null." )
57+ if response_type is None :
58+ response_type = BatchResponseContent
59+
5260 if isinstance (batch_request_content , BatchRequestContent ):
5361 request_info = await self .to_post_request_information (batch_request_content )
5462 content = json .loads (request_info .content .decode ("utf-8" ))
@@ -58,7 +66,7 @@ async def post(
5866 response = None
5967 try :
6068 response = await self ._request_adapter .send_async (
61- request_info , BatchResponseContent , error_map
69+ request_info , response_type , error_map
6270 )
6371 except APIError as e :
6472 logging .error ("API Error: %s" , e )
0 commit comments