47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
|
|
package com.ssb.simplitend.apputils;
|
||
|
|
|
||
|
|
import java.io.IOException;
|
||
|
|
|
||
|
|
import okhttp3.Interceptor;
|
||
|
|
import okhttp3.OkHttpClient;
|
||
|
|
import okhttp3.Request;
|
||
|
|
import okhttp3.Response;
|
||
|
|
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";
|
||
|
|
|
||
|
|
// util functions
|
||
|
|
|
||
|
|
private static Retrofit retrofit;
|
||
|
|
|
||
|
|
public static synchronized Retrofit getRetrofit(){
|
||
|
|
if (retrofit == null){
|
||
|
|
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())
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
return retrofit;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|