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

com.github.twitch4j.helix.domain.ExtensionLiveChannelsList Maven / Gradle / Ivy

There is a newer version: 1.23.0
Show newest version
package com.github.twitch4j.helix.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.Optional;

@Data
@Setter(AccessLevel.PRIVATE)
public class ExtensionLiveChannelsList {

    /**
     * One page of live channels that have installed or activated a specific Extension.
     */
    @JsonProperty("data")
    private List channels;

    @Getter(AccessLevel.PRIVATE)
    private Object pagination;

    /**
     * @return the cursor to specify in the next call to obtain the next page of results, in an optional wrapper
     * @implNote Pagination for this endpoint is currently broken
     * in multiple respects
     */
    @JsonIgnore
    public Optional getCursor() {
        // Currently, pagination is returned directly as a string, which departs from all of the other helix endpoints
        // In the future, Twitch may fix the above inconsistency and return an object that contains a string
        return Optional.ofNullable(pagination instanceof Map ? ((Map) pagination).get("cursor") : pagination)
            .filter(c -> c instanceof String)
            .map(c -> (String) c)
            .filter(StringUtils::isNotBlank);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy