content: package com.amary.app.data.moviecat.data.networking;
  
  import java.util.concurrent.TimeUnit;
  
  import okhttp3.OkHttpClient;
  import okhttp3.logging.HttpLoggingInterceptor;
  import retrofit2.Retrofit;
  import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
  import retrofit2.converter.gson.GsonConverterFactory;
  
  public class ApiClient {
      private static final String BASE_URL = ApiServer.URL_HEAD;
      private static Retrofit retrofit = null;
  
      public static Retrofit getRetrofit() {
          HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
          interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
          OkHttpClient client = new OkHttpClient
                  .Builder()
                  .addInterceptor(interceptor)
                  .readTimeout(10, TimeUnit.SECONDS)
                  .connectTimeout(30, TimeUnit.SECONDS)
                  .build();
          if (retrofit == null){
              retrofit = new Retrofit.Builder()
                      .baseUrl(BASE_URL)
                      .addConverterFactory(GsonConverterFactory.create())
                      .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                      .client(client)
                      .build();
          }
          return retrofit;
      }
  }
  
  