File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ class PageInfo:
121
121
122
122
url : URL | NotGiven
123
123
params : Query | NotGiven
124
+ json : Body | NotGiven
124
125
125
126
@overload
126
127
def __init__ (
@@ -136,19 +137,30 @@ def __init__(
136
137
params : Query ,
137
138
) -> None : ...
138
139
140
+ @overload
141
+ def __init__ (
142
+ self ,
143
+ * ,
144
+ json : Body ,
145
+ ) -> None : ...
146
+
139
147
def __init__ (
140
148
self ,
141
149
* ,
142
150
url : URL | NotGiven = NOT_GIVEN ,
151
+ json : Body | NotGiven = NOT_GIVEN ,
143
152
params : Query | NotGiven = NOT_GIVEN ,
144
153
) -> None :
145
154
self .url = url
155
+ self .json = json
146
156
self .params = params
147
157
148
158
@override
149
159
def __repr__ (self ) -> str :
150
160
if self .url :
151
161
return f"{ self .__class__ .__name__ } (url={ self .url } )"
162
+ if self .json :
163
+ return f"{ self .__class__ .__name__ } (json={ self .json } )"
152
164
return f"{ self .__class__ .__name__ } (params={ self .params } )"
153
165
154
166
@@ -197,6 +209,19 @@ def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
197
209
options .url = str (url )
198
210
return options
199
211
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
+
200
225
raise ValueError ("Unexpected PageInfo state" )
201
226
202
227
You can’t perform that action at this time.
0 commit comments