Search in sources :

Example 1 with CharactersDto

use of com.karumi.marvelapiclient.model.CharactersDto in project Rosie by Karumi.

the class CharactersApiDataSource method getPage.

@Override
public PaginatedCollection<Character> getPage(Page page) throws MarvelApiException {
    int offset = page.getOffset();
    int limit = page.getLimit();
    MarvelResponse<CharactersDto> charactersApiResponse = characterApiClient.getAll(offset, limit);
    CharactersDto charactersDto = charactersApiResponse.getResponse();
    Collection<Character> characters = mapper.reverseMap(charactersDto.getCharacters());
    PaginatedCollection<Character> charactersPage = new PaginatedCollection<>(characters);
    charactersPage.setPage(page);
    charactersPage.setHasMore(charactersDto.getOffset() + charactersDto.getCount() < charactersDto.getTotal());
    return charactersPage;
}
Also used : Character(com.karumi.rosie.sample.characters.domain.model.Character) CharactersDto(com.karumi.marvelapiclient.model.CharactersDto) PaginatedCollection(com.karumi.rosie.repository.PaginatedCollection)

Aggregations

CharactersDto (com.karumi.marvelapiclient.model.CharactersDto)1 PaginatedCollection (com.karumi.rosie.repository.PaginatedCollection)1 Character (com.karumi.rosie.sample.characters.domain.model.Character)1