package io.delphiplatform.api.v3.model.video;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import org.openapitools.jackson.nullable.JsonNullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Object modeling the structure for a generic video analytics response. Currently only YouTube is supported, but the
 * DSP-agnostic design allows for easy extensibility for future use-cases.
 */
@JsonPropertyOrder(alphabetic = true)
public class VideoSummaryItems {

    @JsonProperty("count")
    private Integer count;

    @JsonProperty("items")
    private List<YouTubeSummaryItem> items = null;

    @JsonProperty("next_cursor")
    private JsonNullable<String> nextCursor;

    public VideoSummaryItems count(Integer count) {
        this.count = count;
        return this;
    }

    /**
     * The number of `items` returned in the response
     *
     * @return count
     */
    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public VideoSummaryItems items(List<YouTubeSummaryItem> items) {
        this.items = items;
        return this;
    }

    public VideoSummaryItems addItemsItem(YouTubeSummaryItem itemsItem) {
        if (this.items == null) {
            this.items = new ArrayList<>();
        }
        this.items.add(itemsItem);
        return this;
    }

    /**
     * Get items
     *
     * @return items
     */
    public List<YouTubeSummaryItem> getItems() {
        return items;
    }

    public void setItems(List<YouTubeSummaryItem> items) {
        this.items = items;
    }

    public VideoSummaryItems nextCursor(String nextCursor) {
        this.nextCursor = JsonNullable.of(nextCursor);
        return this;
    }

    public JsonNullable<String> getNextCursor() {
        return nextCursor;
    }

    public void setNextCursor(JsonNullable<String> nextCursor) {
        this.nextCursor = nextCursor;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        VideoSummaryItems videoSummaryItems = (VideoSummaryItems) o;
        return Objects.equals(this.count, videoSummaryItems.count) &&
            Objects.equals(this.items, videoSummaryItems.items) &&
            Objects.equals(this.nextCursor, videoSummaryItems.nextCursor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(count, items, nextCursor);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class VideoSummaryItems {\n");

        sb.append("    count: ").append(toIndentedString(count)).append("\n");
        sb.append("    items: ").append(toIndentedString(items)).append("\n");
        sb.append("    nextCursor: ").append(toIndentedString(nextCursor)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}

