Java Code Examples for com.squareup.okhttp.HttpUrl#Builder

The following examples show how to use com.squareup.okhttp.HttpUrl#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwaggerHubClient.java    From swaggerhub-gradle-plugin with Apache License 2.0 5 votes vote down vote up
private HttpUrl.Builder getBaseUrl(String owner, String api) {
    return new HttpUrl.Builder()
            .scheme(protocol)
            .host(host)
            .port(port)
            .addPathSegment(APIS)
            .addEncodedPathSegment(owner)
            .addEncodedPathSegment(api);
}
 
Example 2
Source File: SwaggerHubClient.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
private HttpUrl.Builder getBaseUrl(DefinitionType definitionType, String owner, String api) {
    HttpUrl.Builder httpUrlBuilder = new HttpUrl.Builder()
            .scheme(protocol)
            .host(host)
            .port(port);
            return addOptionalPathSegment(httpUrlBuilder, basePath)
            .addPathSegment(definitionType.getPathSegment())
            .addEncodedPathSegment(owner)
            .addEncodedPathSegment(api);
}
 
Example 3
Source File: SwaggerHubClient.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
private HttpUrl getSaveIntegrationPluginConfigURL(SaveSCMPluginConfigRequest saveSCMPluginConfigRequest) {
    HttpUrl.Builder httpUrlBuilder = new HttpUrl.Builder()
            .scheme(protocol)
            .host(host)
            .port(port);
            return addOptionalPathSegment(httpUrlBuilder, basePath)
            .addPathSegment("plugins")
            .addPathSegment("configurations")
            .addEncodedPathSegment(saveSCMPluginConfigRequest.getOwner())
            .addEncodedPathSegment(saveSCMPluginConfigRequest.getApi())
            .addEncodedPathSegment(saveSCMPluginConfigRequest.getVersion())
            .addEncodedPathSegment(saveSCMPluginConfigRequest.getScmProvider())
            .addEncodedQueryParameter("oas", saveSCMPluginConfigRequest.getOas())
            .build();
}
 
Example 4
Source File: SwaggerHubClient.java    From swaggerhub-maven-plugin with Apache License 2.0 5 votes vote down vote up
private HttpUrl.Builder addOptionalPathSegment(HttpUrl.Builder builder, String pathSegment){
    if(StringUtils.isEmpty(pathSegment)){
        return builder;
    }
    return builder.addPathSegment(pathSegment);

}