.
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package com.ssb.simplitend.apputils;
|
||||
|
||||
import com.ssb.simplitend.BuildConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
@@ -18,25 +21,38 @@ public abstract class RetrofitHelper {
|
||||
|
||||
public static final String GET_CONTACT_LIST = "api/patients-contact-list";
|
||||
|
||||
public static final String CREATE_CONTACT = "api/contact-create";
|
||||
|
||||
public static final String UPDATE_CONTACT = "api/patient-contact-update/";
|
||||
|
||||
// util functions
|
||||
|
||||
private static Retrofit retrofit;
|
||||
|
||||
public static synchronized Retrofit getRetrofit(){
|
||||
if (retrofit == null){
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||
.addInterceptor(chain -> {
|
||||
Request request = chain.request().newBuilder()
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("Accept-Encoding", "gzip, deflate, br")
|
||||
.addHeader("Connection", "keep-alive")
|
||||
.addHeader("Content-Type", "multipart/form-data")
|
||||
.build();
|
||||
return chain.proceed(request);
|
||||
});
|
||||
|
||||
if (BuildConfig.DEBUG){
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
builder.addInterceptor(interceptor);
|
||||
|
||||
}
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(new OkHttpClient.Builder()
|
||||
.addInterceptor(chain -> {
|
||||
Request request = chain.request().newBuilder()
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("Accept-Encoding", "gzip, deflate, br")
|
||||
.addHeader("Connection", "keep-alive")
|
||||
.addHeader("Content-Type", "multipart/form-data")
|
||||
.build();
|
||||
return chain.proceed(request);
|
||||
}).build())
|
||||
.client(builder.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user