All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.elypia.elypiai.twitch.StreamPaginator Maven / Gradle / Ivy

The newest version!
package com.elypia.elypiai.twitch;

import com.elypia.elypiai.restutils.RestAction;
import com.elypia.elypiai.restutils.impl.IRestPaginator;
import retrofit2.Call;

import java.io.IOException;
import java.util.List;

public class StreamPaginator implements IRestPaginator {

    private Twitch twitch;
    private TwitchQuery query;
    private int limit;
    private String cursor;

    public StreamPaginator(Twitch twitch, TwitchQuery query, int limit) {
        this.twitch = twitch;
        this.query = query;
        this.limit = limit;
    }

    @Override
    public List next() throws IOException {
        Call streamers = twitch.getService().getStreams(
            query.getUserIds(),
            query.getUsernames(),
            query.getGames(),
            limit,
            cursor
        );

        StreamPage page = new RestAction<>(streamers).complete();
        List streams = page.getStreamers();
        cursor = page.getCursor();

        return !streams.isEmpty() ? streams : null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy