/*
 * Jellyfin API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 10.11.6
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

package org.openhab.binding.jellyfin.internal.gen.current.model;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.OffsetDateTime;
import java.util.Objects;
import java.util.StringJoiner;
import java.util.UUID;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Class ReadyRequest.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class ReadyRequestDto {
    public static final String JSON_PROPERTY_WHEN = "When";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime when;

    public static final String JSON_PROPERTY_POSITION_TICKS = "PositionTicks";
    private @org.eclipse.jdt.annotation.Nullable Long positionTicks;

    public static final String JSON_PROPERTY_IS_PLAYING = "IsPlaying";
    private @org.eclipse.jdt.annotation.Nullable Boolean isPlaying;

    public static final String JSON_PROPERTY_PLAYLIST_ITEM_ID = "PlaylistItemId";
    private @org.eclipse.jdt.annotation.Nullable UUID playlistItemId;

    public ReadyRequestDto() {
    }

    public ReadyRequestDto when(@org.eclipse.jdt.annotation.Nullable OffsetDateTime when) {
        this.when = when;
        return this;
    }

    /**
     * Gets or sets when the request has been made by the client.
     * 
     * @return when
     */
    @JsonProperty(value = JSON_PROPERTY_WHEN)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getWhen() {
        return when;
    }

    @JsonProperty(value = JSON_PROPERTY_WHEN)
    public void setWhen(@org.eclipse.jdt.annotation.Nullable OffsetDateTime when) {
        this.when = when;
    }

    public ReadyRequestDto positionTicks(@org.eclipse.jdt.annotation.Nullable Long positionTicks) {
        this.positionTicks = positionTicks;
        return this;
    }

    /**
     * Gets or sets the position ticks.
     * 
     * @return positionTicks
     */
    @JsonProperty(value = JSON_PROPERTY_POSITION_TICKS)
    public @org.eclipse.jdt.annotation.Nullable Long getPositionTicks() {
        return positionTicks;
    }

    @JsonProperty(value = JSON_PROPERTY_POSITION_TICKS)
    public void setPositionTicks(@org.eclipse.jdt.annotation.Nullable Long positionTicks) {
        this.positionTicks = positionTicks;
    }

    public ReadyRequestDto isPlaying(@org.eclipse.jdt.annotation.Nullable Boolean isPlaying) {
        this.isPlaying = isPlaying;
        return this;
    }

    /**
     * Gets or sets a value indicating whether the client playback is unpaused.
     * 
     * @return isPlaying
     */
    @JsonProperty(value = JSON_PROPERTY_IS_PLAYING)
    public @org.eclipse.jdt.annotation.Nullable Boolean getIsPlaying() {
        return isPlaying;
    }

    @JsonProperty(value = JSON_PROPERTY_IS_PLAYING)
    public void setIsPlaying(@org.eclipse.jdt.annotation.Nullable Boolean isPlaying) {
        this.isPlaying = isPlaying;
    }

    public ReadyRequestDto playlistItemId(@org.eclipse.jdt.annotation.Nullable UUID playlistItemId) {
        this.playlistItemId = playlistItemId;
        return this;
    }

    /**
     * Gets or sets the playlist item identifier of the playing item.
     * 
     * @return playlistItemId
     */
    @JsonProperty(value = JSON_PROPERTY_PLAYLIST_ITEM_ID)
    public @org.eclipse.jdt.annotation.Nullable UUID getPlaylistItemId() {
        return playlistItemId;
    }

    @JsonProperty(value = JSON_PROPERTY_PLAYLIST_ITEM_ID)
    public void setPlaylistItemId(@org.eclipse.jdt.annotation.Nullable UUID playlistItemId) {
        this.playlistItemId = playlistItemId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ReadyRequestDto readyRequestDto = (ReadyRequestDto) o;
        return Objects.equals(this.when, readyRequestDto.when)
                && Objects.equals(this.positionTicks, readyRequestDto.positionTicks)
                && Objects.equals(this.isPlaying, readyRequestDto.isPlaying)
                && Objects.equals(this.playlistItemId, readyRequestDto.playlistItemId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(when, positionTicks, isPlaying, playlistItemId);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class ReadyRequestDto {\n");
        sb.append("    when: ").append(toIndentedString(when)).append("\n");
        sb.append("    positionTicks: ").append(toIndentedString(positionTicks)).append("\n");
        sb.append("    isPlaying: ").append(toIndentedString(isPlaying)).append("\n");
        sb.append("    playlistItemId: ").append(toIndentedString(playlistItemId)).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) {
        return o == null ? "null" : o.toString().replace("\n", "\n    ");
    }

    /**
     * Convert the instance into URL query string.
     *
     * @return URL query string
     */
    public String toUrlQueryString() {
        return toUrlQueryString(null);
    }

    /**
     * Convert the instance into URL query string.
     *
     * @param prefix prefix of the query string
     * @return URL query string
     */
    public String toUrlQueryString(String prefix) {
        String suffix = "";
        String containerSuffix = "";
        String containerPrefix = "";
        if (prefix == null) {
            // style=form, explode=true, e.g. /pet?name=cat&type=manx
            prefix = "";
        } else {
            // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
            prefix = prefix + "[";
            suffix = "]";
            containerSuffix = "]";
            containerPrefix = "[";
        }

        StringJoiner joiner = new StringJoiner("&");

        // add `When` to the URL query string
        if (getWhen() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sWhen%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getWhen()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        // add `PositionTicks` to the URL query string
        if (getPositionTicks() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sPositionTicks%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getPositionTicks()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        // add `IsPlaying` to the URL query string
        if (getIsPlaying() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sIsPlaying%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getIsPlaying()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        // add `PlaylistItemId` to the URL query string
        if (getPlaylistItemId() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sPlaylistItemId%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getPlaylistItemId()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        return joiner.toString();
    }

    public static class Builder {

        private ReadyRequestDto instance;

        public Builder() {
            this(new ReadyRequestDto());
        }

        protected Builder(ReadyRequestDto instance) {
            this.instance = instance;
        }

        public ReadyRequestDto.Builder when(OffsetDateTime when) {
            this.instance.when = when;
            return this;
        }

        public ReadyRequestDto.Builder positionTicks(Long positionTicks) {
            this.instance.positionTicks = positionTicks;
            return this;
        }

        public ReadyRequestDto.Builder isPlaying(Boolean isPlaying) {
            this.instance.isPlaying = isPlaying;
            return this;
        }

        public ReadyRequestDto.Builder playlistItemId(UUID playlistItemId) {
            this.instance.playlistItemId = playlistItemId;
            return this;
        }

        /**
         * returns a built ReadyRequestDto instance.
         *
         * The builder is not reusable.
         */
        public ReadyRequestDto build() {
            try {
                return this.instance;
            } finally {
                // ensure that this.instance is not reused
                this.instance = null;
            }
        }

        @Override
        public String toString() {
            return getClass() + "=(" + instance + ")";
        }
    }

    /**
     * Create a builder with no initialized field.
     */
    public static ReadyRequestDto.Builder builder() {
        return new ReadyRequestDto.Builder();
    }

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public ReadyRequestDto.Builder toBuilder() {
        return new ReadyRequestDto.Builder().when(getWhen()).positionTicks(getPositionTicks()).isPlaying(getIsPlaying())
                .playlistItemId(getPlaylistItemId());
    }
}
