@@ -168,7 +168,7 @@ protected <T> T handleFailResponse(Response response, Class<T> tClass) {
168
168
return null ;
169
169
}
170
170
171
- //protected JSONObject serialize(Response response) {
171
+ // protected JSONObject serialize(Response response) {
172
172
// ResponseBody body = response.body();
173
173
// if (body == null) {
174
174
// throw new HttpException("response body is null");
@@ -181,7 +181,7 @@ protected <T> T handleFailResponse(Response response, Class<T> tClass) {
181
181
// }
182
182
//}
183
183
184
- //protected JSONArray serializeList(Response response) {
184
+ // protected JSONArray serializeList(Response response) {
185
185
// ResponseBody body = response.body();
186
186
// if (body == null) {
187
187
// throw new HttpException("response body is null");
@@ -206,44 +206,61 @@ public <T> T get(String path, Map<String, Object> queryMap, Class<T> tClass) {
206
206
}
207
207
208
208
209
+ public JSONMapper get (String path , Pair <?>... queryParams ) {
210
+ Response response = get (path , (Map <String , Object >) null , queryParams );
211
+ return handleResponse (response , JSONMapper .class );
212
+ }
213
+
214
+ public JSONMapper get (String path , Map <String , Object > queryMap ) {
215
+ Response response = get (path , queryMap , (Pair <?>[]) null );
216
+ return handleResponse (response , JSONMapper .class );
217
+ }
218
+
219
+ public <T > List <T > getList (String path , Class <T > tClass , Pair <?>... queryParams ) {
220
+ Response response = get (path , (Map <String , Object >) null , queryParams );
221
+
222
+ return (List <T >) handleResponse (response , tClass , true );
223
+ }
224
+
225
+ public <T > List <T > getList (String path , Map <String , Object > queryMap , Class <T > tClass ) {
226
+ Response response = get (path , queryMap , (Pair <?>[]) null );
227
+ return (List <T >) handleResponse (response , tClass , true );
228
+ }
229
+
209
230
public <T > T postForm (String url , Map <String , Object > formParams , Class <T > tClass ) {
210
231
211
232
Response response = post (url , MediaTypeEnum .FORM , null , formParams , null );
212
233
return handleResponse (response , tClass );
213
234
}
214
235
215
- public <T > T postFormData (String url , Map <String , Object > formParams , Class <T > tClass ) {
236
+ public <T > T postForm (String url , Map <String , Object > formParams , Map < String , Object > headerParams , Class <T > tClass ) {
216
237
217
- Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
238
+ Response response = post (url , MediaTypeEnum .FORM , null , formParams , headerParams );
218
239
return handleResponse (response , tClass );
219
240
}
220
241
221
- public <T > T post (String url , Object body , Class <T > tClass ) {
242
+ public <T > T postFormData (String url , Map < String , Object > formParams , Class <T > tClass ) {
222
243
223
- Response response = post (url , MediaTypeEnum .JSON , body , null , null );
244
+ Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
224
245
return handleResponse (response , tClass );
225
246
}
226
247
248
+ public <T > T postFormData (String url , Map <String , Object > formParams , Map <String , Object > headerParams , Class <T > tClass ) {
227
249
228
- public JSONMapper get (String path , Pair <?>... queryParams ) {
229
- Response response = get (path , (Map <String , Object >) null , queryParams );
230
- return handleResponse (response , JSONMapper .class );
231
- }
232
-
233
- public JSONMapper get (String path , Map <String , Object > queryMap ) {
234
- Response response = get (path , queryMap , (Pair <?>[]) null );
235
- return handleResponse (response , JSONMapper .class );
250
+ Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , headerParams );
251
+ return handleResponse (response , tClass );
236
252
}
237
253
238
- public <T > List <T > getList (String path , Class <T > tClass , Pair <?>... queryParams ) {
239
- Response response = get (path , (Map <String , Object >) null , queryParams );
254
+ public <T > T post (String url , Object body , Class <T > tClass ) {
240
255
241
- return (List <T >) handleResponse (response , tClass , true );
256
+ Response response = post (url , MediaTypeEnum .JSON , body , null , null );
257
+ return handleResponse (response , tClass );
242
258
}
243
259
244
- public <T > List <T > getList (String path , Map <String , Object > queryMap , Class <T > tClass ) {
245
- Response response = get (path , queryMap , (Pair <?>[]) null );
246
- return (List <T >) handleResponse (response , tClass , true );
260
+ public <T > T post (String url , Object body , Map <String , Object > headerParams , Class <T > tClass ) {
261
+
262
+ Response response = post (url , MediaTypeEnum .JSON , body , null , headerParams );
263
+ return handleResponse (response , tClass );
247
264
}
248
265
249
266
@@ -253,48 +270,96 @@ public JSONMapper postForm(String url, Map<String, Object> formParams) {
253
270
return handleResponse (response , JSONMapper .class );
254
271
}
255
272
273
+ public JSONMapper postForm (String url , Map <String , Object > formParams , Map <String , Object > headerParams ) {
274
+
275
+ Response response = post (url , MediaTypeEnum .FORM , null , formParams , headerParams );
276
+ return handleResponse (response , JSONMapper .class );
277
+ }
278
+
256
279
public JSONMapper postFormData (String url , Map <String , Object > formParams ) {
257
280
258
281
Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
259
282
return handleResponse (response , JSONMapper .class );
260
283
}
261
284
285
+ public JSONMapper postFormData (String url , Map <String , Object > formParams , Map <String , Object > headerParams ) {
286
+
287
+ Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , headerParams );
288
+ return handleResponse (response , JSONMapper .class );
289
+ }
290
+
262
291
public JSONMapper post (String url , Object body ) {
263
292
264
293
Response response = post (url , MediaTypeEnum .JSON , body , null , null );
265
294
return handleResponse (response , JSONMapper .class );
266
295
}
267
296
297
+ public JSONMapper post (String url , Object body , Map <String , Object > headerParams ) {
298
+
299
+ Response response = post (url , MediaTypeEnum .JSON , body , null , headerParams );
300
+ return handleResponse (response , JSONMapper .class );
301
+ }
302
+
268
303
public JSONMapper put (String url , Object body ) {
269
304
270
305
Response response = put (url , MediaTypeEnum .JSON , body , null , null );
271
306
return handleResponse (response , JSONMapper .class );
272
307
}
273
308
309
+ public JSONMapper put (String url , Object body , Map <String , Object > headerParams ) {
310
+
311
+ Response response = put (url , MediaTypeEnum .JSON , body , null , headerParams );
312
+ return handleResponse (response , JSONMapper .class );
313
+ }
314
+
274
315
public <T > T put (String url , Object body , Class <T > tClass ) {
275
316
276
317
Response response = put (url , MediaTypeEnum .JSON , body , null , null );
277
318
return handleResponse (response , tClass );
278
319
}
279
320
321
+ public <T > T put (String url , Object body , Map <String , Object > headerParams , Class <T > tClass ) {
322
+
323
+ Response response = put (url , MediaTypeEnum .JSON , body , null , headerParams );
324
+ return handleResponse (response , tClass );
325
+ }
326
+
280
327
public JSONMapper putForm (String url , Map <String , Object > formParams ) {
281
328
282
329
Response response = put (url , MediaTypeEnum .FORM , null , formParams , null );
283
330
return handleResponse (response , JSONMapper .class );
284
331
}
285
332
333
+ public JSONMapper putForm (String url , Map <String , Object > formParams , Map <String , Object > headerParams ) {
334
+
335
+ Response response = put (url , MediaTypeEnum .FORM , null , formParams , headerParams );
336
+ return handleResponse (response , JSONMapper .class );
337
+ }
338
+
286
339
public <T > T putForm (String url , Map <String , Object > formParams , Class <T > tClass ) {
287
340
288
341
Response response = put (url , MediaTypeEnum .FORM , null , formParams , null );
289
342
return handleResponse (response , tClass );
290
343
}
291
344
345
+ public <T > T putForm (String url , Map <String , Object > formParams , Map <String , Object > headerParams , Class <T > tClass ) {
346
+
347
+ Response response = put (url , MediaTypeEnum .FORM , null , formParams , headerParams );
348
+ return handleResponse (response , tClass );
349
+ }
350
+
292
351
public JSONMapper putFormData (String url , Map <String , Object > formParams ) {
293
352
294
353
Response response = put (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
295
354
return handleResponse (response , JSONMapper .class );
296
355
}
297
356
357
+ public JSONMapper putFormData (String url , Map <String , Object > formParams , Map <String , Object > headerParams ) {
358
+
359
+ Response response = put (url , MediaTypeEnum .FORM_DATA , null , formParams , headerParams );
360
+ return handleResponse (response , JSONMapper .class );
361
+ }
362
+
298
363
public <T > T delete (String url ,
299
364
Object body ,
300
365
Map <String , Object > formParams ,
@@ -304,11 +369,30 @@ public <T> T delete(String url,
304
369
return handleResponse (response , tClass );
305
370
}
306
371
372
+ public <T > T delete (String url ,
373
+ Object body ,
374
+ Map <String , Object > formParams ,
375
+ Map <String , Object > headerParams ,
376
+ Class <T > tClass ) {
377
+
378
+ Response response = delete (url , body == null ? MediaTypeEnum .FORM : MediaTypeEnum .JSON , body , formParams , headerParams );
379
+ return handleResponse (response , tClass );
380
+ }
381
+
307
382
public JSONMapper delete (String url ,
308
383
Object body ,
309
384
Map <String , Object > formParams ) {
310
385
311
386
Response response = delete (url , body == null ? MediaTypeEnum .FORM : MediaTypeEnum .JSON , body , formParams , (Map <String , Object >) null );
312
387
return handleResponse (response , JSONMapper .class );
313
388
}
389
+
390
+ public JSONMapper delete (String url ,
391
+ Object body ,
392
+ Map <String , Object > formParams
393
+ , Map <String , Object > headerParams ) {
394
+
395
+ Response response = delete (url , body == null ? MediaTypeEnum .FORM : MediaTypeEnum .JSON , body , formParams , headerParams );
396
+ return handleResponse (response , JSONMapper .class );
397
+ }
314
398
}
0 commit comments