7
7
from office365 .runtime .http .http_method import HttpMethod
8
8
from office365 .runtime .http .request_options import RequestOptions
9
9
from office365 .runtime .odata .v3 .json_light_format import JsonLightFormat
10
+ from office365 .runtime .paths .service_operation import ServiceOperationPath
10
11
from office365 .runtime .queries .create_entity import CreateEntityQuery
11
12
from office365 .runtime .queries .delete_entity import DeleteEntityQuery
12
13
from office365 .runtime .queries .service_operation import ServiceOperationQuery
@@ -61,15 +62,18 @@ def process_response(self, response, query):
61
62
if isinstance (return_type , ClientResult ):
62
63
return_type .set_property ("__value" , response .content )
63
64
else :
64
- if isinstance (query , ServiceOperationQuery ) and isinstance (json_format , JsonLightFormat ):
65
- json_format .function = query .method_name
65
+ if isinstance (json_format , JsonLightFormat ):
66
+ if isinstance (query , ServiceOperationQuery ):
67
+ json_format .function = query .method_name
68
+ elif isinstance (return_type .resource_path , ServiceOperationPath ):
69
+ json_format .function = return_type .resource_path .name
66
70
67
71
self .map_json (response .json (), return_type , json_format )
68
72
69
73
def map_json (self , json , return_type , json_format = None ):
70
74
"""
71
75
:type json: any
72
- :type return_type: ClientValue or ClientResult or ClientObject
76
+ :type return_type: ClientValue or ClientResult or ClientObject
73
77
:type json_format: office365.runtime.odata.json_format.ODataJsonFormat
74
78
"""
75
79
if json_format is None :
@@ -81,16 +85,14 @@ def map_json(self, json, return_type, json_format=None):
81
85
82
86
def _next_property (self , json , json_format ):
83
87
"""
84
- :type json: any
88
+ :type json: Any
85
89
:type json_format: office365.runtime.odata.json_format.ODataJsonFormat
86
90
"""
87
91
if isinstance (json_format , JsonLightFormat ):
88
92
json = json .get (json_format .security , json )
89
93
json = json .get (json_format .function , json )
90
94
91
- if not isinstance (json , dict ):
92
- yield "__value" , json
93
- else :
95
+ if isinstance (json , dict ):
94
96
next_link_url = json .get (json_format .collection_next , None )
95
97
json = json .get (json_format .collection , json )
96
98
if next_link_url :
@@ -114,13 +116,16 @@ def _next_property(self, json, json_format):
114
116
yield name , value
115
117
else :
116
118
yield "__value" , json
119
+ elif json is not None :
120
+ yield "__value" , json
117
121
118
122
def _build_payload (self , query ):
119
123
"""
120
124
Normalizes OData request payload
121
125
122
126
:type query: office365.runtime.queries.client_query.ClientQuery
123
127
"""
128
+
124
129
def _normalize_payload (payload ):
125
130
if isinstance (payload , ClientObject ) or isinstance (payload , ClientValue ):
126
131
return payload .to_json (self ._default_json_format )
0 commit comments