Newer
Older
CitrusClient / app / src / main / java / com / example / citrusclient / rest / ScheduleRest.java
  1. package com.example.citrusclient.rest;
  2.  
  3. import com.example.citrusclient.models.Schedule;
  4.  
  5. import java.util.HashMap;
  6.  
  7. import retrofit2.Call;
  8. import retrofit2.http.DELETE;
  9. import retrofit2.http.Field;
  10. import retrofit2.http.FormUrlEncoded;
  11. import retrofit2.http.GET;
  12. import retrofit2.http.POST;
  13. import retrofit2.http.PUT;
  14. import retrofit2.http.Path;
  15. import retrofit2.http.Query;
  16.  
  17. public interface ScheduleRest {
  18.  
  19. String BASE_URL = "accounts/{account_id}/schedule";
  20.  
  21. @GET(BASE_URL)
  22. Call<HashMap<Integer, //年
  23. HashMap<Integer, //月
  24. HashMap<Integer, //日
  25. HashMap<Integer, //Id
  26. Schedule>>>>> getAllSchedules(
  27. @Path("account_id") String accountId,
  28. @Query("token") String token
  29. );
  30.  
  31. @GET(BASE_URL + "/{year}")
  32. Call<HashMap<Integer, //月
  33. HashMap<Integer, //日
  34. HashMap<Integer, //Id
  35. Schedule>>>> getSchedulesByYear(
  36. @Path("account_id") String accountId,
  37. @Path("year") int year,
  38. @Query("token") String token
  39. );
  40.  
  41. @GET(BASE_URL + "/{year}/{month}")
  42. Call<HashMap<Integer, //日
  43. HashMap<Integer, //Id
  44. Schedule>>> getSchedulesByMonth(
  45. @Path("account_id") String accountId,
  46. @Path("year") int year,
  47. @Path("month") int month,
  48. @Query("token") String token
  49. );
  50.  
  51. @GET(BASE_URL + "/{year}/{month}/{day}")
  52. Call<HashMap<Integer, //Id
  53. Schedule>> getSchedulesByDay(
  54. @Path("account_id") String accountId,
  55. @Path("year") int year,
  56. @Path("month") int month,
  57. @Path("day") int day,
  58. @Query("token") String token
  59. );
  60.  
  61. @GET(BASE_URL + "/{year}/{month}/{day}")
  62. Call<HashMap<Integer, //Id
  63. Schedule>> getSchedulesByDayAndBook(
  64. @Path("account_id") String accountId,
  65. @Path("year") int year,
  66. @Path("month") int month,
  67. @Path("day") int day,
  68. @Query("book_id") int bookId,
  69. @Query("token") String token
  70. );
  71.  
  72. @GET(BASE_URL + "/{year}/{month}")
  73. Call<HashMap<Integer, //日
  74. HashMap<Integer, //Id
  75. Schedule>>> getScheduleByMonthAndBookId(
  76. @Path("account_id") String accountId,
  77. @Path("year") int year,
  78. @Path("month") int month,
  79. @Query("book_id") int bookId,
  80. @Query("token") String token
  81. );
  82.  
  83. @GET(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
  84. Call<Schedule> getScheduleById(
  85. @Path("account_id") String accountId,
  86. @Path("year") int year,
  87. @Path("month") int month,
  88. @Path("day") int day,
  89. @Path("schedule_id") int id,
  90. @Query("token") String token
  91. );
  92.  
  93.  
  94.  
  95. @FormUrlEncoded
  96. @POST(BASE_URL + "/{year}/{month}/{day}")
  97. Call<Schedule> createSchedule(
  98. @Path("account_id") String accountId,
  99. @Path("year") int year,
  100. @Path("month") int month,
  101. @Path("day") int day,
  102. @Field("title") String title,
  103. @Field("start_time") String startTime,
  104. @Field("end_time") String endTime,
  105. @Field("book_id") int bookId,
  106. @Field("token") String token
  107. );
  108.  
  109. @DELETE(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
  110. Call<String> deleteScheduleById(
  111. @Path("account_id") String accountId,
  112. @Path("year") int year,
  113. @Path("month") int month,
  114. @Path("day") int day,
  115. @Path("schedule_id") int scheduleId,
  116. @Query("token") String token
  117. );
  118.  
  119. @FormUrlEncoded
  120. @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
  121. Call<String> putStartTime(
  122. @Path("account_id") String accountId,
  123. @Path("year") int year,
  124. @Path("month") int month,
  125. @Path("day") int day,
  126. @Path("schedule_id") int scheduleId,
  127. @Field("token") String token,
  128. @Field("start_time") String startTime
  129. );
  130.  
  131. @FormUrlEncoded
  132. @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
  133. Call<String> putEndTime(
  134. @Path("account_id") String accountId,
  135. @Path("year") int year,
  136. @Path("month") int month,
  137. @Path("day") int day,
  138. @Path("schedule_id") int scheduleId,
  139. @Field("token") String token,
  140. @Field("end_time") String endTime
  141. );
  142.  
  143. @FormUrlEncoded
  144. @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
  145. Call<String> putTitle(
  146. @Path("account_id") String accountId,
  147. @Path("year") int year,
  148. @Path("month") int month,
  149. @Path("day") int day,
  150. @Path("schedule_id") int scheduleId,
  151. @Field("token") String token,
  152. @Field("title") String title
  153. );
  154.  
  155. @FormUrlEncoded
  156. @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
  157. Call<String> putBookId(
  158. @Path("account_id") String accountId,
  159. @Path("year") int year,
  160. @Path("month") int month,
  161. @Path("day") int day,
  162. @Path("schedule_id") int scheduleId,
  163. @Field("token") String token,
  164. @Field("book_id") int bookId
  165. );
  166.  
  167. }