Example #1
0
 /**
  * Execute the request and return the POJO that represent the response.
  *
  * @param <T> The POJO that represents the response object
  * @param resourcePath the resource path
  * @param params the request parameters
  * @param returnType the POJO class to be parsed from the response
  * @return the POJO object that represent the response
  */
 private <T> T executeRequest(
     String resourcePath, Map<String, Object> params, Class<T> returnType) {
   Request request = Request.Get(resourcePath);
   if (params != null && !params.isEmpty()) {
     for (Map.Entry<String, Object> entry : params.entrySet()) {
       request.withQuery(entry.getKey(), entry.getValue());
     }
   }
   HttpRequestBase requestBase = request.build();
   try {
     HttpResponse response = execute(requestBase);
     return ResponseUtil.getObject(response, returnType);
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }