File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ class PageInfo:
119119
120120 url : URL | NotGiven
121121 params : Query | NotGiven
122+ json : Body | NotGiven
122123
123124 @overload
124125 def __init__ (
@@ -134,19 +135,30 @@ def __init__(
134135 params : Query ,
135136 ) -> None : ...
136137
138+ @overload
139+ def __init__ (
140+ self ,
141+ * ,
142+ json : Body ,
143+ ) -> None : ...
144+
137145 def __init__ (
138146 self ,
139147 * ,
140148 url : URL | NotGiven = NOT_GIVEN ,
149+ json : Body | NotGiven = NOT_GIVEN ,
141150 params : Query | NotGiven = NOT_GIVEN ,
142151 ) -> None :
143152 self .url = url
153+ self .json = json
144154 self .params = params
145155
146156 @override
147157 def __repr__ (self ) -> str :
148158 if self .url :
149159 return f"{ self .__class__ .__name__ } (url={ self .url } )"
160+ if self .json :
161+ return f"{ self .__class__ .__name__ } (json={ self .json } )"
150162 return f"{ self .__class__ .__name__ } (params={ self .params } )"
151163
152164
@@ -195,6 +207,19 @@ def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
195207 options .url = str (url )
196208 return options
197209
210+ if not isinstance (info .json , NotGiven ):
211+ if not is_mapping (info .json ):
212+ raise TypeError ("Pagination is only supported with mappings" )
213+
214+ if not options .json_data :
215+ options .json_data = {** info .json }
216+ else :
217+ if not is_mapping (options .json_data ):
218+ raise TypeError ("Pagination is only supported with mappings" )
219+
220+ options .json_data = {** options .json_data , ** info .json }
221+ return options
222+
198223 raise ValueError ("Unexpected PageInfo state" )
199224
200225
You can’t perform that action at this time.
0 commit comments