infobip.api.config.TimeoutClientProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infobip-api-java-client Show documentation
Show all versions of infobip-api-java-client Show documentation
API client in Java for Infobip's API (http://dev.infobip.com/).
package infobip.api.config;
import java.util.concurrent.TimeUnit;
import com.squareup.okhttp.OkHttpClient;
import retrofit.client.Client;
import retrofit.client.OkClient;
public class TimeoutClientProvider implements Client.Provider {
private final Configuration configuration;
public TimeoutClientProvider(Configuration configuration) {
this.configuration = configuration;
}
@Override
public Client get() {
final OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setReadTimeout(configuration.getReadTimeout(), TimeUnit.MILLISECONDS);
okHttpClient.setConnectTimeout(configuration.getConnectionTimeout(), TimeUnit.MILLISECONDS);
return new OkClient(okHttpClient);
}
}