/* 
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

package dev.plexapi.sdk.models.operations;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import dev.plexapi.sdk.utils.LazySingletonValue;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Boolean;
import java.lang.Long;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.time.OffsetDateTime;
import java.util.Objects;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;

/**
 * GetPinAuthPinContainer - Requests a new pin id used in the authentication flow
 */

public class GetPinAuthPinContainer {

    @JsonProperty("id")
    private long id;

    @JsonProperty("code")
    private String code;

    @JsonProperty("product")
    private String product;

    @JsonInclude(Include.NON_ABSENT)
    @JsonProperty("trusted")
    private Optional<Boolean> trusted;

    @JsonProperty("qr")
    private String qr;

    /**
     * The X-Client-Identifier used in the request
     */
    @JsonProperty("clientIdentifier")
    private String clientIdentifier;

    /**
     * Geo location data
     */
    @JsonProperty("location")
    private GeoData location;

    /**
     * The number of seconds this pin expires, by default 900 seconds
     */
    @JsonInclude(Include.NON_ABSENT)
    @JsonProperty("expiresIn")
    private Optional<Long> expiresIn;

    @JsonProperty("createdAt")
    private OffsetDateTime createdAt;

    @JsonProperty("expiresAt")
    private OffsetDateTime expiresAt;

    @JsonInclude(Include.NON_ABSENT)
    @JsonProperty("authToken")
    private JsonNullable<String> authToken;

    @JsonInclude(Include.NON_ABSENT)
    @JsonProperty("newRegistration")
    private JsonNullable<? extends Object> newRegistration;

    @JsonCreator
    public GetPinAuthPinContainer(
            @JsonProperty("id") long id,
            @JsonProperty("code") String code,
            @JsonProperty("product") String product,
            @JsonProperty("trusted") Optional<Boolean> trusted,
            @JsonProperty("qr") String qr,
            @JsonProperty("clientIdentifier") String clientIdentifier,
            @JsonProperty("location") GeoData location,
            @JsonProperty("expiresIn") Optional<Long> expiresIn,
            @JsonProperty("createdAt") OffsetDateTime createdAt,
            @JsonProperty("expiresAt") OffsetDateTime expiresAt,
            @JsonProperty("authToken") JsonNullable<String> authToken,
            @JsonProperty("newRegistration") JsonNullable<? extends Object> newRegistration) {
        Utils.checkNotNull(id, "id");
        Utils.checkNotNull(code, "code");
        Utils.checkNotNull(product, "product");
        Utils.checkNotNull(trusted, "trusted");
        Utils.checkNotNull(qr, "qr");
        Utils.checkNotNull(clientIdentifier, "clientIdentifier");
        Utils.checkNotNull(location, "location");
        Utils.checkNotNull(expiresIn, "expiresIn");
        Utils.checkNotNull(createdAt, "createdAt");
        Utils.checkNotNull(expiresAt, "expiresAt");
        Utils.checkNotNull(authToken, "authToken");
        Utils.checkNotNull(newRegistration, "newRegistration");
        this.id = id;
        this.code = code;
        this.product = product;
        this.trusted = trusted;
        this.qr = qr;
        this.clientIdentifier = clientIdentifier;
        this.location = location;
        this.expiresIn = expiresIn;
        this.createdAt = createdAt;
        this.expiresAt = expiresAt;
        this.authToken = authToken;
        this.newRegistration = newRegistration;
    }
    
    public GetPinAuthPinContainer(
            long id,
            String code,
            String product,
            String qr,
            String clientIdentifier,
            GeoData location,
            OffsetDateTime createdAt,
            OffsetDateTime expiresAt) {
        this(id, code, product, Optional.empty(), qr, clientIdentifier, location, Optional.empty(), createdAt, expiresAt, JsonNullable.undefined(), JsonNullable.undefined());
    }

    @JsonIgnore
    public long id() {
        return id;
    }

    @JsonIgnore
    public String code() {
        return code;
    }

    @JsonIgnore
    public String product() {
        return product;
    }

    @JsonIgnore
    public Optional<Boolean> trusted() {
        return trusted;
    }

    @JsonIgnore
    public String qr() {
        return qr;
    }

    /**
     * The X-Client-Identifier used in the request
     */
    @JsonIgnore
    public String clientIdentifier() {
        return clientIdentifier;
    }

    /**
     * Geo location data
     */
    @JsonIgnore
    public GeoData location() {
        return location;
    }

    /**
     * The number of seconds this pin expires, by default 900 seconds
     */
    @JsonIgnore
    public Optional<Long> expiresIn() {
        return expiresIn;
    }

    @JsonIgnore
    public OffsetDateTime createdAt() {
        return createdAt;
    }

    @JsonIgnore
    public OffsetDateTime expiresAt() {
        return expiresAt;
    }

