// Path: app/src/main/java/io/dwak/holohackernews/app/network/HackerNewsService.java
// public interface HackerNewsService {
//     @GET("/news")
//     void getTopStories(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/news")
//     Observable<List<NodeHNAPIStory>> getTopStories();
// 
//     @GET("/news2")
//     void getTopStoriesPageTwo(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/news2")
//     Observable<List<NodeHNAPIStory>> getTopStoriesPageTwo();
// 
//     @GET("/newest")
//     void getNewestStories(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/newest")
//     Observable<List<NodeHNAPIStory>> getNewestStories();
// 
//     @GET("/best")
//     void getBestStories(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/best")
//     Observable<List<NodeHNAPIStory>> getBestStories();
// 
//     @GET("/show")
//     Observable<List<NodeHNAPIStory>> getShowStories();
// 
//     @GET("/shownew")
//     Observable<List<NodeHNAPIStory>> getShowNewStories();
// 
//     @GET("/ask")
//     Observable<List<NodeHNAPIStory>> getAskStories();
// 
//     @GET("/item/{itemId}")
//     void getItemDetails(@Path("itemId") long itemId, Callback<NodeHNAPIStoryDetail> callback);
// 
//     @GET("/item/{itemId}")
//     Observable<NodeHNAPIStoryDetail> getItemDetails(@Path("itemId") long itemId);
// 
// }
// 
// Path: app/src/main/java/io/dwak/holohackernews/app/network/LoganSquareConvertor.java
// public final class LoganSquareConvertor implements Converter {
// 
//     @Override
//     public Object fromBody(TypedInput body, Type type) throws ConversionException {
//         try {
//             // Check if the type contains a parametrized list
//             if (ParameterizedType.class.isAssignableFrom(type.getClass())) {
//                 // Grab the actual type parameter from the parametrized list and delegate to LoganSquare
//                 ParameterizedType parameterized = (ParameterizedType) type;
//                 return LoganSquare.parseList(body.in(), (Class) parameterized.getActualTypeArguments()[0]);
// 
//             } else {
//                 // Single elements get parsed immediately
//                 return LoganSquare.parse(body.in(), (Class) type);
//             }
//         } catch (Exception e) {
//             throw new ConversionException(e);
//         }
//     }
// 
//     @Override
//     public TypedOutput toBody(Object object) {
//         try {
//             // Check if the type contains a parametrized list
//             if (List.class.isAssignableFrom(object.getClass())) {
//                 // Convert the input to a list first, access the first element and serialize the list
//                 List<Object> list = (List<Object>) object;
//                 if (list.isEmpty()) {
//                     return new TypedString("[]");
//                 }
//                 else {
//                     Object firstElement = list.get(0);
//                     return new TypedString(LoganSquare.serialize(list, (Class<Object>) firstElement.getClass()));
//                 }
//             }
//             else {
//                 // Serialize single elements immediately
//                 return new TypedString(LoganSquare.serialize(object));
//             }
//         } catch (Exception e) {
//             throw new RuntimeException(e);
//         }
//     }
// }
// 
// Path: app/src/main/java/io/dwak/holohackernews/app/network/LoginService.java
// public interface LoginService {
//     @FormUrlEncoded
//     @POST("/login")
//     Observable<Response> login(@Field("go_to") String goTo, @Field("acct") String username, @Field("pw") String password);
// }
// 
// Path: app/src/main/java/io/dwak/holohackernews/app/network/UserService.java
// public interface UserService {
//     @FormUrlEncoded
//     @POST("/comment")
//     Observable<Object> postComment(@Header("Cookie") String cookie,
//                                    @Field("goto") String gotoParam,
//                                    @Field("hmac") String hmac,
//                                    @Field("parent") Long parentId,
//                                    @Field("text") String text);
// 
//     @GET("/vote")
//     Observable<Object> vote(@Header("Cookie") String cookie,
//                             @Query("for") Long parentId,
//                             @Query("dir") String direction,
//                             @Query("auth") String auth,
//                             @Query("goto") String gotoParam);
// }


