Skip to content

Commit 52998f2

Browse files
committed
add custom error_map optional parameter
1 parent 60bebdd commit 52998f2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/msgraph_core/requests/batch_request_builder.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ class BatchRequestBuilder:
2424
Provides operations to call the batch method.
2525
"""
2626

27-
def __init__(self, request_adapter: RequestAdapter, error_map: Optional[Dict[str, int]] = None):
27+
def __init__(
28+
self,
29+
request_adapter: RequestAdapter,
30+
error_map: Optional[Dict[str, Type[Parsable]]] = None
31+
):
2832
if request_adapter is None:
2933
raise ValueError("request_adapter cannot be Null.")
3034
self._request_adapter = request_adapter
@@ -35,7 +39,7 @@ async def post(
3539
self,
3640
batch_request_content: Union[BatchRequestContent, BatchRequestContentCollection],
3741
response_type: Optional[Type[T]] = None,
38-
error_map: Optional[Dict[str, int]] = None,
42+
error_map: Optional[Dict[str, Type[Parsable]]] = None,
3943
) -> Union[T, BatchResponseContentCollection]:
4044
"""
4145
Sends a batch request and returns the batch response content.
@@ -44,7 +48,7 @@ async def post(
4448
batch_request_content (Union[BatchRequestContent,
4549
BatchRequestContentCollection]): The batch request content.
4650
response_type: Optional[Type[T]] : The type to deserialize the response into.
47-
error_map: Dict[str, int] = {}:
51+
Optional[Dict[str, Type[Parsable]]] = None:
4852
Error mappings for response handling.
4953
5054
Returns:
@@ -83,15 +87,15 @@ async def post(
8387
async def post_batch_collection(
8488
self,
8589
batch_request_content_collection: BatchRequestContentCollection,
86-
error_map: Optional[Dict[str, int]] = None,
90+
error_map: Optional[Dict[str, Type[Parsable]]] = None,
8791
) -> BatchResponseContentCollection:
8892
"""
8993
Sends a collection of batch requests and returns a collection of batch response contents.
9094
9195
Args:
9296
batch_request_content_collection (BatchRequestContentCollection): The
9397
collection of batch request contents.
94-
error_map: Dict[str, int] = {}:
98+
Optional[Dict[str, Type[Parsable]]] = None:
9599
Error mappings for response handling.
96100
97101
Returns:
@@ -105,7 +109,7 @@ async def post_batch_collection(
105109
for batch_request_content in batch_request_content_collection.batches:
106110
request_info = await self.to_post_request_information(batch_request_content)
107111
response = await self._request_adapter.send_async(
108-
request_info, BatchResponseContent, error_map
112+
request_info, BatchResponseContent, error_map or self.error_map
109113
)
110114
batch_responses.add_response(response)
111115

0 commit comments

Comments
 (0)