/*
 * 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 com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Class UtcTimeResponse.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class UtcTimeResponse {
    public static final String JSON_PROPERTY_REQUEST_RECEPTION_TIME = "RequestReceptionTime";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime requestReceptionTime;

    public static final String JSON_PROPERTY_RESPONSE_TRANSMISSION_TIME = "ResponseTransmissionTime";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime responseTransmissionTime;

    public UtcTimeResponse() {
    }

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

    /**
     * Gets the UTC time when request has been received.
     * 
     * @return requestReceptionTime
     */
    @JsonProperty(value = JSON_PROPERTY_REQUEST_RECEPTION_TIME)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getRequestReceptionTime() {
        return requestReceptionTime;
    }

    @JsonProperty(value = JSON_PROPERTY_REQUEST_RECEPTION_TIME)
    public void setRequestReceptionTime(@org.eclipse.jdt.annotation.Nullable OffsetDateTime requestReceptionTime) {
        this.requestReceptionTime = requestReceptionTime;
    }

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

    /**
     * Gets the UTC time when response has been sent.
     * 
     * @return responseTransmissionTime
     */
    @JsonProperty(value = JSON_PROPERTY_RESPONSE_TRANSMISSION_TIME)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getResponseTransmissionTime() {
        return responseTransmissionTime;
    }

    @JsonProperty(value = JSON_PROPERTY_RESPONSE_TRANSMISSION_TIME)
    public void setResponseTransmissionTime(
            @org.eclipse.jdt.annotation.Nullable OffsetDateTime responseTransmissionTime) {
        this.responseTransmissionTime = responseTransmissionTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        UtcTimeResponse utcTimeResponse = (UtcTimeResponse) o;
        return Objects.equals(this.requestReceptionTime, utcTimeResponse.requestReceptionTime)
                && Objects.equals(this.responseTransmissionTime, utcTimeResponse.responseTransmissionTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(requestReceptionTime, responseTransmissionTime);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class UtcTimeResponse {\n");
        sb.append("    requestReceptionTime: ").append(toIndentedString(requestReceptionTime)).append("\n");
        sb.append("    responseTransmissionTime: ").append(toIndentedString(responseTransmissionTime)).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 `RequestReceptionTime` to the URL query string
        if (getRequestReceptionTime() != null) {
            try {
                joiner.add(
                        String.format(java.util.Locale.ROOT, "%sRequestReceptionTime%s=%s", prefix, suffix, URLEncoder
                                .encode(String.valueOf(getRequestReceptionTime()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        // add `ResponseTransmissionTime` to the URL query string
        if (getResponseTransmissionTime() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sResponseTransmissionTime%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getResponseTransmissionTime()), "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 UtcTimeResponse instance;

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

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

        public UtcTimeResponse.Builder requestReceptionTime(OffsetDateTime requestReceptionTime) {
            this.instance.requestReceptionTime = requestReceptionTime;
            return this;
        }

        public UtcTimeResponse.Builder responseTransmissionTime(OffsetDateTime responseTransmissionTime) {
            this.instance.responseTransmissionTime = responseTransmissionTime;
            return this;
        }

        /**
         * returns a built UtcTimeResponse instance.
         *
         * The builder is not reusable.
         */
        public UtcTimeResponse 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 UtcTimeResponse.Builder builder() {
        return new UtcTimeResponse.Builder();
    }

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public UtcTimeResponse.Builder toBuilder() {
        return new UtcTimeResponse.Builder().requestReceptionTime(getRequestReceptionTime())
                .responseTransmissionTime(getResponseTransmissionTime());
    }
}
