@@ -168,7 +168,7 @@ protected <T> T handleFailResponse(Response response, Class<T> tClass) {
168168 return null ;
169169 }
170170
171- //protected JSONObject serialize(Response response) {
171+ // protected JSONObject serialize(Response response) {
172172 // ResponseBody body = response.body();
173173 // if (body == null) {
174174 // throw new HttpException("response body is null");
@@ -181,7 +181,7 @@ protected <T> T handleFailResponse(Response response, Class<T> tClass) {
181181 // }
182182 //}
183183
184- //protected JSONArray serializeList(Response response) {
184+ // protected JSONArray serializeList(Response response) {
185185 // ResponseBody body = response.body();
186186 // if (body == null) {
187187 // throw new HttpException("response body is null");
@@ -206,44 +206,61 @@ public <T> T get(String path, Map<String, Object> queryMap, Class<T> tClass) {
206206 }
207207
208208
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+
209230 public <T > T postForm (String url , Map <String , Object > formParams , Class <T > tClass ) {
210231
211232 Response response = post (url , MediaTypeEnum .FORM , null , formParams , null );
212233 return handleResponse (response , tClass );
213234 }
214235
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 ) {
216237
217- Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
238+ Response response = post (url , MediaTypeEnum .FORM , null , formParams , headerParams );
218239 return handleResponse (response , tClass );
219240 }
220241
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 ) {
222243
223- Response response = post (url , MediaTypeEnum .JSON , body , null , null );
244+ Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
224245 return handleResponse (response , tClass );
225246 }
226247
248+ public <T > T postFormData (String url , Map <String , Object > formParams , Map <String , Object > headerParams , Class <T > tClass ) {
227249
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 );
236252 }
237253
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 ) {
240255
241- return (List <T >) handleResponse (response , tClass , true );
256+ Response response = post (url , MediaTypeEnum .JSON , body , null , null );
257+ return handleResponse (response , tClass );
242258 }
243259
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 );
247264 }
248265
249266
@@ -253,48 +270,96 @@ public JSONMapper postForm(String url, Map<String, Object> formParams) {
253270 return handleResponse (response , JSONMapper .class );
254271 }
255272
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+
256279 public JSONMapper postFormData (String url , Map <String , Object > formParams ) {
257280
258281 Response response = post (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
259282 return handleResponse (response , JSONMapper .class );
260283 }
261284
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+
262291 public JSONMapper post (String url , Object body ) {
263292
264293 Response response = post (url , MediaTypeEnum .JSON , body , null , null );
265294 return handleResponse (response , JSONMapper .class );
266295 }
267296
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+
268303 public JSONMapper put (String url , Object body ) {
269304
270305 Response response = put (url , MediaTypeEnum .JSON , body , null , null );
271306 return handleResponse (response , JSONMapper .class );
272307 }
273308
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+
274315 public <T > T put (String url , Object body , Class <T > tClass ) {
275316
276317 Response response = put (url , MediaTypeEnum .JSON , body , null , null );
277318 return handleResponse (response , tClass );
278319 }
279320
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+
280327 public JSONMapper putForm (String url , Map <String , Object > formParams ) {
281328
282329 Response response = put (url , MediaTypeEnum .FORM , null , formParams , null );
283330 return handleResponse (response , JSONMapper .class );
284331 }
285332
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+
286339 public <T > T putForm (String url , Map <String , Object > formParams , Class <T > tClass ) {
287340
288341 Response response = put (url , MediaTypeEnum .FORM , null , formParams , null );
289342 return handleResponse (response , tClass );
290343 }
291344
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+
292351 public JSONMapper putFormData (String url , Map <String , Object > formParams ) {
293352
294353 Response response = put (url , MediaTypeEnum .FORM_DATA , null , formParams , null );
295354 return handleResponse (response , JSONMapper .class );
296355 }
297356
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+
298363 public <T > T delete (String url ,
299364 Object body ,
300365 Map <String , Object > formParams ,
@@ -304,11 +369,30 @@ public <T> T delete(String url,
304369 return handleResponse (response , tClass );
305370 }
306371
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+
307382 public JSONMapper delete (String url ,
308383 Object body ,
309384 Map <String , Object > formParams ) {
310385
311386 Response response = delete (url , body == null ? MediaTypeEnum .FORM : MediaTypeEnum .JSON , body , formParams , (Map <String , Object >) null );
312387 return handleResponse (response , JSONMapper .class );
313388 }
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+ }
314398}
0 commit comments