Newer
Older
CitrusClient / app / src / main / java / com / example / citrusclient / rest / TodosRest.java
  1. package com.example.citrusclient.rest;
  2.  
  3. import com.example.citrusclient.models.Todo;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7.  
  8.  
  9. import retrofit2.Call;
  10. import retrofit2.Response;
  11. import retrofit2.http.DELETE;
  12. import retrofit2.http.Field;
  13. import retrofit2.http.FormUrlEncoded;
  14. import retrofit2.http.GET;
  15. import retrofit2.http.POST;
  16. import retrofit2.http.PUT;
  17. import retrofit2.http.Path;
  18. import retrofit2.http.Query;
  19.  
  20. public interface TodosRest {
  21.  
  22. @GET("accounts/{account_id}/books/{book_id}/todos")
  23. Call<HashMap<Integer, HashMap<Integer, HashMap<Integer, HashMap<Integer, Todo>>>>> getAllTodos(
  24. @Path("account_id") String accountId,
  25. @Path("book_id") Integer bookId,
  26. @Query("token") String token
  27. );
  28.  
  29. @GET("accounts/{account_id}/books/{book_id}/todos/{year}/{month}")
  30. Call<HashMap<Integer, HashMap<Integer, Todo>>> getTodosByMonth(
  31. @Path("account_id") String accountId,
  32. @Path("book_id") Integer bookId,
  33. @Path("year") Integer year,
  34. @Path("month") Integer month,
  35. @Query("token") String token
  36. );
  37.  
  38. @GET("accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}")
  39. Call<HashMap<Integer, Todo>> getTodosByDay(
  40. @Path("account_id") String accountId,
  41. @Path("book_id") Integer bookId,
  42. @Path("year") Integer year,
  43. @Path("month") Integer month,
  44. @Path("day") Integer day,
  45. @Query("token") String token
  46. );
  47.  
  48. @GET("accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}")
  49. Call<Todo> getTodoById(
  50. @Path("account_id") String accountId,
  51. @Path("book_id") Integer bookId,
  52. @Path("year") Integer year,
  53. @Path("month") Integer month,
  54. @Path("day") Integer day,
  55. @Path("todo_id") Integer todoId,
  56. @Query("token") String token
  57. );
  58.  
  59. @FormUrlEncoded
  60. @POST("accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}")
  61. Call<Todo> createTodo(
  62. @Path("account_id") String accountId,
  63. @Path("book_id") Integer bookId,
  64. @Path("year") Integer year,
  65. @Path("month") Integer month,
  66. @Path("day") Integer day,
  67. @Field("title") String title,
  68. @Field("token") String token
  69. );
  70. @FormUrlEncoded
  71. @PUT("accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}/check")
  72. Call<Void> setCheck(
  73. @Path("account_id") String accountId,
  74. @Path("book_id") Integer bookId,
  75. @Path("year") Integer year,
  76. @Path("month") Integer month,
  77. @Path("day") Integer day,
  78. @Path("todo_id") Integer todoId,
  79. @Field("check") boolean check,
  80. @Field("token") String token
  81. );
  82.  
  83. @DELETE("accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}")
  84. Call<Void> deleteTodoById(
  85. @Path("account_id") String accountId,
  86. @Path("book_id") Integer bookId,
  87. @Path("year") Integer year,
  88. @Path("month") Integer month,
  89. @Path("day") Integer day,
  90. @Path("todo_id") Integer todoId,
  91. @Query("token") String token
  92. );
  93.  
  94.  
  95. }