    @JsonIgnore
    public JsonNullable<String> authToken() {
        return authToken;
    }

    @SuppressWarnings("unchecked")
    @JsonIgnore
    public JsonNullable<Object> newRegistration() {
        return (JsonNullable<Object>) newRegistration;
    }

    public final static Builder builder() {
        return new Builder();
    }

    public GetPinAuthPinContainer withId(long id) {
        Utils.checkNotNull(id, "id");
        this.id = id;
        return this;
    }

    public GetPinAuthPinContainer withCode(String code) {
        Utils.checkNotNull(code, "code");
        this.code = code;
        return this;
    }

    public GetPinAuthPinContainer withProduct(String product) {
        Utils.checkNotNull(product, "product");
        this.product = product;
        return this;
    }

    public GetPinAuthPinContainer withTrusted(boolean trusted) {
        Utils.checkNotNull(trusted, "trusted");
        this.trusted = Optional.ofNullable(trusted);
        return this;
    }

    public GetPinAuthPinContainer withTrusted(Optional<Boolean> trusted) {
        Utils.checkNotNull(trusted, "trusted");
        this.trusted = trusted;
        return this;
    }

    public GetPinAuthPinContainer withQr(String qr) {
        Utils.checkNotNull(qr, "qr");
        this.qr = qr;
        return this;
    }

    /**
     * The X-Client-Identifier used in the request
     */
    public GetPinAuthPinContainer withClientIdentifier(String clientIdentifier) {
        Utils.checkNotNull(clientIdentifier, "clientIdentifier");
        this.clientIdentifier = clientIdentifier;
        return this;
    }

    /**
     * Geo location data
     */
    public GetPinAuthPinContainer withLocation(GeoData location) {
        Utils.checkNotNull(location, "location");
        this.location = location;
        return this;
    }

    /**
     * The number of seconds this pin expires, by default 900 seconds
     */
    public GetPinAuthPinContainer withExpiresIn(long expiresIn) {
        Utils.checkNotNull(expiresIn, "expiresIn");
        this.expiresIn = Optional.ofNullable(expiresIn);
        return this;
    }

    /**
     * The number of seconds this pin expires, by default 900 seconds
     */
    public GetPinAuthPinContainer withExpiresIn(Optional<Long> expiresIn) {
        Utils.checkNotNull(expiresIn, "expiresIn");
        this.expiresIn = expiresIn;
        return this;
    }

    public GetPinAuthPinContainer withCreatedAt(OffsetDateTime createdAt) {
        Utils.checkNotNull(createdAt, "createdAt");
        this.createdAt = createdAt;
        return this;
    }

    public GetPinAuthPinContainer withExpiresAt(OffsetDateTime expiresAt) {
        Utils.checkNotNull(expiresAt, "expiresAt");
        this.expiresAt = expiresAt;
        return this;
    }

    public GetPinAuthPinContainer withAuthToken(String authToken) {
        Utils.checkNotNull(authToken, "authToken");
        this.authToken = JsonNullable.of(authToken);
        return this;
    }

    public GetPinAuthPinContainer withAuthToken(JsonNullable<String> authToken) {
        Utils.checkNotNull(authToken, "authToken");
        this.authToken = authToken;
        return this;
    }

    public GetPinAuthPinContainer withNewRegistration(Object newRegistration) {
        Utils.checkNotNull(newRegistration, "newRegistration");
        this.newRegistration = JsonNullable.of(newRegistration);
        return this;
    }

