/* 
 * 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.core.type.TypeReference;
import dev.plexapi.sdk.utils.LazySingletonValue;
import dev.plexapi.sdk.utils.SpeakeasyMetadata;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Boolean;
import java.lang.Override;
import java.lang.String;
import java.util.Objects;
import java.util.Optional;

/**
 * PostUsersSignInDataRequestBody - Login credentials
 */

public class PostUsersSignInDataRequestBody {

    @SpeakeasyMetadata("form:name=login")
    private String login;

    @SpeakeasyMetadata("form:name=password")
    private String password;

    @SpeakeasyMetadata("form:name=rememberMe")
    private Optional<Boolean> rememberMe;

    @SpeakeasyMetadata("form:name=verificationCode")
    private Optional<String> verificationCode;

    @JsonCreator
    public PostUsersSignInDataRequestBody(
            String login,
            String password,
            Optional<Boolean> rememberMe,
            Optional<String> verificationCode) {
        Utils.checkNotNull(login, "login");
        Utils.checkNotNull(password, "password");
        Utils.checkNotNull(rememberMe, "rememberMe");
        Utils.checkNotNull(verificationCode, "verificationCode");
        this.login = login;
        this.password = password;
        this.rememberMe = rememberMe;
        this.verificationCode = verificationCode;
    }
    
    public PostUsersSignInDataRequestBody(
            String login,
            String password) {
        this(login, password, Optional.empty(), Optional.empty());
    }

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

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

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

    @JsonIgnore
    public Optional<String> verificationCode() {
        return verificationCode;
    }

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

    public PostUsersSignInDataRequestBody withLogin(String login) {
        Utils.checkNotNull(login, "login");
        this.login = login;
        return this;
    }

    public PostUsersSignInDataRequestBody withPassword(String password) {
        Utils.checkNotNull(password, "password");
        this.password = password;
        return this;
    }

    public PostUsersSignInDataRequestBody withRememberMe(boolean rememberMe) {
        Utils.checkNotNull(rememberMe, "rememberMe");
        this.rememberMe = Optional.ofNullable(rememberMe);
        return this;
    }

    public PostUsersSignInDataRequestBody withRememberMe(Optional<Boolean> rememberMe) {
        Utils.checkNotNull(rememberMe, "rememberMe");
        this.rememberMe = rememberMe;
        return this;
    }

    public PostUsersSignInDataRequestBody withVerificationCode(String verificationCode) {
        Utils.checkNotNull(verificationCode, "verificationCode");
        this.verificationCode = Optional.ofNullable(verificationCode);
        return this;
    }

    public PostUsersSignInDataRequestBody withVerificationCode(Optional<String> verificationCode) {
        Utils.checkNotNull(verificationCode, "verificationCode");
        this.verificationCode = verificationCode;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PostUsersSignInDataRequestBody other = (PostUsersSignInDataRequestBody) o;
        return 
            Objects.deepEquals(this.login, other.login) &&
            Objects.deepEquals(this.password, other.password) &&
            Objects.deepEquals(this.rememberMe, other.rememberMe) &&
            Objects.deepEquals(this.verificationCode, other.verificationCode);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            login,
            password,
            rememberMe,
            verificationCode);
    }
    
    @Override
    public String toString() {
        return Utils.toString(PostUsersSignInDataRequestBody.class,
                "login", login,
                "password", password,
                "rememberMe", rememberMe,
                "verificationCode", verificationCode);
    }
    
    public final static class Builder {
 
        private String login;
 
        private String password;
 
        private Optional<Boolean> rememberMe;
 
        private Optional<String> verificationCode = Optional.empty();  
        
        private Builder() {
          // force use of static builder() method
        }

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

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

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

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

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

        public Builder verificationCode(Optional<String> verificationCode) {
            Utils.checkNotNull(verificationCode, "verificationCode");
            this.verificationCode = verificationCode;
            return this;
        }
        
        public PostUsersSignInDataRequestBody build() {
            if (rememberMe == null) {
                rememberMe = _SINGLETON_VALUE_RememberMe.value();
            }            return new PostUsersSignInDataRequestBody(
                login,
                password,
                rememberMe,
                verificationCode);
        }

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

