diff --git a/app/src/main/java/com/example/citrusclient/models/Book.java b/app/src/main/java/com/example/citrusclient/models/Book.java index f69ff74..19140a2 100644 --- a/app/src/main/java/com/example/citrusclient/models/Book.java +++ b/app/src/main/java/com/example/citrusclient/models/Book.java @@ -1,4 +1,33 @@ package com.example.citrusclient.models; public class Book { + + private int bookId; + private String title; + private boolean publicity; + private String color; + private String accountId; + + + public Book(String accountId, Integer bookId, String title, boolean publicity, String color, String time) { + this.accountId = accountId; + this.bookId = bookId; + this.title = title; + this.publicity = publicity; + this.color = color; + } + + //Setter + public void setTitle(String t) {title = t;} + public void setPublicity(boolean p) {publicity = p;} + public void setColor(String c) {color = c;} + public void setBookId(int id) {bookId = id;} + public void setAccountId(String a) {accountId = a;} + + //Getter + public String getTitle() {return title;} + public boolean getPublicity() {return publicity;} + public String getColor() {return color;} + public int getBookId() {return bookId;} + public String getAccountId() {return accountId;} } diff --git a/app/src/main/java/com/example/citrusclient/rest/BooksRest.java b/app/src/main/java/com/example/citrusclient/rest/BooksRest.java index 53727ae..13cbfcd 100644 --- a/app/src/main/java/com/example/citrusclient/rest/BooksRest.java +++ b/app/src/main/java/com/example/citrusclient/rest/BooksRest.java @@ -1,7 +1,7 @@ package com.example.citrusclient.rest; -import java.util.Collection; -import java.util.HashMap; +import com.example.citrusclient.models.Book; + import retrofit2.Call; import retrofit2.Response; @@ -12,18 +12,84 @@ import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; +import retrofit2.http.Query; public interface BooksRest { + //本の一覧を返す @GET("accounts/{account_id}/books") - Call getBooks( - @Path("account_id") String account_id + Call getBooks( + @Path("account_id") String account_id, + @Query("token") String token ); + //本の新規作成 @FormUrlEncoded @POST("accounts/{account_id}/books") - Call createBook( - @Path("account_id") String account_id + Call createBook( + @Path("account_id") String account_id, + @Field("title") String title, + @Field("color") String color, + @Field("publicity") boolean publicity, + @Field("token") String token + ); + //本の情報を取得 + @GET("accounts/{account_id}/books/{book_id}") + Call getBook( + @Path("account_id") String account_id, + @Path("book_id") Integer book_id, + @Query("token") String token + ); + + //本の削除 + @DELETE("accounts/{account_id}/books/{book_id}") + Call deleteBook( + @Path("account_id") String account_id, + @Path("book_id") Integer book_id, + @Query("token") String token + ); + + //本のタイトルを返す(指定したbook_idの本のタイトルを返す) + @GET("accounts/{account_id}/books/{book_id}/title") + Call getTitle( + @Path("account_id") String account_id, + @Path("book_id") Integer book_id, + @Query("token") String token + ); + + //本のタイトルを変更(指定したbook_idの本のタイトルを変更する) + @PUT("accounts/{account_id}/books/{book_id}/title") + Call putTitle( + @Path("account_id") String account_id, + @Path("book_id") Integer book_id, + @Field("title") String title, + @Field("token") String token + ); + + //本の公開情報を返す(指定したbook_idの本の公開状態を返す) + @GET("accounts/{account_id}/books/{book_id}/public") + Call getPublicity( + @Path("account_id") String account_id, + @Path("book_id") Integer book_id, + @Query("token") String token + ); + + //公開状態を変更する(指定された本の公開状態を変更する) + @PUT("accounts/{account_id}/books/{book_id}/public") + Call putPublicity( + @Path("account_id") String account_id, + @Path("book_id") Integer book_id, + @Field("publicity") Boolean publicity, + @Field("token") String token + ); + + //本の色を変更する(book_idを指定して本の色を変更する) + @PUT("accounts/{account_id}/books/{book_id}/color") + Call putColor( + @Path("account_id") String account_id, + @Path("book_id") Integer book_id, + @Field("color") String color, + @Field("token") String token ); }