diff --git a/app/src/main/java/com/example/citrusclient/models/Todo.java b/app/src/main/java/com/example/citrusclient/models/Todo.java new file mode 100644 index 0000000..eb1d9a9 --- /dev/null +++ b/app/src/main/java/com/example/citrusclient/models/Todo.java @@ -0,0 +1,40 @@ +package com.example.citrusclient.models; + +public class Todo { + + String accountId; + Integer bookId; + String title; + boolean check; + int year; + int month; + int day; + Integer todoId; + + //セッター + public void setAccountId(String aid) {accountId = aid;} + public void setBookId(Integer bid) {bookId = bid;} + public void setTitle(String t) {title = t;} + public void setCheck(boolean c) {check = c;} + public void setYear(int y) {year = y;} + public void setMonth(int m) {month = m;} + public void setDay(int d) {day = d;} + public void setTodoId(Integer t) {todoId = t;} + + //ゲッター + public String getAccountId() {return accountId;} + public Integer getBookId(){return bookId;} + public String getTitle() {return title;} + + public boolean getCheck() {return check;} + + public int getYear() {return year;} + + public int getMonth() {return month;} + + public int getDay() {return day;} + + public Integer getTodoId() { + return todoId; + } +} diff --git a/app/src/main/java/com/example/citrusclient/rest/TodosRest.java b/app/src/main/java/com/example/citrusclient/rest/TodosRest.java index 5e169ab..88c6ad8 100644 --- a/app/src/main/java/com/example/citrusclient/rest/TodosRest.java +++ b/app/src/main/java/com/example/citrusclient/rest/TodosRest.java @@ -1,5 +1,95 @@ package com.example.citrusclient.rest; +import com.example.citrusclient.models.Todo; + +import java.util.ArrayList; +import java.util.HashMap; + + +import retrofit2.Call; +import retrofit2.Response; +import retrofit2.http.DELETE; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Path; +import retrofit2.http.Query; + public interface TodosRest { + @GET("/accounts/{account_id}/books/{book_id}/todos") + Call> getAllTodos( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Query("token") String token + ); + + @GET("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}") + Call> getTodosByMonth( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("year") Integer year, + @Path("month") Integer month, + @Query("token") String token + ); + + @GET("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}") + Call> getTodosByDay( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("year") Integer year, + @Path("month") Integer month, + @Path("day") Integer day, + @Query("token") String token + ); + + @GET("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}") + Call getTodoById( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("year") Integer year, + @Path("month") Integer month, + @Path("day") Integer day, + @Path("todo_id") Integer todoId, + @Query("token") String token + ); + + @FormUrlEncoded + @POST("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}") + Call createTodo( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("year") Integer year, + @Path("month") Integer month, + @Path("day") Integer day, + @Field("title") String title, + @Field("token") String token + ); + @FormUrlEncoded + @PUT("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}/check") + Call setCheck( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("year") Integer year, + @Path("month") Integer month, + @Path("day") Integer day, + @Path("todo_id") Integer todoId, + @Field("check") boolean check, + @Field("token") String token + ); + + @DELETE("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}") + Call deleteTodoById( + @Path("account_id") String accountId, + @Path("book_id") Integer bookId, + @Path("year") Integer year, + @Path("month") Integer month, + @Path("day") Integer day, + @Path("todo_id") Integer todoId, + @Query("token") String token + ); + + }