Submit an API request, and bind the returned JSON data into an object of the given result jackson JavaType.
For mapping it uses Jackson object mapper.

@param apiRequest
@param resultType
@param <Result>
@return
@throws TDClientException
436097
@SuppressWarnings(value = "unchecked cast")
    public <Result> Result call(TDApiRequest apiRequest, Optional<String> apiKeyCache, final JavaType resultType)
            throws TDClientException
    {
        try {
            byte[] content = submitRequest(apiRequest, apiKeyCache, byteArrayContentHandler);
            if (logger.isTraceEnabled()) {
                logger.trace("response:\n{}", new String(content, StandardCharsets.UTF_8));
            }
            if (resultType.getRawClass() == String.class) {
                return (Result) new String(content, StandardCharsets.UTF_8);
            }
            else {
                return getJsonReader(resultType).readValue(content);
            }
        }
        catch (JsonMappingException e) {
            logger.error("Jackson mapping error", e);
            throw new TDClientException(INVALID_JSON_RESPONSE, e);
        }
        catch (IOException e) {
            throw new TDClientException(INVALID_JSON_RESPONSE, e);
        }
    }
1325528
public ApiResponse<DynconfigGetConfigResponse> dynconfigGetConfigWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = dynconfigGetConfigValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<DynconfigGetConfigResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
1259883
public function request(TypeInfo $resultTypeInfo, Request $apiRequest)
    {
        $headers = $apiRequest->getHeaders();

        $headers['Accept'] = JsonRequest::CONTENT_TYPE;

        if ($this->bearerToken !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->bearerToken;
        }

        $request = new Psr7\Request(
            $apiRequest->method,
            $apiRequest->getUrl($this->baseUrl),
            $headers,
            $apiRequest->getBody()
        );

        $options = $apiRequest->getOptions();
        $options['query'] = $apiRequest->getQuery();

        $response = $this->httpClient->send($request, $options);

        $responseBody = $response->getBody();
        $contents = $responseBody->getContents();
        $rawResult = Common::decode($contents);

        return $resultTypeInfo->deserialize($rawResult);
    }
1229614
protected Object httpRequest(ApiAction action, HttpRequestMethod method, Map<String, Object> data) throws IOException {
        String url = this.apiUrl + "/" + action.toString().toLowerCase();
        Type type = new TypeToken<Map<String, Object>>() {}.getType();
        String json = GSON.toJson(data, type);
        Map<String, String> params = buildPayload(json);
        Object response = httpClient.executeHttpRequest(url, method, params, handler, customHeaders);
        recordRateLimitInfo(action, method, response);
        return response;
    }
490244
@Post("json")
	public final void registerDeviceRequest(final Representation entity) {
		Request request = getRequest();
		Map<String, Object> requestAttributes = request.getAttributes();
		String deviceLibraryIdentifier = (String) requestAttributes.get("deviceLibraryIdentifier");
		String passTypeIdentifier = (String) requestAttributes.get("passTypeIdentifier");
		String serialNumber = (String) requestAttributes.get("serialNumber");
		String authString = request.getChallengeResponse().getRawValue();
		Status responseStatus;
		try {
			String jsonPushToken = entity.getText();
			PKPushToken pkPushToken = jsonObjectMapper.readValue(jsonPushToken, PKPushToken.class);

			LOGGER.debug("registerDeviceRequest - deviceLibraryIdentifier: {}", deviceLibraryIdentifier);
			LOGGER.debug("registerDeviceRequest - passTypeIdentifier: {}", passTypeIdentifier);
			LOGGER.debug("registerDeviceRequest - serialNumber: {}", serialNumber);
			LOGGER.debug("registerDeviceRequest - authString: {}", authString);
			LOGGER.debug("registerDeviceRequest - jsonPushToken: {}", jsonPushToken);
			LOGGER.debug("registerDeviceRequest - pkPushToken: {}", pkPushToken);
			responseStatus = handleRegisterDeviceRequest(deviceLibraryIdentifier, passTypeIdentifier, serialNumber, authString, pkPushToken);
		} catch (PKAuthTokenNotValidException e) {
			responseStatus = Status.CLIENT_ERROR_UNAUTHORIZED;
		} catch (IOException e) {
			responseStatus = Status.SERVER_ERROR_INTERNAL;
		}
		setStatusIntoResponse(responseStatus, getResponse());
	}
815540
public QueryResponse executeQueryPost(Query query) throws ApiException {
        ApiResponse<QueryResponse> resp = executeQueryPostWithHttpInfo(query);
        return resp.getData();
    }
264421
protected <T> T readResponse(Response response,JavaType javaType)
    {
        try
        {
            return objectMapper.readValue(response.body().byteStream(), javaType);
        }
        catch (IOException e)
        {
            throw new ClientMarshallingException("Error reading results.",e);
        }
    }
709538
protected <R> R executeRequest(Request request, JavaType javaType)
    {
        long start = System.currentTimeMillis();
        boolean error = true;
        try
        {
            Response response = executeRequest(request);
            R r = readResponse(response, javaType);
            error = false;
            return r;
        }
        finally
        {
            if(clientEventListener != null)
            {
                ClientEvent event = new ClientEvent(baseUrl,request.getEntityName(),request.getRequestMethod(),
                        System.currentTimeMillis() - start,error);
                clientEventListener.handleEvent(event);
            }
        }
    }
