Skip to content

Commit 2e77ff7

Browse files
committed
fix batch response item issues
1 parent 3c1d998 commit 2e77ff7

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/msgraph_core/requests/batch_response_item.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
from typing import Optional, Dict, Any
1+
from typing import Optional, Dict, Any, Callable
22
from io import BytesIO
33

44
from kiota_abstractions.serialization import Parsable, ParsableFactory
55
from kiota_abstractions.serialization import ParseNode
66
from kiota_abstractions.serialization import SerializationWriter
77

88

9-
class StreamInterface(BytesIO):
10-
pass
11-
12-
139
class BatchResponseItem(Parsable):
1410

1511
def __init__(self) -> None:
@@ -24,7 +20,7 @@ def __init__(self) -> None:
2420

2521
@property
2622
def id(self) -> Optional[str]:
27-
"""
23+
"""
2824
Get the ID of the response
2925
:return: The ID of the response
3026
:rtype: Optional[str]
@@ -69,7 +65,7 @@ def status(self) -> Optional[int]:
6965

7066
@status.setter
7167
def status(self, status_code: Optional[int]) -> None:
72-
"""
68+
"""
7369
Set the status code of the response
7470
:param status_code: The status code of the response
7571
:type status_code: Optional[int]
@@ -104,7 +100,7 @@ def body(self) -> Optional[BytesIO]:
104100
return self._body
105101

106102
@body.setter
107-
def body(self, body: Optional[StreamInterface]) -> None:
103+
def body(self, body: Optional[BytesIO]) -> None:
108104
"""
109105
Set the body of the response
110106
:param body: The body of the response
@@ -138,15 +134,15 @@ def create_from_discriminator_value(
138134
raise TypeError("parse_node cannot be null")
139135
return BatchResponseItem()
140136

141-
def get_field_deserializers(self) -> Dict[str, Any]:
137+
def get_field_deserializers(self) -> Dict[str, Callable[[ParseNode], None]]:
142138
"""
143139
Gets the deserialization information for this object.
144140
145141
"""
146142
return {
147143
"id": lambda x: setattr(self, "id", x.get_str_value()),
148144
"status": lambda x: setattr(self, "status", x.get_int_value()),
149-
"headers": lambda x: setattr(self, "headers", x.try_get_anything(x._json_node)),
145+
"headers": lambda x: setattr(self, "headers", x.try_get_anything(x._json_node)), # type: ignore # need interface to return a dictionary
150146
"body": lambda x: setattr(self, "body", x.get_bytes_value()),
151147
}
152148

@@ -157,5 +153,8 @@ def serialize(self, writer: SerializationWriter) -> None:
157153
writer.write_str_value('id', self._id)
158154
writer.write_str_value('atomicity_group', self._atomicity_group)
159155
writer.write_int_value('status', self._status)
160-
writer.write_collection_of_primitive_values('headers', self._headers)
161-
writer.write_bytes_value('body', self._body)
156+
writer.write_collection_of_primitive_values('headers', self._headers) # type: ignore # need method to serialize dicts
157+
if self._body:
158+
writer.write_bytes_value('body', self._body.getvalue())
159+
else:
160+
writer.write_bytes_value('body', None)

0 commit comments

Comments
 (0)