content: package com.androidavanzado.offlinemovies.data;
  
  import androidx.room.Room;
  
  import com.androidavanzado.offlinemovies.app.MyApp;
  import com.androidavanzado.offlinemovies.data.local.MovieRoomDatabase;
  import com.androidavanzado.offlinemovies.data.local.dao.MovieDao;
  import com.androidavanzado.offlinemovies.data.remote.ApiConstants;
  import com.androidavanzado.offlinemovies.data.remote.MovieApiService;
  import com.androidavanzado.offlinemovies.data.remote.RequestInterceptor;
  
  import okhttp3.OkHttpClient;
  import retrofit2.Retrofit;
  import retrofit2.converter.gson.GsonConverterFactory;
  
  public class MovieRepository {
  
      private final MovieApiService movieApiService;
      private final MovieDao movieDao;
  
      public MovieRepository() {
          // Local > ROOM
          MovieRoomDatabase movieRoomDatabase = Room.databaseBuilder(
                  MyApp.getContext(),
                  MovieRoomDatabase.class,
                  "db_movies"
          ).build();
          movieDao = movieRoomDatabase.getMovieDao();
  
  
          // RequestInterceptor: incluir en la cabecera (URL) de la
          // petición el TOKEN o API_KEY que autoriza al usuario
          OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
          okHttpClientBuilder.addInterceptor(new RequestInterceptor());
          OkHttpClient cliente = okHttpClientBuilder.build();
  
  
          // Remote > Retrofit
          Retrofit retrofit = new Retrofit.Builder()
                  .baseUrl(ApiConstants.BASE_URL)
                  .client(cliente)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
  
          movieApiService = retrofit.create(MovieApiService.class);
  
      }
  }
  