    public GetPinAuthPinContainer withNewRegistration(JsonNullable<? extends Object> newRegistration) {
        Utils.checkNotNull(newRegistration, "newRegistration");
        this.newRegistration = newRegistration;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GetPinAuthPinContainer other = (GetPinAuthPinContainer) o;
        return 
            Objects.deepEquals(this.id, other.id) &&
            Objects.deepEquals(this.code, other.code) &&
            Objects.deepEquals(this.product, other.product) &&
            Objects.deepEquals(this.trusted, other.trusted) &&
            Objects.deepEquals(this.qr, other.qr) &&
            Objects.deepEquals(this.clientIdentifier, other.clientIdentifier) &&
            Objects.deepEquals(this.location, other.location) &&
            Objects.deepEquals(this.expiresIn, other.expiresIn) &&
            Objects.deepEquals(this.createdAt, other.createdAt) &&
            Objects.deepEquals(this.expiresAt, other.expiresAt) &&
            Objects.deepEquals(this.authToken, other.authToken) &&
            Objects.deepEquals(this.newRegistration, other.newRegistration);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            id,
            code,
            product,
            trusted,
            qr,
            clientIdentifier,
            location,
            expiresIn,
            createdAt,
            expiresAt,
            authToken,
            newRegistration);
    }
    
    @Override
    public String toString() {
        return Utils.toString(GetPinAuthPinContainer.class,
                "id", id,
                "code", code,
                "product", product,
                "trusted", trusted,
                "qr", qr,
                "clientIdentifier", clientIdentifier,
                "location", location,
                "expiresIn", expiresIn,
                "createdAt", createdAt,
                "expiresAt", expiresAt,
                "authToken", authToken,
                "newRegistration", newRegistration);
    }
    
    public final static class Builder {
 
        private Long id;
 
        private String code;
 
        private String product;
 
        private Optional<Boolean> trusted;
 
        private String qr;
 
        private String clientIdentifier;
 
        private GeoData location;
 
        private Optional<Long> expiresIn;
 
        private OffsetDateTime createdAt;
 
        private OffsetDateTime expiresAt;
 
        private JsonNullable<String> authToken = JsonNullable.undefined();
 
        private JsonNullable<? extends Object> newRegistration = JsonNullable.undefined();  
        
        private Builder() {
          // force use of static builder() method
        }

        public Builder id(long id) {
            Utils.checkNotNull(id, "id");
            this.id = id;
            return this;
        }

        public Builder code(String code) {
            Utils.checkNotNull(code, "code");
            this.code = code;
            return this;
        }

        public Builder product(String product) {
            Utils.checkNotNull(product, "product");
            this.product = product;
            return this;
        }

        public Builder trusted(boolean trusted) {
            Utils.checkNotNull(trusted, "trusted");
            this.trusted = Optional.ofNullable(trusted);
            return this;
        }

        public Builder trusted(Optional<Boolean> trusted) {
            Utils.checkNotNull(trusted, "trusted");
            this.trusted = trusted;
            return this;
        }

        public Builder qr(String qr) {
            Utils.checkNotNull(qr, "qr");
            this.qr = qr;
            return this;
        }

        /**
         * The X-Client-Identifier used in the request
         */
        public Builder clientIdentifier(String clientIdentifier) {
            Utils.checkNotNull(clientIdentifier, "clientIdentifier");
            this.clientIdentifier = clientIdentifier;
            return this;
        }

        /**
         * Geo location data
         */
        public Builder location(GeoData location) {
            Utils.checkNotNull(location, "location");
            this.location = location;
            return this;
        }

        /**
         * The number of seconds this pin expires, by default 900 seconds
         */
        public Builder expiresIn(long expiresIn) {
            Utils.checkNotNull(expiresIn, "expiresIn");
            this.expiresIn = Optional.ofNullable(expiresIn);
            return this;
        }

        /**
         * The number of seconds this pin expires, by default 900 seconds
         */
        public Builder expiresIn(Optional<Long> expiresIn) {
            Utils.checkNotNull(expiresIn, "expiresIn");
            this.expiresIn = expiresIn;
            return this;
        }

        public Builder createdAt(OffsetDateTime createdAt) {
            Utils.checkNotNull(createdAt, "createdAt");
            this.createdAt = createdAt;
            return this;
        }

        public Builder expiresAt(OffsetDateTime expiresAt) {
            Utils.checkNotNull(expiresAt, "expiresAt");
            this.expiresAt = expiresAt;
            return this;
        }

        public Builder authToken(String authToken) {
            Utils.checkNotNull(authToken, "authToken");
            this.authToken = JsonNullable.of(authToken);
            return this;
        }

        public Builder authToken(JsonNullable<String> authToken) {
            Utils.checkNotNull(authToken, "authToken");
            this.authToken = authToken;
            return this;
        }

        public Builder newRegistration(Object newRegistration) {
            Utils.checkNotNull(newRegistration, "newRegistration");
            this.newRegistration = JsonNullable.of(newRegistration);
            return this;
        }

        public Builder newRegistration(JsonNullable<? extends Object> newRegistration) {
            Utils.checkNotNull(newRegistration, "newRegistration");
            this.newRegistration = newRegistration;
            return this;
        }
        
        public GetPinAuthPinContainer build() {
            if (trusted == null) {
                trusted = _SINGLETON_VALUE_Trusted.value();
            }
            if (expiresIn == null) {
                expiresIn = _SINGLETON_VALUE_ExpiresIn.value();
            }            return new GetPinAuthPinContainer(
                id,
                code,
                product,
                trusted,
                qr,
                clientIdentifier,
                location,
                expiresIn,
                createdAt,
                expiresAt,
                authToken,
                newRegistration);
        }

        private static final LazySingletonValue<Optional<Boolean>> _SINGLETON_VALUE_Trusted =
                new LazySingletonValue<>(
                        "trusted",
                        "false",
                        new TypeReference<Optional<Boolean>>() {});

        private static final LazySingletonValue<Optional<Long>> _SINGLETON_VALUE_ExpiresIn =
                new LazySingletonValue<>(
                        "expiresIn",
                        "900",
                        new TypeReference<Optional<Long>>() {});
    }
}

