Advertisement
GeorgePashev_88

ContactAPI Retrofit Interface

Apr 29th, 2024
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. package com.example.kontakti;
  2.  
  3. import java.util.List;
  4.  
  5. import retrofit2.Call;
  6. import retrofit2.http.Body;
  7. import retrofit2.http.GET;
  8. import retrofit2.http.DELETE;
  9. import retrofit2.http.POST;
  10. import retrofit2.http.PUT;
  11. import retrofit2.http.Path;
  12.  
  13. public interface ContactAPI {
  14.     public class message{
  15.         public String status;
  16.         public message(message m){
  17.             this.status = m.status;
  18.         }
  19.         public message(String _status){
  20.             this.status = _status;
  21.         }
  22.     }
  23.     public class  contacts{
  24.         public int ID;
  25.         public String name;
  26.         public String address;
  27.         public String phone;
  28.         public String email;
  29.         public contacts(contacts m){
  30.             ID = m.ID;
  31.             name = m.name;
  32.             address = m.address;
  33.             phone = m.phone;
  34.             email = m.email;
  35.         }
  36.         public contacts(int _ID, String _name, String _address,
  37.                         String _phone, String _email){
  38.             ID = _ID;
  39.             name = _name;
  40.             address = _address;
  41.             phone = _phone;
  42.             email = _email;
  43.         }
  44.     }
  45.     @GET("/api/users")
  46.     public Call<List<contacts>> api_users();
  47.  
  48.     @GET("/api/users/{id}")
  49.     public Call<contacts> api_get_user(@Path("id") int id);
  50.  
  51.     @POST("/api/users/add")
  52.     public Call<contacts> api_add_user(@Body contacts c);
  53.  
  54.     @PUT("/api/users/update")
  55.     public Call<contacts> api_update_user(@Body contacts c);
  56.  
  57.     @DELETE("/api/users/delete/{id}")
  58.     public Call<message> api_delete_user(@Path("id") int id);
  59.  
  60.  
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement