diff --git a/app/src/main/java/com/example/citrusclient/rest/FavoritesRest.java b/app/src/main/java/com/example/citrusclient/rest/FavoritesRest.java index 8cf4caa..0e3dd95 100644 --- a/app/src/main/java/com/example/citrusclient/rest/FavoritesRest.java +++ b/app/src/main/java/com/example/citrusclient/rest/FavoritesRest.java @@ -1,4 +1,62 @@ package com.example.citrusclient.rest; +import java.util.HashMap; +import java.util.HashSet; + +import retrofit2.Call; +import retrofit2.http.DELETE; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.PUT; +import retrofit2.http.Path; +import retrofit2.http.Query; + public interface FavoritesRest { + //主{account_id}がいいねした本の一覧 + @FormUrlEncoded + @GET("accounts/{account_id}/favorites") + Call>> getFavoritesBooks( + @Path("account_id") String accountId, + @Query("token") String token + ); + + //主{account_id}がいいねした誰か{other_account_id}の本の一覧 + @FormUrlEncoded + @GET("accounts/{account_id}/favorites/{other_account_id}") + Call> getFavoritesBooksById( + @Path("account_id") String accountId, + @Path("other_account_id") String otherAccountId, + @Query("token") String token + ); + + //主{account_id}のある本{book_id}をいいねした人の一覧 + @FormUrlEncoded + @GET("accounts/{account_id}/books/{book_id}/favorited") + Call> getFavoritedAccount( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Query("token") String token + ); + + //主{account_id}のある本{book_id}を他の人{other_account_id}がいいねする + @FormUrlEncoded + @PUT("accounts/{account_id}/books/{book_id}/favorited/{other_account_id}") + Call putFavorite( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("other_account_id") String otherAccountId, + @Field("token") String token + ); + + //主{account_id}のある本{book_id}を他の人{other_account_id}がいいねを解除する + @FormUrlEncoded + @DELETE("accounts/{account_id}/books/{book_id}/favorited/{other_account_id}") + Call removeFavorite( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("other_account_id") String otherAccountId, + @Query("token") String token + ); + }