Example usage for com.squareup.okhttp HttpUrl query

List of usage examples for com.squareup.okhttp HttpUrl query

Introduction

In this page you can find the example usage for com.squareup.okhttp HttpUrl query.

Prototype

public String query() 

Source Link

Usage

From source file:com.ibm.watson.developer_cloud.service.AlchemyService.java

License:Open Source License

/**
 * Adds the Alchemy API key to HTTP request.
 * //ww w  . j  a v  a  2  s.  com
 * @param builder the builder
 * @param apiKey the API key token
 */
private void addApiKeyToRequest(Builder builder, String apiKey) {
    final HttpUrl url = HttpUrl.parse(builder.build().urlString());
    if (url.query() == null || url.query().isEmpty()) {
        builder.url(builder.build().url() + "?" + apiKey);
    } else {
        builder.url(builder.build().url() + "&" + apiKey);
    }
}