949208
public static JSONObject getJSONObject(HttpGet request, Integer method) throws JSONException {
        return UpworkRestClient.getJSONObject(request, method, new HashMap<String, String>());
    }
561659
@RequestMapping(params = {"query", "queryId"})
    public ModelAndView showSearchResults(
            PortletRequest request,
            @RequestParam(value = "query") String query,
            @RequestParam(value = "queryId") String queryId) {

        final Map<String, Object> model = new HashMap<>();
        model.put("query", query);

        // Determine if the new REST search should be used
        if (isRestSearch(request)) {
            // we only need query, so the model at this point is sufficient
            return new ModelAndView("/jsp/Search/searchRest", model);
        }

        ConcurrentMap<String, List<Tuple<SearchResult, String>>> results =
                new ConcurrentHashMap<>();
        final PortalSearchResults portalSearchResults =
                this.getPortalSearchResults(request, queryId);
        if (portalSearchResults != null) {
            results = portalSearchResults.getResults();
        }

        results.forEach(
                (key, value) -> {
                    value.sort(Comparator.comparingInt(tuple -> tuple.first.getRank()));
                });

        logger.debug("Search results for query '{}' are:  {}", query, results);

        model.put("results", results);
        model.put("defaultTabKey", this.defaultTabKey);
        model.put("tabKeys", this.tabKeys);

        final boolean isMobile = isMobile(request);
        String viewName = isMobile ? "/jsp/Search/mobileSearch" : "/jsp/Search/search";

        return new ModelAndView(viewName, model);
    }
366843
public static <T> T executeJsonResult(HttpUriRequest request,Class<T> clazz){
		return execute(request,JsonResponseHandler.createResponseHandler(clazz));
	}
885974
public ApiResponse<PostLocationResponse> postLocationWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = postLocationValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<PostLocationResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
805600
@SuppressWarnings("unchecked")
  public <T> T api(Class<T> serviceInterface) {

    final ServiceCall serviceCall = this;
    final Map<Method, MethodInfo> genericReturnTypes = Reflect.methodsInfo(serviceInterface);

    // noinspection unchecked
    return (T)
        Proxy.newProxyInstance(
            getClass().getClassLoader(),
            new Class[] {serviceInterface},
            (proxy, method, params) -> {
              final MethodInfo methodInfo = genericReturnTypes.get(method);
              final Class<?> returnType = methodInfo.parameterizedReturnType();
              final boolean isServiceMessage = methodInfo.isRequestTypeServiceMessage();

              Optional<Object> check =
                  toStringOrEqualsOrHashCode(method.getName(), serviceInterface, params);
              if (check.isPresent()) {
                return check.get(); // toString, hashCode was invoked.
              }

              switch (methodInfo.communicationMode()) {
                case FIRE_AND_FORGET:
                  return serviceCall.oneWay(toServiceMessage(methodInfo, params));

                case REQUEST_RESPONSE:
                  return serviceCall
                      .requestOne(toServiceMessage(methodInfo, params), returnType)
                      .transform(asMono(isServiceMessage));

                case REQUEST_STREAM:
                  return serviceCall
                      .requestMany(toServiceMessage(methodInfo, params), returnType)
                      .transform(asFlux(isServiceMessage));

                case REQUEST_CHANNEL:
                  // this is REQUEST_CHANNEL so it means params[0] must be a publisher - its safe to
                  // cast.
                  return serviceCall
                      .requestBidirectional(
                          Flux.from((Publisher) params[0])
                              .map(data -> toServiceMessage(methodInfo, data)),
                          returnType)
                      .transform(asFlux(isServiceMessage));

                default:
                  throw new IllegalArgumentException(
                      "Communication mode is not supported: " + method);
              }
            });
  }
1198386
@Override
	public T convert(ResponseBody value) throws IOException {
		try {
			return (T) binderContext.parse(value.byteStream(), clazz);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			value.close();
		}
	}
1103432
@Override
    public OptionalThing<ApiResponse> handleClientException(ApiFailureResource resource, RuntimeException cause) {
        final FaicliUnifiedFailureType failureType = FaicliUnifiedFailureType.CLIENT_ERROR;
        final FaicliUnifiedFailureResult result = createFailureResult(failureType, resource, cause);
        adjustClientExceptionErrors(resource, cause, result);
        return OptionalThing.of(asJson(result)); // HTTP status will be automatically sent as client error for the cause
    }
289826
@SuppressWarnings("unchecked")
	public <T> T toObject(String jsonString, JavaType javaType) {
		if (StringUtils.isEmpty(jsonString)) {
			return null;
		}

		try {
			return (T) mapper.readValue(jsonString, javaType);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
733164
private Result execute(ResultType cmdType) throws SparqlException {
    String mimeType = contentType;
    
    // Validate the user-supplied MIME type.
    if (mimeType != null && !ResultFactory.supports(mimeType, cmdType)) {
      logger.warn("Requested MIME content type '{}' does not support expected response type: {}", mimeType, cmdType);
      mimeType = null;
    }
    
    // Get the default MIME type to request
    if (mimeType == null) {
      mimeType = ResultFactory.getDefaultMediaType(cmdType);
    }
    
    if (logger.isDebugEnabled()) {
      logRequest(cmdType, mimeType);
    }
    
    try {
      HttpResponse response = SparqlCall.executeRequest(this, mimeType);
      return ResultFactory.getResult(this, response, cmdType);
    } catch (Throwable t) {
      release();
      throw SparqlException.convert("Error creating SPARQL result from server response", t);
    }
  }