2023-07-13 21:12:17 +05:30
|
|
|
package com.ssb.simplitend.apputils;
|
|
|
|
|
|
2023-07-18 19:38:59 +05:30
|
|
|
import com.ssb.simplitend.BuildConfig;
|
|
|
|
|
|
2023-07-13 21:12:17 +05:30
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import okhttp3.Interceptor;
|
|
|
|
|
import okhttp3.OkHttpClient;
|
|
|
|
|
import okhttp3.Request;
|
|
|
|
|
import okhttp3.Response;
|
2023-07-18 19:38:59 +05:30
|
|
|
import okhttp3.logging.HttpLoggingInterceptor;
|
2023-07-13 21:12:17 +05:30
|
|
|
import retrofit2.Retrofit;
|
|
|
|
|
import retrofit2.converter.gson.GsonConverterFactory;
|
|
|
|
|
|
|
|
|
|
public abstract class RetrofitHelper {
|
|
|
|
|
|
|
|
|
|
// urls
|
|
|
|
|
public static final String BASE_URL = "https://simplitend.betadelivery.com/";
|
|
|
|
|
|
|
|
|
|
public static final String REGISTER_PATIENT = "api/auth/patient-register";
|
|
|
|
|
|
|
|
|
|
public static final String GET_CONTACT_LIST = "api/patients-contact-list";
|
|
|
|
|
|
2023-07-18 19:38:59 +05:30
|
|
|
public static final String CREATE_CONTACT = "api/contact-create";
|
|
|
|
|
|
|
|
|
|
public static final String UPDATE_CONTACT = "api/patient-contact-update/";
|
|
|
|
|
|
2023-07-13 21:12:17 +05:30
|
|
|
// util functions
|
|
|
|
|
|
|
|
|
|
private static Retrofit retrofit;
|
|
|
|
|
|
|
|
|
|
public static synchronized Retrofit getRetrofit(){
|
|
|
|
|
if (retrofit == null){
|
2023-07-18 19:38:59 +05:30
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
2023-07-13 21:12:17 +05:30
|
|
|
retrofit = new Retrofit.Builder()
|
|
|
|
|
.baseUrl(BASE_URL)
|
|
|
|
|
.addConverterFactory(GsonConverterFactory.create())
|
2023-07-18 19:38:59 +05:30
|
|
|
.client(builder.build())
|
2023-07-13 21:12:17 +05:30
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retrofit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|