2026-03-28 15:42:58 -03:00

69 lines
2.0 KiB
Java

package com.magamochi.ingestion.client;
import com.magamochi.ingestion.model.dto.MangaDexMangaDTO;
import java.util.List;
import java.util.UUID;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.resilience.annotation.Retryable;
import org.springframework.web.bind.annotation.*;
@FeignClient(name = "mangaDex", url = "https://api.mangadex.org")
public interface MangaDexClient {
@GetMapping("/manga/{id}")
@Retryable(
maxRetries = 3,
delay = 1000,
multiplier = 2,
maxDelay = 5000,
includes = Exception.class)
MangaDexMangaDTO getManga(@PathVariable UUID id);
@GetMapping("/manga/{id}/feed")
@Retryable(
maxRetries = 3,
delay = 1000,
multiplier = 2,
maxDelay = 5000,
includes = Exception.class)
MangaDexMangaFeedDTO getMangaFeed(
@PathVariable UUID id, @RequestParam("contentRating[]") List<String> contentRating);
@GetMapping("/manga/{id}/feed")
@Retryable(
maxRetries = 3,
delay = 1000,
multiplier = 2,
maxDelay = 5000,
includes = Exception.class)
MangaDexMangaFeedDTO getMangaFeed(
@PathVariable UUID id,
@RequestParam int limit,
@RequestParam int offset,
@RequestParam("contentRating[]") List<String> contentRating);
@GetMapping("/at-home/server/{chapterId}")
@Retryable(
maxRetries = 3,
delay = 1000,
multiplier = 2,
maxDelay = 5000,
includes = Exception.class)
MangaChapterDataDTO getMangaChapter(@PathVariable UUID chapterId);
record MangaDexMangaFeedDTO(
List<MangaFeedData> data, Integer limit, Integer offset, Integer total) {
public record MangaFeedData(UUID id, String type, MangaFeedAttributes attributes) {
public record MangaFeedAttributes(
String volume,
String chapter,
String title,
String translatedLanguage,
Boolean isUnavailable) {}
}
}
record MangaChapterDataDTO(String baseUrl, ChapterData chapter) {
public record ChapterData(String hash, List<String> data) {}
}
}