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);
        }
    }
}

@@ -153,47 +153,152 @@
 ava.
-util.List;%0A%0Aimport okhttp3.OkHttpClient
+io.IOException;%0Aimport java.util.List;%0A%0Aimport okhttp3.Interceptor;%0Aimport okhttp3.OkHttpClient;%0Aimport okhttp3.Request;%0Aimport okhttp3.Response
 ;%0Aim
@@ -1102,16 +1102,36 @@
 client =
+%0A                   
  new OkH
@@ -1149,16 +1149,903 @@
 uilder()
+%0A%0A                    // uncomment when using headers%0A                    /*.addInterceptor(%0A                            new Interceptor() %7B%0A                                @Override%0A                                public Response intercept(Interceptor.Chain chain) throws%0A                                        IOException %7B%0A                                    Request request = chain.request().newBuilder()%0A                                            .addHeader(%22Accept%22, %22application/json%22)%0A                                            .addHeader(%22Content-Type%22, %22application/json%22)%0A                                            .addHeader(%22Authorization%22, %22Bearer %22 + %22token%22)%0A                                            .build();%0A                                    return chain.proceed(request);%0A                                %7D%0A                            %7D)*/%0A                    
 .addInte

add headers Interceptor to OkHttpClient constructor