/*
 * 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;

/**
 * ForgotPasswordResult
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class ForgotPasswordResult {
    public static final String JSON_PROPERTY_ACTION = "Action";
    private @org.eclipse.jdt.annotation.Nullable ForgotPasswordAction action;

    public static final String JSON_PROPERTY_PIN_FILE = "PinFile";
    private @org.eclipse.jdt.annotation.Nullable String pinFile;

    public static final String JSON_PROPERTY_PIN_EXPIRATION_DATE = "PinExpirationDate";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime pinExpirationDate;

    public ForgotPasswordResult() {
    }

    public ForgotPasswordResult action(@org.eclipse.jdt.annotation.Nullable ForgotPasswordAction action) {
        this.action = action;
        return this;
    }

    /**
     * Gets or sets the action.
     * 
     * @return action
     */
    @JsonProperty(value = JSON_PROPERTY_ACTION)
    public @org.eclipse.jdt.annotation.Nullable ForgotPasswordAction getAction() {
        return action;
    }

    @JsonProperty(value = JSON_PROPERTY_ACTION)
    public void setAction(@org.eclipse.jdt.annotation.Nullable ForgotPasswordAction action) {
        this.action = action;
    }

    public ForgotPasswordResult pinFile(@org.eclipse.jdt.annotation.Nullable String pinFile) {
        this.pinFile = pinFile;
        return this;
    }

    /**
     * Gets or sets the pin file.
     * 
     * @return pinFile
     */
    @JsonProperty(value = JSON_PROPERTY_PIN_FILE)
    public @org.eclipse.jdt.annotation.Nullable String getPinFile() {
        return pinFile;
    }

    @JsonProperty(value = JSON_PROPERTY_PIN_FILE)
    public void setPinFile(@org.eclipse.jdt.annotation.Nullable String pinFile) {
        this.pinFile = pinFile;
    }

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

    /**
     * Gets or sets the pin expiration date.
     * 
     * @return pinExpirationDate
     */
    @JsonProperty(value = JSON_PROPERTY_PIN_EXPIRATION_DATE)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getPinExpirationDate() {
        return pinExpirationDate;
    }

    @JsonProperty(value = JSON_PROPERTY_PIN_EXPIRATION_DATE)
    public void setPinExpirationDate(@org.eclipse.jdt.annotation.Nullable OffsetDateTime pinExpirationDate) {
        this.pinExpirationDate = pinExpirationDate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ForgotPasswordResult forgotPasswordResult = (ForgotPasswordResult) o;
        return Objects.equals(this.action, forgotPasswordResult.action)
                && Objects.equals(this.pinFile, forgotPasswordResult.pinFile)
                && Objects.equals(this.pinExpirationDate, forgotPasswordResult.pinExpirationDate);
    }

    @Override
    public int hashCode() {
        return Objects.hash(action, pinFile, pinExpirationDate);
    }

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

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

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

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

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

        public ForgotPasswordResult.Builder action(ForgotPasswordAction action) {
            this.instance.action = action;
            return this;
        }

        public ForgotPasswordResult.Builder pinFile(String pinFile) {
            this.instance.pinFile = pinFile;
            return this;
        }

        public ForgotPasswordResult.Builder pinExpirationDate(OffsetDateTime pinExpirationDate) {
            this.instance.pinExpirationDate = pinExpirationDate;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public ForgotPasswordResult.Builder toBuilder() {
        return new ForgotPasswordResult.Builder().action(getAction()).pinFile(getPinFile())
                .pinExpirationDate(getPinExpirationDate());
    }
}
