package io.delphiplatform.api.v3.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import org.openapitools.jackson.nullable.JsonNullable;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.util.Objects;

import javax.validation.Valid;
import javax.validation.constraints.Pattern;

/**
 * Object containing the base details of a Playlist market rank
 */
public class PlaylistRankSimple {

    @JsonProperty("playlist_rank_id")
    private JsonNullable<Integer> playlistRankId = JsonNullable.undefined();

    @JsonProperty("playlist_id")
    private String playlistId;

    @JsonProperty("report_date")
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    private JsonNullable<LocalDate> reportDate = JsonNullable.undefined();

    @JsonProperty("rank")
    private JsonNullable<Integer> rank = JsonNullable.undefined();

    @JsonProperty("dsp_id")
    private String dspId;

    @JsonProperty("country_code")
    private String countryCode;

    public PlaylistRankSimple playlistRankId(Integer playlistRankId) {
        this.playlistRankId = JsonNullable.of(playlistRankId);
        return this;
    }

    /**
     * Get playlistRankId
     *
     * @return playlistRankId
     */
    public JsonNullable<Integer> getPlaylistRankId() {
        return playlistRankId;
    }

    public void setPlaylistRankId(JsonNullable<Integer> playlistRankId) {
        this.playlistRankId = playlistRankId;
    }

    public PlaylistRankSimple playlistId(String playlistId) {
        this.playlistId = playlistId;
        return this;
    }

    /**
     * Primary key identifier for Playlist
     *
     * @return playlistId
     */
    public String getPlaylistId() {
        return playlistId;
    }

    public void setPlaylistId(String playlistId) {
        this.playlistId = playlistId;
    }

    public PlaylistRankSimple reportDate(LocalDate reportDate) {
        this.reportDate = JsonNullable.of(reportDate);
        return this;
    }

    /**
     * ISO 8601 date in format `YYYY-MM-DD`
     *
     * @return reportDate
     */
    @Valid
    @Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2}$")
    public JsonNullable<LocalDate> getReportDate() {
        return reportDate;
    }

    public void setReportDate(JsonNullable<LocalDate> reportDate) {
        this.reportDate = reportDate;
    }

    public PlaylistRankSimple rank(Integer rank) {
        this.rank = JsonNullable.of(rank);
        return this;
    }

    /**
     * SME internal ranking
     *
     * @return rank
     */
    public JsonNullable<Integer> getRank() {
        return rank;
    }

    public void setRank(JsonNullable<Integer> rank) {
        this.rank = rank;
    }

    public PlaylistRankSimple dspId(String dspId) {
        this.dspId = dspId;
        return this;
    }

    /**
     * Primary key identifier for Dsp
     *
     * @return dspId
     */
    public String getDspId() {
        return dspId;
    }

    public void setDspId(String dspId) {
        this.dspId = dspId;
    }

    public PlaylistRankSimple countryCode(String countryCode) {
        this.countryCode = countryCode;
        return this;
    }

    /**
     * Typically a lower-case two letter code for the country
     *
     * @return countryCode
     */
    public String getCountryCode() {
        return countryCode;
    }

    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PlaylistRankSimple playlistRankSimple = (PlaylistRankSimple) o;
        return Objects.equals(this.playlistRankId, playlistRankSimple.playlistRankId) &&
            Objects.equals(this.playlistId, playlistRankSimple.playlistId) &&
            Objects.equals(this.reportDate, playlistRankSimple.reportDate) &&
            Objects.equals(this.rank, playlistRankSimple.rank) &&
            Objects.equals(this.dspId, playlistRankSimple.dspId) &&
            Objects.equals(this.countryCode, playlistRankSimple.countryCode);
    }

    @Override
    public int hashCode() {
        return Objects.hash(playlistRankId, playlistId, reportDate, rank, dspId, countryCode);
    }

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

        sb.append("    playlistRankId: ").append(toIndentedString(playlistRankId)).append("\n");
        sb.append("    playlistId: ").append(toIndentedString(playlistId)).append("\n");
        sb.append("    reportDate: ").append(toIndentedString(reportDate)).append("\n");
        sb.append("    rank: ").append(toIndentedString(rank)).append("\n");
        sb.append("    dspId: ").append(toIndentedString(dspId)).append("\n");
        sb.append("    countryCode: ").append(toIndentedString(countryCode)).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    ");
    }
}
