// Path: app/src/main/java/io/github/krtkush/marsexplorer/RESTClients/RestClientConstants.java
// public class  RestClientConstants {
// 
//     // Strings related to NASA's API
//     private static final String nasaApiEndPoint = "https://api.nasa.gov/";
//     private static final String nasaApiServiceName = "mars-photos/";
//     private static final String nasaApiVersion = "api/v1/rovers/";
//     public static final String nasaApiBaseUrl = nasaApiEndPoint + nasaApiServiceName
//             + nasaApiVersion;
// 
//     // Strings related to Mars Weather's API
//     private static final String marsWeatherEndPoint = "http://cab.inta-csic.es/";
//     private static final String marsWeatherAddress = "rems/wp-content/plugins/marsweather-widget/";
//     public static final String marsWeatherBaseUrl = marsWeatherEndPoint + marsWeatherAddress;
// 
//     // Custom headers
//     public static final String responseCachingFlagHeader = "ApplyResponseCache";
//     public static final String offlineCachingFlagHeader = "ApplyOfflineCache";
// 
//     // Cache directory name
//     public static final String apiResponsesCache = "apiResponses";
// }


import java.io.IOException;
import io.github.krtkush.marsexplorer.RESTClients.RestClientConstants;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import timber.log.Timber;
package io.github.krtkush.marsexplorer.RESTClients.Interceptors;



/**
 * Created by kartikeykushwaha on 08/06/16.
 */

/**
 * Interceptor to cache data and maintain it for six hour.
 *
 * If the same network request is sent within six hour, the response is retrieved from cache.
 */
public class ResponseCacheInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {

        Request request = chain.request();
// Path: app/src/main/java/io/github/krtkush/marsexplorer/RESTClients/RestClientConstants.java
// public class  RestClientConstants {
// 
//     // Strings related to NASA's API
//     private static final String nasaApiEndPoint = "https://api.nasa.gov/";
//     private static final String nasaApiServiceName = "mars-photos/";
//     private static final String nasaApiVersion = "api/v1/rovers/";
//     public static final String nasaApiBaseUrl = nasaApiEndPoint + nasaApiServiceName
//             + nasaApiVersion;
// 
//     // Strings related to Mars Weather's API
//     private static final String marsWeatherEndPoint = "http://cab.inta-csic.es/";
//     private static final String marsWeatherAddress = "rems/wp-content/plugins/marsweather-widget/";
//     public static final String marsWeatherBaseUrl = marsWeatherEndPoint + marsWeatherAddress;
// 
//     // Custom headers
//     public static final String responseCachingFlagHeader = "ApplyResponseCache";
//     public static final String offlineCachingFlagHeader = "ApplyOfflineCache";
// 
//     // Cache directory name
//     public static final String apiResponsesCache = "apiResponses";
// }


// Path: app/src/main/java/io/github/krtkush/marsexplorer/RESTClients/Interceptors/ResponseCacheInterceptor.java
import java.io.IOException;
import io.github.krtkush.marsexplorer.RESTClients.RestClientConstants;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import timber.log.Timber;

package io.github.krtkush.marsexplorer.RESTClients.Interceptors;



/**
 * Created by kartikeykushwaha on 08/06/16.
 */

/**
 * Interceptor to cache data and maintain it for six hour.
 *
 * If the same network request is sent within six hour, the response is retrieved from cache.
 */
public class ResponseCacheInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {

        Request request = chain.request();
        if(Boolean.valueOf(request.header(RestClientConstants.responseCachingFlagHeader))) {