public MarvelResponse<ComicDto> getComic(String comicId) throws MarvelApiException { if (comicId == null || comicId.isEmpty()) { throw new IllegalArgumentException("The ComicId must not be null or empty"); } ComicApiRest api = getApi(ComicApiRest.class); Call<MarvelResponse<ComicsDto>> call = api.getComic(comicId); MarvelResponse<ComicsDto> comics = execute(call); ComicsDto comicsDto = comics.getResponse(); if (comicsDto != null && comicsDto.getCount() > 0) { ComicDto comicDto = comicsDto.getComics().get(0); MarvelResponse<ComicDto> comicResponse = new MarvelResponse<>(comics); comicResponse.setResponse(comicDto); return comicResponse; } else { throw new MarvelApiException("Comic not found", null); } } }
public MarvelResponse<SeriesDto> getSeriesById(String seriesId) throws MarvelApiException { if (seriesId == null || seriesId.isEmpty()) { throw new IllegalArgumentException("The seriesId must not be null or empty"); } SeriesApiRest api = getApi(SeriesApiRest.class); Call<MarvelResponse<SeriesCollectionDto>> call = api.getSerie(seriesId); MarvelResponse<SeriesCollectionDto> series = execute(call); SeriesCollectionDto seriesCollectionDto = series.getResponse(); if (seriesCollectionDto != null && seriesCollectionDto.getCount() > 0) { SeriesDto seriesDto = seriesCollectionDto.getSeries().get(0); MarvelResponse<SeriesDto> serieResponse = new MarvelResponse<>(series); serieResponse.setResponse(seriesDto); return serieResponse; } else { throw new MarvelApiException("Series not found", null); } }
public MarvelResponse<CharacterDto> getCharacter(String characterId) throws MarvelApiException { if (characterId == null || characterId.isEmpty()) { throw new IllegalArgumentException("The CharacterId must not be null or empty"); } CharacterApiRest api = getApi(CharacterApiRest.class); Call<MarvelResponse<CharactersDto>> call = api.getCharacter(characterId); MarvelResponse<CharactersDto> characters = execute(call); CharactersDto charactersDto = characters.getResponse(); if (charactersDto != null && charactersDto.getCount() > 0) { CharacterDto characterDto = charactersDto.getCharacters().get(0); MarvelResponse<CharacterDto> characterResponse = new MarvelResponse<>(characters); characterResponse.setResponse(characterDto); return characterResponse; } else { throw new MarvelApiException("Character not found", null); } } }