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 @@ -120,6 +120,7 @@ class PageInfo:
120
120
121
121
url : URL | NotGiven
122
122
params : Query | NotGiven
123
+ json : Body | NotGiven
123
124
124
125
@overload
125
126
def __init__ (
@@ -135,19 +136,30 @@ def __init__(
135
136
params : Query ,
136
137
) -> None : ...
137
138
139
+ @overload
140
+ def __init__ (
141
+ self ,
142
+ * ,
143
+ json : Body ,
144
+ ) -> None : ...
145
+
138
146
def __init__ (
139
147
self ,
140
148
* ,
141
149
url : URL | NotGiven = NOT_GIVEN ,
150
+ json : Body | NotGiven = NOT_GIVEN ,
142
151
params : Query | NotGiven = NOT_GIVEN ,
143
152
) -> None :
144
153
self .url = url
154
+ self .json = json
145
155
self .params = params
146
156
147
157
@override
148
158
def __repr__ (self ) -> str :
149
159
if self .url :
150
160
return f"{ self .__class__ .__name__ } (url={ self .url } )"
161
+ if self .json :
162
+ return f"{ self .__class__ .__name__ } (json={ self .json } )"
151
163
return f"{ self .__class__ .__name__ } (params={ self .params } )"
152
164
153
165
@@ -196,6 +208,19 @@ def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
196
208
options .url = str (url )
197
209
return options
198
210
211
+ if not isinstance (info .json , NotGiven ):
212
+ if not is_mapping (info .json ):
213
+ raise TypeError ("Pagination is only supported with mappings" )
214
+
215
+ if not options .json_data :
216
+ options .json_data = {** info .json }
217
+ else :
218
+ if not is_mapping (options .json_data ):
219
+ raise TypeError ("Pagination is only supported with mappings" )
220
+
221
+ options .json_data = {** options .json_data , ** info .json }
222
+ return options
223
+
199
224
raise ValueError ("Unexpected PageInfo state" )
200
225
201
226
You can’t perform that action at this time.
0 commit comments