138 lines
4.3 KiB
Java
138 lines
4.3 KiB
Java
package com.santiparra.yomitrack.api;
|
|
|
|
import com.google.gson.JsonObject;
|
|
import com.santiparra.yomitrack.db.entities.AnimeEntity;
|
|
import com.santiparra.yomitrack.db.entities.MangaEntity;
|
|
import com.santiparra.yomitrack.db.entities.UserEntity;
|
|
import com.santiparra.yomitrack.model.AniListMedia;
|
|
import com.santiparra.yomitrack.model.AnimePageResponse;
|
|
import com.santiparra.yomitrack.model.ApiResponse;
|
|
import com.santiparra.yomitrack.model.CommentModel;
|
|
import com.santiparra.yomitrack.model.LoginResponse;
|
|
import com.santiparra.yomitrack.model.MangaPageResponse;
|
|
import com.santiparra.yomitrack.model.RegisterResponse;
|
|
import com.santiparra.yomitrack.model.UserStatsResponse;
|
|
import com.santiparra.yomitrack.utils.ActivityLog;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import retrofit2.Call;
|
|
import retrofit2.http.Body;
|
|
import retrofit2.http.DELETE;
|
|
import retrofit2.http.Field;
|
|
import retrofit2.http.FormUrlEncoded;
|
|
import retrofit2.http.GET;
|
|
import retrofit2.http.HTTP;
|
|
import retrofit2.http.POST;
|
|
import retrofit2.http.PUT;
|
|
import retrofit2.http.Path;
|
|
import retrofit2.http.Query;
|
|
|
|
public interface ApiService {
|
|
|
|
// ---------------- Usuario ----------------
|
|
@POST("users/register")
|
|
Call<RegisterResponse> registerUser(@Body UserEntity user);
|
|
|
|
@POST("users/login")
|
|
Call<LoginResponse> loginUser(@Body UserEntity user);
|
|
|
|
@FormUrlEncoded
|
|
@POST("users/forgot-password")
|
|
Call<ApiResponse> forgotPassword(@Field("email") String email);
|
|
|
|
@FormUrlEncoded
|
|
@POST("users/reset-password")
|
|
Call<ApiResponse> resetPassword(
|
|
@Field("email") String email,
|
|
@Field("token") String token,
|
|
@Field("newPassword") String newPassword
|
|
);
|
|
|
|
// ---------------- Anime ----------------
|
|
@POST("anime/add")
|
|
Call<ApiResponse> insertAnime(@Body AnimeEntity anime);
|
|
|
|
// Scroll infinito: obtener lista paginada
|
|
@GET("/anime/list/{userId}")
|
|
Call<AnimePageResponse> getAnimes(
|
|
@Path("userId") int userId,
|
|
@Query("page") int page,
|
|
@Query("size") int size
|
|
);
|
|
|
|
@PUT("anime/{id}")
|
|
Call<ApiResponse> updateAnime(@Path("id") int animeId, @Body AnimeEntity anime);
|
|
|
|
@DELETE("anime/delete/{id}")
|
|
Call<ApiResponse> deleteAnime(@Path("id") int id);
|
|
|
|
// ---------------- Manga ----------------
|
|
@POST("manga/add")
|
|
Call<ApiResponse> insertManga(@Body MangaEntity manga);
|
|
|
|
@GET("/manga/list/{userId}")
|
|
Call<MangaPageResponse> getMangas(
|
|
@Path("userId") int userId,
|
|
@Query("page") int page,
|
|
@Query("size") int size
|
|
);
|
|
|
|
@GET("manga/user/{userId}/status/{status}")
|
|
Call<List<MangaEntity>> getMangaByUserAndStatus(
|
|
@Path("userId") int userId,
|
|
@Path("status") String status
|
|
);
|
|
|
|
@PUT("manga/{id}")
|
|
Call<ApiResponse> updateManga(@Path("id") int mangaId, @Body MangaEntity manga);
|
|
|
|
@DELETE("manga/delete/{id}")
|
|
Call<ApiResponse> deleteManga(@Path("id") int id);
|
|
|
|
// ---------------- Activity -------------------
|
|
|
|
@GET("users/{id}/stats")
|
|
Call<UserStatsResponse> getUserStats(@Path("id") int userId);
|
|
|
|
@GET("api/activity/list/{userId}")
|
|
Call<List<ActivityLog>> getActivityLog(@Path("userId") int userId);
|
|
|
|
@GET("api/activity/comments/{activityId}")
|
|
Call<List<CommentModel>> getCommentsByActivity(@Path("activityId") int activityId);
|
|
|
|
@GET("/api/activity/like/{userId}/{activityId}")
|
|
Call<JsonObject> checkLike(
|
|
@Path("userId") int userId,
|
|
@Path("activityId") int activityId
|
|
);
|
|
|
|
@GET("anime/user/{userId}/status/{status}")
|
|
Call<List<AnimeEntity>> getAnimeByUserAndStatus(
|
|
@Path("userId") int userId,
|
|
@Path("status") String status
|
|
);
|
|
|
|
@POST("api/activity/like")
|
|
Call<JsonObject> postLike(@Body JsonObject body);
|
|
|
|
@POST("api/activity/comment")
|
|
Call<JsonObject> postComment(@Body JsonObject body);
|
|
|
|
@POST("api/activity/add")
|
|
Call<JsonObject> postActivity(@Body Map<String, Object> body);
|
|
|
|
@HTTP(method = "DELETE", path = "api/activity/like/remove", hasBody = true)
|
|
Call<JsonObject> deleteLike(@Body JsonObject body);
|
|
|
|
|
|
// ---------------- AniList API ----------------
|
|
|
|
@GET("anilist/search")
|
|
Call<List<AniListMedia>> searchAniList(@Query("query") String query, @Query("type") String type);
|
|
|
|
}
|