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 @@ -121,6 +121,7 @@ class PageInfo:
121121
122122 url : URL | NotGiven
123123 params : Query | NotGiven
124+ json : Body | NotGiven
124125
125126 @overload
126127 def __init__ (
@@ -136,19 +137,30 @@ def __init__(
136137 params : Query ,
137138 ) -> None : ...
138139
140+ @overload
141+ def __init__ (
142+ self ,
143+ * ,
144+ json : Body ,
145+ ) -> None : ...
146+
139147 def __init__ (
140148 self ,
141149 * ,
142150 url : URL | NotGiven = NOT_GIVEN ,
151+ json : Body | NotGiven = NOT_GIVEN ,
143152 params : Query | NotGiven = NOT_GIVEN ,
144153 ) -> None :
145154 self .url = url
155+ self .json = json
146156 self .params = params
147157
148158 @override
149159 def __repr__ (self ) -> str :
150160 if self .url :
151161 return f"{ self .__class__ .__name__ } (url={ self .url } )"
162+ if self .json :
163+ return f"{ self .__class__ .__name__ } (json={ self .json } )"
152164 return f"{ self .__class__ .__name__ } (params={ self .params } )"
153165
154166
@@ -197,6 +209,19 @@ def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
197209 options .url = str (url )
198210 return options
199211
212+ if not isinstance (info .json , NotGiven ):
213+ if not is_mapping (info .json ):
214+ raise TypeError ("Pagination is only supported with mappings" )
215+
216+ if not options .json_data :
217+ options .json_data = {** info .json }
218+ else :
219+ if not is_mapping (options .json_data ):
220+ raise TypeError ("Pagination is only supported with mappings" )
221+
222+ options .json_data = {** options .json_data , ** info .json }
223+ return options
224+
200225 raise ValueError ("Unexpected PageInfo state" )
201226
202227
You can’t perform that action at this time.
0 commit comments