Skip to content

Commit 18a77d2

Browse files
committed
allow passing a Parsable as response_type
1 parent 69dd264 commit 18a77d2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/msgraph_core/requests/batch_request_builder.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

src/msgraph_core/requests/batch_request_content.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BatchRequestContent(Parsable):
1313
Provides operations to call the batch method.
1414
"""
1515

16-
MAX_REQUESTS = 5
16+
MAX_REQUESTS = 20
1717

1818
def __init__(self, requests: List[Union['BatchRequestItem', 'RequestInformation']] = []):
1919
"""

0 commit comments

Comments
 (0)