// Path: app/src/main/java/com/calgen/prodek/fadflicks/utils/ApplicationConstants.java
// public class ApplicationConstants {
// 
//     /**
//      * Set to true if debugging is needed
//      */
//     public static final boolean DEBUG = false;
// 
//     /**
//      * When true, forces to clear defaultSharedPreferences
//      */
//     public static final boolean PURGE_CACHE = false;
// 
//     public static final int CACHE_PURGE_PERIOD = 24*60*60*100;
// 
//     /**
//      * API Endpoint
//      */
//     public static final String END_POINT = "http://api.themoviedb.org/3/";
//     /**
//      * Connection timeout duration
//      */
//     public static final int CONNECT_TIMEOUT = 60 * 1000;
//     /**
//      * Connection Read timeout duration
//      */
//     public static final int READ_TIMEOUT = 60 * 1000;
//     /**
//      * Connection write timeout duration
//      */
//     public static final int WRITE_TIMEOUT = 60 * 1000;
// 
// }


import com.calgen.prodek.fadflicks.utils.ApplicationConstants;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/*
 *    Copyright 2016 Gurupad Mamadapur
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.calgen.prodek.fadflicks.api;




/**
 * ===========
 * Acknowledgement
 * ===========
 * Thanks to Thomas kioko for the tutorial
 * on using interceptors
 *
 * @see <a href="http://www.thomaskioko.com/mobile_phone/android-unit-testing/">Blog post</a>
 */
public class ApiClient {
    private Retrofit retrofit;
    private boolean isDebug;
    private HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();

    /**
     * Set the {@link Retrofit} log level.
     *
     * @param isDebug If true, the log level is set to
     *                {@link HttpLoggingInterceptor.Level#BODY}. Otherwise
     *                {@link HttpLoggingInterceptor.Level#NONE}.
     */
    public ApiClient setIsDebug(boolean isDebug) {
        this.isDebug = isDebug;
        if (retrofit != null) {
            httpLoggingInterceptor.
                    setLevel(isDebug ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
        }
        return this;
    }

    /**
     * Configure OkHttpClient
     *
     * @return OkHttpClient
     */
    private OkHttpClient okHttpClient() {

        return new OkHttpClient.Builder()
                .addInterceptor(new AuthInterceptor())
// Path: app/src/main/java/com/calgen/prodek/fadflicks/utils/ApplicationConstants.java
// public class ApplicationConstants {
// 
//     /**
//      * Set to true if debugging is needed
//      */
//     public static final boolean DEBUG = false;
// 
//     /**
//      * When true, forces to clear defaultSharedPreferences
//      */
//     public static final boolean PURGE_CACHE = false;
// 
//     public static final int CACHE_PURGE_PERIOD = 24*60*60*100;
// 
//     /**
//      * API Endpoint
//      */
//     public static final String END_POINT = "http://api.themoviedb.org/3/";
//     /**
//      * Connection timeout duration
//      */
//     public static final int CONNECT_TIMEOUT = 60 * 1000;
//     /**
//      * Connection Read timeout duration
//      */
//     public static final int READ_TIMEOUT = 60 * 1000;
//     /**
//      * Connection write timeout duration
//      */
//     public static final int WRITE_TIMEOUT = 60 * 1000;
// 
// }


// Path: app/src/main/java/com/calgen/prodek/fadflicks/api/ApiClient.java
import com.calgen.prodek.fadflicks.utils.ApplicationConstants;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/*
 *    Copyright 2016 Gurupad Mamadapur
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.calgen.prodek.fadflicks.api;




/**
 * ===========
 * Acknowledgement
 * ===========
 * Thanks to Thomas kioko for the tutorial
 * on using interceptors
 *
 * @see <a href="http://www.thomaskioko.com/mobile_phone/android-unit-testing/">Blog post</a>
 */
public class ApiClient {
    private Retrofit retrofit;
    private boolean isDebug;
    private HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();

    /**
     * Set the {@link Retrofit} log level.
     *
     * @param isDebug If true, the log level is set to
     *                {@link HttpLoggingInterceptor.Level#BODY}. Otherwise
     *                {@link HttpLoggingInterceptor.Level#NONE}.
     */
    public ApiClient setIsDebug(boolean isDebug) {
        this.isDebug = isDebug;
        if (retrofit != null) {
            httpLoggingInterceptor.
                    setLevel(isDebug ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
        }
        return this;
    }

    /**
     * Configure OkHttpClient
     *
     * @return OkHttpClient
     */
    private OkHttpClient okHttpClient() {

        return new OkHttpClient.Builder()
                .addInterceptor(new AuthInterceptor())
                .connectTimeout(ApplicationConstants.CONNECT_TIMEOUT, TimeUnit.SECONDS)