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 @@ -119,6 +119,7 @@ class PageInfo:
119
119
120
120
url : URL | NotGiven
121
121
params : Query | NotGiven
122
+ json : Body | NotGiven
122
123
123
124
@overload
124
125
def __init__ (
@@ -134,19 +135,30 @@ def __init__(
134
135
params : Query ,
135
136
) -> None : ...
136
137
138
+ @overload
139
+ def __init__ (
140
+ self ,
141
+ * ,
142
+ json : Body ,
143
+ ) -> None : ...
144
+
137
145
def __init__ (
138
146
self ,
139
147
* ,
140
148
url : URL | NotGiven = NOT_GIVEN ,
149
+ json : Body | NotGiven = NOT_GIVEN ,
141
150
params : Query | NotGiven = NOT_GIVEN ,
142
151
) -> None :
143
152
self .url = url
153
+ self .json = json
144
154
self .params = params
145
155
146
156
@override
147
157
def __repr__ (self ) -> str :
148
158
if self .url :
149
159
return f"{ self .__class__ .__name__ } (url={ self .url } )"
160
+ if self .json :
161
+ return f"{ self .__class__ .__name__ } (json={ self .json } )"
150
162
return f"{ self .__class__ .__name__ } (params={ self .params } )"
151
163
152
164
@@ -195,6 +207,19 @@ def _info_to_options(self, info: PageInfo) -> FinalRequestOptions:
195
207
options .url = str (url )
196
208
return options
197
209
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
+
198
223
raise ValueError ("Unexpected PageInfo state" )
199
224
200
225
You can’t perform that action at this time.
0 commit comments