34 lines
869 B
Java
34 lines
869 B
Java
|
package org.mian.gitnex.clients;
|
||
|
|
||
|
import okhttp3.OkHttpClient;
|
||
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||
|
import retrofit2.Retrofit;
|
||
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||
|
|
||
|
/**
|
||
|
* Author M M Arif
|
||
|
*/
|
||
|
|
||
|
public class IssuesService {
|
||
|
|
||
|
public static <S> S createService(Class<S> serviceClass, String instanceURL) {
|
||
|
|
||
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||
|
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||
|
|
||
|
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||
|
|
||
|
httpClient.addInterceptor(logging);
|
||
|
|
||
|
Retrofit retrofit = new Retrofit.Builder()
|
||
|
.baseUrl(instanceURL)
|
||
|
.addConverterFactory(GsonConverterFactory.create())
|
||
|
//.client(httpClient.build())
|
||
|
.build();
|
||
|
|
||
|
return retrofit.create(serviceClass);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|