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; 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"; 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(builder.build()) .build(); } return retrofit; } }