Newer
Older
NemophilaClient / app / src / main / java / com / example / nemophila / resources / AccountsRest.java
Kai Kimoto P McGraw on 29 Jun 2023 1 KB Merge pull request #124 from nitta-lab-2023/myPageAct
  1. package com.example.nemophila.resources;
  2.  
  3. //import android.accounts.Account;
  4.  
  5. import com.example.nemophila.entities.AccountJson;
  6. import com.example.nemophila.entities.PostJson;
  7.  
  8. import java.util.Collection;
  9. import java.util.HashMap;
  10.  
  11. import retrofit2.Call;
  12. import retrofit2.Response;
  13. import retrofit2.http.DELETE;
  14. import retrofit2.http.Field;
  15. import retrofit2.http.FormUrlEncoded;
  16. import retrofit2.http.GET;
  17. import retrofit2.http.POST;
  18. import retrofit2.http.PUT;
  19. import retrofit2.http.Path;
  20.  
  21. public interface AccountsRest {
  22. @GET("accounts")
  23. Call<HashMap> getAccounts();
  24.  
  25. @FormUrlEncoded
  26. @POST("accounts")
  27. Call<AccountJson> createAccounts(
  28. @Field("name") String name,
  29. @Field("pw") String pw
  30. );
  31.  
  32. @GET("accounts/{uid}")
  33. Call<AccountJson> getAccount(
  34. @Path("uid") String uid
  35. );
  36.  
  37. @DELETE("accounts/{uid}")
  38. Call<Void> deleteAccount(
  39. @Path("uid") String uid,
  40. @Field("token") String token
  41. );
  42.  
  43. @FormUrlEncoded
  44. @POST("accounts/{uid}/login")
  45. Call<AccountJson> getAccounts(
  46. @Path("uid") String uid,
  47. @Field("pw")String pw
  48. );
  49.  
  50. @FormUrlEncoded
  51. @PUT("accounts/{uid}/pw")
  52. Call<Void> changePw(
  53. @Path("uid") String uid,
  54. @Field("oldPw") String oldPw,
  55. @Field("newPw") String newPw,
  56. @Field("token") String token
  57. );
  58.  
  59. @FormUrlEncoded
  60. @PUT("accounts/{uid}/name")
  61. Call<Void> changeName(
  62. @Path("uid") String uid,
  63. @Field("name") String name,
  64. @Field("token") String token
  65. );
  66.  
  67. @GET("accounts/{uid}/posts")
  68. Call<Collection<PostJson>> getAccountPosts(
  69. @Path("uid") String uid
  70. );
  71.  
  72. @DELETE("shops/{sid}/posts/{uid}/{pid}")
  73. Call<Void> deletePost(
  74. @Path("sid") String sid,
  75. @Path("uid") String uid,
  76. @Path("pid") String pid,
  77. @Field("token") String token
  78. );
  79. }