brapi-java-client/src/main/java/org/brapi/client/v2/BrAPIClient.java
public <T> ApiResponse<Pair<Optional<T>, Optional<BrAPIAcceptedSearchResponse>>> executeSearch(Call call, Type returnType) throws ApiException {
		// Do a normal call
		Type jsonReturnType = new TypeToken<JsonObject>(){}.getType();
		ApiResponse<JsonObject> searchResponse = execute(call, jsonReturnType);

		// Check our response to construct the Pair
		Pair<Optional<T>, Optional<BrAPIAcceptedSearchResponse>> result;
		if (searchResponse.getBody() != null) {
			JsonObject searchBody = searchResponse.getBody();
			JsonObject searchResult = searchBody.getAsJsonObject("result");
			try {
				if (searchResult != null && searchResult.get("searchResultsDbId") != null) {
					// Parse into a BrAPI Accepted Search Response
					BrAPIAcceptedSearchResponse searchResultObject = json.getGson().fromJson(searchBody, BrAPIAcceptedSearchResponse.class);
					result = new ImmutablePair<>(Optional.empty(), Optional.of(searchResultObject));
				} else {
					// Parse into the actual response object
					T listResponse = json.getGson().fromJson(searchBody, returnType);
					result = new ImmutablePair<>(Optional.of(listResponse), Optional.empty());
				}
			} catch (JsonSyntaxException e){
				throw new ApiException(e);
			}

		} else {
			throw new ApiException("Search body was not returned:" );
		}

		return new ApiResponse<>(searchResponse.getStatusCode(), searchResponse.getHeaders(), result);
	}
/**
	 * Execute HTTP call and deserialize the HTTP response body into the given
	 * return type.
	 *
	 * @param returnType The return type used to deserialize HTTP response body
	 * @param <T>        The return type corresponding to (same with) returnType
	 * @param call       Call
	 * @return ApiResponse object containing response status, headers and data,
	 *         which is a Java object deserialized from response body and would be
	 *         null when returnType is null.
	 * @throws ApiException If fail to execute the call
	 */
Execute HTTP call and deserialize the HTTP response body into the given
return type.

@param returnType The return type used to deserialize HTTP response body
@param         The return type corresponding to (same with) returnType
@param call       Call
@return ApiResponse object containing response status, headers and data,
which is a Java object deserialized from response body and would be
null when returnType is null.
@throws ApiException If fail to execute the call
Execute HTTP call and deserialize the HTTP response body into the given return type . @param returnType The return type used to deserialize HTTP response body @param The return type corresponding to ( same with ) returnType @param call Call @return ApiResponse object containing response status headers and data which is a Java object deserialized from response body and would be null when returnType is null . @throws ApiException If fail to execute the call
public <T> ApiResponse<Pair<Optional<T>, Optional<BrAPIAcceptedSearchResponse>>> executeSearch(Call call, Type returnType) throws ApiException {
		Type jsonReturnType = new TypeToken<JsonObject>(){}.getType();
		ApiResponse<JsonObject> searchResponse = execute(call, jsonReturnType);
		Pair<Optional<T>, Optional<BrAPIAcceptedSearchResponse>> result;
		if (searchResponse.getBody() != null) {
			JsonObject searchBody = searchResponse.getBody();
			JsonObject searchResult = searchBody.getAsJsonObject("result");
			try {
				if (searchResult != null && searchResult.get("searchResultsDbId") != null) {
					BrAPIAcceptedSearchResponse searchResultObject = json.getGson().fromJson(searchBody, BrAPIAcceptedSearchResponse.class);
					result = new ImmutablePair<>(Optional.empty(), Optional.of(searchResultObject));
				} else {
					T listResponse = json.getGson().fromJson(searchBody, returnType);
					result = new ImmutablePair<>(Optional.of(listResponse), Optional.empty());
				}
			} catch (JsonSyntaxException e){
				throw new ApiException(e);
			}
		} else {
			throw new ApiException("Search body was not returned:" );
		}
		return new ApiResponse<>(searchResponse.getStatusCode(), searchResponse.getHeaders(), result);
	}
public < T > ApiResponse < Pair < Optional < T > , Optional < BrAPIAcceptedSearchResponse > > > executeSearch ( Call call , Type returnType ) throws ApiException { Type jsonReturnType = new TypeToken < JsonObject > ( ) { } . getType ( ) ; ApiResponse < JsonObject > searchResponse = execute ( call , jsonReturnType ) ; Pair < Optional < T > , Optional < BrAPIAcceptedSearchResponse > > result ; if ( searchResponse . getBody ( ) != null ) { JsonObject searchBody = searchResponse . getBody ( ) ; JsonObject searchResult = searchBody . getAsJsonObject ( "result" ) ; try { if ( searchResult != null && searchResult . get ( "searchResultsDbId" ) != null ) { BrAPIAcceptedSearchResponse searchResultObject = json . getGson ( ) . fromJson ( searchBody , BrAPIAcceptedSearchResponse . class ) ; result = new ImmutablePair < > ( Optional . empty ( ) , Optional . of ( searchResultObject ) ) ; } else { T listResponse = json . getGson ( ) . fromJson ( searchBody , returnType ) ; result = new ImmutablePair < > ( Optional . of ( listResponse ) , Optional . empty ( ) ) ; } } catch ( JsonSyntaxException e ) { throw new ApiException ( e ) ; } } else { throw new ApiException ( "Search body was not returned:" ) ; } return new ApiResponse < > ( searchResponse . getStatusCode ( ) , searchResponse . getHeaders ( ) , result ) ; }
Execute HTTP call and deserialize the HTTP response body into the given
 return type.
Execute HTTP call and deserialize the HTTP response body into the given return type .
// Do a normal call // Check our response to construct the Pair // Parse into a BrAPI Accepted Search Response // Parse into the actual response object