import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import io.dwak.holohackernews.app.network.HackerNewsService;
import io.dwak.holohackernews.app.network.LoganSquareConvertor;
import io.dwak.holohackernews.app.network.LoginService;
import io.dwak.holohackernews.app.network.UserService;
import retrofit.RestAdapter;
import retrofit.client.OkClient;
                .setEndpoint("https://whispering-fortress-7282.herokuapp.com/")
                .build()
                .create(HackerNewsService.class);
    }

    @Provides
    @Singleton
    LoginService providesLoginService(@Named("retrofit-loglevel") RestAdapter.LogLevel logLevel,
                                      @Named("loganSquare") LoganSquareConvertor loganSquareConvertor,
                                      @Named("okclient") OkClient okClient) {
        return new RestAdapter.Builder()
                .setClient(okClient)
                .setLogLevel(logLevel)
                .setConverter(loganSquareConvertor)
                .setEndpoint("https://news.ycombinator.com")
                .build()
                .create(LoginService.class);
    }

    @Provides
    @Singleton
    UserService providesUserService(@Named("retrofit-loglevel") RestAdapter.LogLevel logLevel,
                                    @Named("loganSquare") LoganSquareConvertor loganSquareConvertor,
                                    @Named("okclient") OkClient okClient) {
        return new RestAdapter.Builder()
                .setClient(okClient)
                .setLogLevel(logLevel)
                .setConverter(loganSquareConvertor)
                .setEndpoint("https://news.ycombinator.com")
                .build()
// Path: app/src/main/java/io/dwak/holohackernews/app/network/HackerNewsService.java
// public interface HackerNewsService {
//     @GET("/news")
//     void getTopStories(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/news")
//     Observable<List<NodeHNAPIStory>> getTopStories();
// 
//     @GET("/news2")
//     void getTopStoriesPageTwo(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/news2")
//     Observable<List<NodeHNAPIStory>> getTopStoriesPageTwo();
// 
//     @GET("/newest")
//     void getNewestStories(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/newest")
//     Observable<List<NodeHNAPIStory>> getNewestStories();
// 
//     @GET("/best")
//     void getBestStories(Callback<List<NodeHNAPIStory>> callback);
// 
//     @GET("/best")
//     Observable<List<NodeHNAPIStory>> getBestStories();
// 
//     @GET("/show")
//     Observable<List<NodeHNAPIStory>> getShowStories();
// 
//     @GET("/shownew")
//     Observable<List<NodeHNAPIStory>> getShowNewStories();
// 
//     @GET("/ask")
//     Observable<List<NodeHNAPIStory>> getAskStories();
// 
//     @GET("/item/{itemId}")
//     void getItemDetails(@Path("itemId") long itemId, Callback<NodeHNAPIStoryDetail> callback);
// 
//     @GET("/item/{itemId}")
//     Observable<NodeHNAPIStoryDetail> getItemDetails(@Path("itemId") long itemId);
// 
// }
// 
// Path: app/src/main/java/io/dwak/holohackernews/app/network/LoganSquareConvertor.java
// public final class LoganSquareConvertor implements Converter {
// 
//     @Override
//     public Object fromBody(TypedInput body, Type type) throws ConversionException {
//         try {
//             // Check if the type contains a parametrized list
//             if (ParameterizedType.class.isAssignableFrom(type.getClass())) {
//                 // Grab the actual type parameter from the parametrized list and delegate to LoganSquare
//                 ParameterizedType parameterized = (ParameterizedType) type;
//                 return LoganSquare.parseList(body.in(), (Class) parameterized.getActualTypeArguments()[0]);
// 
//             } else {
//                 // Single elements get parsed immediately
//                 return LoganSquare.parse(body.in(), (Class) type);
//             }
//         } catch (Exception e) {
//             throw new ConversionException(e);
//         }
//     }
// 
//     @Override
//     public TypedOutput toBody(Object object) {
//         try {
//             // Check if the type contains a parametrized list
//             if (List.class.isAssignableFrom(object.getClass())) {
//                 // Convert the input to a list first, access the first element and serialize the list
//                 List<Object> list = (List<Object>) object;
//                 if (list.isEmpty()) {
//                     return new TypedString("[]");
//                 }
//                 else {
//                     Object firstElement = list.get(0);
//                     return new TypedString(LoganSquare.serialize(list, (Class<Object>) firstElement.getClass()));
//                 }
//             }
//             else {
//                 // Serialize single elements immediately
//                 return new TypedString(LoganSquare.serialize(object));
//             }
//         } catch (Exception e) {
//             throw new RuntimeException(e);
//         }
//     }
// }
// 
// Path: app/src/main/java/io/dwak/holohackernews/app/network/LoginService.java
// public interface LoginService {
//     @FormUrlEncoded
//     @POST("/login")
//     Observable<Response> login(@Field("go_to") String goTo, @Field("acct") String username, @Field("pw") String password);
// }
// 
// Path: app/src/main/java/io/dwak/holohackernews/app/network/UserService.java
// public interface UserService {
//     @FormUrlEncoded
//     @POST("/comment")
//     Observable<Object> postComment(@Header("Cookie") String cookie,
//                                    @Field("goto") String gotoParam,
//                                    @Field("hmac") String hmac,
//                                    @Field("parent") Long parentId,
//                                    @Field("text") String text);
// 
//     @GET("/vote")
//     Observable<Object> vote(@Header("Cookie") String cookie,
//                             @Query("for") Long parentId,
//                             @Query("dir") String direction,
//                             @Query("auth") String auth,
//                             @Query("goto") String gotoParam);
// }


// Path: app/src/main/java/io/dwak/holohackernews/app/dagger/module/NetworkServiceModule.java
import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import io.dwak.holohackernews.app.network.HackerNewsService;
import io.dwak.holohackernews.app.network.LoganSquareConvertor;
import io.dwak.holohackernews.app.network.LoginService;
import io.dwak.holohackernews.app.network.UserService;
import retrofit.RestAdapter;
import retrofit.client.OkClient;

                .setEndpoint("https://whispering-fortress-7282.herokuapp.com/")
                .build()
                .create(HackerNewsService.class);
    }

    @Provides
    @Singleton
    LoginService providesLoginService(@Named("retrofit-loglevel") RestAdapter.LogLevel logLevel,
                                      @Named("loganSquare") LoganSquareConvertor loganSquareConvertor,
                                      @Named("okclient") OkClient okClient) {
        return new RestAdapter.Builder()
                .setClient(okClient)
                .setLogLevel(logLevel)
                .setConverter(loganSquareConvertor)
                .setEndpoint("https://news.ycombinator.com")
                .build()
                .create(LoginService.class);
    }

    @Provides
    @Singleton
    UserService providesUserService(@Named("retrofit-loglevel") RestAdapter.LogLevel logLevel,
                                    @Named("loganSquare") LoganSquareConvertor loganSquareConvertor,
                                    @Named("okclient") OkClient okClient) {
        return new RestAdapter.Builder()
                .setClient(okClient)
                .setLogLevel(logLevel)
                .setConverter(loganSquareConvertor)
                .setEndpoint("https://news.ycombinator.com")
                .build()
                .create(UserService.class);