RestfulAPI Class
public class RetrofitClient {
private static Retrofit retrofit = null;
OkHttpClient client = new OkHttpClient();
// public final String BASE_URL = "http://braindna.co/";
public final String URL = "http://54.174.149.227:8080";
// http://54.174.149.227:8080/calculate16Personality
public APIService getAPIService(Context context) {
return getClient(URL, context).create(APIService.class);
}
public OkHttpClient getBuilder(Context context) {
return new OkHttpClient.Builder()
// .addInterceptor(new AddCookiesInterceptor(context)) // VERY VERY IMPORTANT
// .addInterceptor(new ReceivedCookiesInterceptor(context)) // VERY VERY IMPORTANT
.build();
}
public Retrofit getClient(String baseUrl, Context context) {
return new Retrofit.Builder()
.baseUrl(baseUrl)
.client(getBuilder(context))
.addConverterFactory(GsonConverterFactory.create())
.build();
}
public final String BASE_URL = "http://braindna.co/";
public APIService getService(Context context) {
return getTwiceClient(BASE_URL, context).create(APIService.class);
}
public OkHttpClient getTwiceBuilder(Context context) {
return new OkHttpClient.Builder()
.addInterceptor(new AddCookiesInterceptor(context)) // VERY VERY IMPORTANT
.addInterceptor(new ReceivedCookiesInterceptor(context)) // VERY VERY IMPORTANT
.build();
}
public Retrofit getTwiceClient(String baseUrl, Context context) {
return new Retrofit.Builder()
.baseUrl(baseUrl)
.client(getTwiceBuilder(context))
.addConverterFactory(GsonConverterFactory.create())
.build();
}
}