package com.wassim.androidmvpbase.data.remote;

import com.wassim.androidmvpbase.data.model.Movie;
import com.wassim.androidmvpbase.util.Vars;

import java.util.List;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;
import retrofit2.RxJavaCallAdapterFactory;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import rx.Observable;

public interface ApiService {

    @GET("movies.json")
    Observable<List<Movie>> getMovies();

    @POST("movies")
    Observable<Movie> saveMovie();

    @PUT("movies")
    Observable<Movie> updateMovie();

    @DELETE("movies")
    Observable<Movie> deleteMovie();

    class Factory {
        public static ApiService create() {

            HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
            interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

            Retrofit retrofit = new Retrofit.Builder()
                    .baseUrl(Vars.ENDPOINT)
                    .client(client)
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .build();
            return retrofit.create(ApiService.class);
        }
    }
}

package com.wassim.androidmvpbase.data.remote;

import com.wassim.androidmvpbase.data.model.Movie;
import com.wassim.androidmvpbase.util.Vars;

import java.io.IOException;
import java.util.List;

import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;
import retrofit2.RxJavaCallAdapterFactory;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import rx.Observable;

public interface ApiService {

    @GET("movies.json")
    Observable<List<Movie>> getMovies();

    @POST("movies")
    Observable<Movie> saveMovie();

    @PUT("movies")
    Observable<Movie> updateMovie();

    @DELETE("movies")
    Observable<Movie> deleteMovie();

    class Factory {
        public static ApiService create() {

            HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
            interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            OkHttpClient client =
                    new OkHttpClient.Builder()

                    // uncomment when using headers
                    /*.addInterceptor(
                            new Interceptor() {
                                @Override
                                public Response intercept(Interceptor.Chain chain) throws
                                        IOException {
                                    Request request = chain.request().newBuilder()
                                            .addHeader("Accept", "application/json")
                                            .addHeader("Content-Type", "application/json")
                                            .addHeader("Authorization", "Bearer " + "token")
                                            .build();
                                    return chain.proceed(request);
                                }
                            })*/
                    .addInterceptor(interceptor).build();

            Retrofit retrofit = new Retrofit.Builder()
                    .baseUrl(Vars.ENDPOINT)
                    .client(client)
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .build();
            return retrofit.create(ApiService.class);
        }
    }
}

add headers Interceptor to OkHttpClient constructor