/* 
 * 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.Override;
import java.lang.String;
import java.util.Objects;
import java.util.Optional;


public class PastSubscription {

    @JsonInclude(Include.ALWAYS)
    @JsonProperty("id")
    private Optional<String> id;

    @JsonInclude(Include.ALWAYS)
    @JsonProperty("mode")
    private Optional<String> mode;

    @JsonInclude(Include.ALWAYS)
    @JsonProperty("renewsAt")
    private Optional<Long> renewsAt;

    @JsonInclude(Include.ALWAYS)
    @JsonProperty("endsAt")
    private Optional<Long> endsAt;

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

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

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

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

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

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

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

    @JsonProperty("type")
    private String type;

    @JsonInclude(Include.ALWAYS)
    @JsonProperty("transfer")
    private Optional<String> transfer;

    @JsonProperty("state")
    private PostUsersSignInDataState state;

    @JsonProperty("billing")
    private Billing billing;

    @JsonCreator
    public PastSubscription(
            @JsonProperty("id") Optional<String> id,
            @JsonProperty("mode") Optional<String> mode,
            @JsonProperty("renewsAt") Optional<Long> renewsAt,
            @JsonProperty("endsAt") Optional<Long> endsAt,
            @JsonProperty("canceled") Optional<Boolean> canceled,
            @JsonProperty("gracePeriod") Optional<Boolean> gracePeriod,
            @JsonProperty("onHold") Optional<Boolean> onHold,
            @JsonProperty("canReactivate") Optional<Boolean> canReactivate,
            @JsonProperty("canUpgrade") Optional<Boolean> canUpgrade,
            @JsonProperty("canDowngrade") Optional<Boolean> canDowngrade,
            @JsonProperty("canConvert") Optional<Boolean> canConvert,
            @JsonProperty("type") String type,
            @JsonProperty("transfer") Optional<String> transfer,
            @JsonProperty("state") PostUsersSignInDataState state,
            @JsonProperty("billing") Billing billing) {
        Utils.checkNotNull(id, "id");
        Utils.checkNotNull(mode, "mode");
        Utils.checkNotNull(renewsAt, "renewsAt");
        Utils.checkNotNull(endsAt, "endsAt");
        Utils.checkNotNull(canceled, "canceled");
        Utils.checkNotNull(gracePeriod, "gracePeriod");
        Utils.checkNotNull(onHold, "onHold");
        Utils.checkNotNull(canReactivate, "canReactivate");
        Utils.checkNotNull(canUpgrade, "canUpgrade");
        Utils.checkNotNull(canDowngrade, "canDowngrade");
        Utils.checkNotNull(canConvert, "canConvert");
        Utils.checkNotNull(type, "type");
        Utils.checkNotNull(transfer, "transfer");
        Utils.checkNotNull(state, "state");
        Utils.checkNotNull(billing, "billing");
        this.id = id;
        this.mode = mode;
        this.renewsAt = renewsAt;
        this.endsAt = endsAt;
        this.canceled = canceled;
        this.gracePeriod = gracePeriod;
        this.onHold = onHold;
        this.canReactivate = canReactivate;
        this.canUpgrade = canUpgrade;
        this.canDowngrade = canDowngrade;
        this.canConvert = canConvert;
        this.type = type;
        this.transfer = transfer;
        this.state = state;
        this.billing = billing;
    }
    
    public PastSubscription(
            String type,
            PostUsersSignInDataState state,
            Billing billing) {
        this(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), type, Optional.empty(), state, billing);
    }

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

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

    @JsonIgnore
    public Optional<Long> renewsAt() {
        return renewsAt;
    }

    @JsonIgnore
    public Optional<Long> endsAt() {
        return endsAt;
    }

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

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

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

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

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

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

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

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

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

    @JsonIgnore
    public PostUsersSignInDataState state() {
        return state;
    }

    @JsonIgnore
    public Billing billing() {
        return billing;
    }

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

    public PastSubscription withId(String id) {
        Utils.checkNotNull(id, "id");
        this.id = Optional.ofNullable(id);
        return this;
    }

    public PastSubscription withId(Optional<String> id) {
        Utils.checkNotNull(id, "id");
        this.id = id;
        return this;
    }

    public PastSubscription withMode(String mode) {
        Utils.checkNotNull(mode, "mode");
        this.mode = Optional.ofNullable(mode);
        return this;
    }

    public PastSubscription withMode(Optional<String> mode) {
        Utils.checkNotNull(mode, "mode");
        this.mode = mode;
        return this;
    }

    public PastSubscription withRenewsAt(long renewsAt) {
        Utils.checkNotNull(renewsAt, "renewsAt");
        this.renewsAt = Optional.ofNullable(renewsAt);
        return this;
    }

    public PastSubscription withRenewsAt(Optional<Long> renewsAt) {
        Utils.checkNotNull(renewsAt, "renewsAt");
        this.renewsAt = renewsAt;
        return this;
    }

    public PastSubscription withEndsAt(long endsAt) {
        Utils.checkNotNull(endsAt, "endsAt");
        this.endsAt = Optional.ofNullable(endsAt);
        return this;
    }

    public PastSubscription withEndsAt(Optional<Long> endsAt) {
        Utils.checkNotNull(endsAt, "endsAt");
        this.endsAt = endsAt;
        return this;
    }

    public PastSubscription withCanceled(boolean canceled) {
        Utils.checkNotNull(canceled, "canceled");
        this.canceled = Optional.ofNullable(canceled);
        return this;
    }

    public PastSubscription withCanceled(Optional<Boolean> canceled) {
        Utils.checkNotNull(canceled, "canceled");
        this.canceled = canceled;
        return this;
    }

    public PastSubscription withGracePeriod(boolean gracePeriod) {
        Utils.checkNotNull(gracePeriod, "gracePeriod");
        this.gracePeriod = Optional.ofNullable(gracePeriod);
        return this;
    }

    public PastSubscription withGracePeriod(Optional<Boolean> gracePeriod) {
        Utils.checkNotNull(gracePeriod, "gracePeriod");
        this.gracePeriod = gracePeriod;
        return this;
    }

    public PastSubscription withOnHold(boolean onHold) {
        Utils.checkNotNull(onHold, "onHold");
        this.onHold = Optional.ofNullable(onHold);
        return this;
    }

    public PastSubscription withOnHold(Optional<Boolean> onHold) {
        Utils.checkNotNull(onHold, "onHold");
        this.onHold = onHold;
        return this;
    }

    public PastSubscription withCanReactivate(boolean canReactivate) {
        Utils.checkNotNull(canReactivate, "canReactivate");
        this.canReactivate = Optional.ofNullable(canReactivate);
        return this;
    }

    public PastSubscription withCanReactivate(Optional<Boolean> canReactivate) {
        Utils.checkNotNull(canReactivate, "canReactivate");
        this.canReactivate = canReactivate;
        return this;
    }

    public PastSubscription withCanUpgrade(boolean canUpgrade) {
        Utils.checkNotNull(canUpgrade, "canUpgrade");
        this.canUpgrade = Optional.ofNullable(canUpgrade);
        return this;
    }

    public PastSubscription withCanUpgrade(Optional<Boolean> canUpgrade) {
        Utils.checkNotNull(canUpgrade, "canUpgrade");
        this.canUpgrade = canUpgrade;
        return this;
    }

    public PastSubscription withCanDowngrade(boolean canDowngrade) {
        Utils.checkNotNull(canDowngrade, "canDowngrade");
        this.canDowngrade = Optional.ofNullable(canDowngrade);
        return this;
    }

    public PastSubscription withCanDowngrade(Optional<Boolean> canDowngrade) {
        Utils.checkNotNull(canDowngrade, "canDowngrade");
        this.canDowngrade = canDowngrade;
        return this;
    }

    public PastSubscription withCanConvert(boolean canConvert) {
        Utils.checkNotNull(canConvert, "canConvert");
        this.canConvert = Optional.ofNullable(canConvert);
        return this;
    }

    public PastSubscription withCanConvert(Optional<Boolean> canConvert) {
        Utils.checkNotNull(canConvert, "canConvert");
        this.canConvert = canConvert;
        return this;
    }

    public PastSubscription withType(String type) {
        Utils.checkNotNull(type, "type");
        this.type = type;
        return this;
    }

    public PastSubscription withTransfer(String transfer) {
        Utils.checkNotNull(transfer, "transfer");
        this.transfer = Optional.ofNullable(transfer);
        return this;
    }

    public PastSubscription withTransfer(Optional<String> transfer) {
        Utils.checkNotNull(transfer, "transfer");
        this.transfer = transfer;
        return this;
    }

    public PastSubscription withState(PostUsersSignInDataState state) {
        Utils.checkNotNull(state, "state");
        this.state = state;
        return this;
    }

    public PastSubscription withBilling(Billing billing) {
        Utils.checkNotNull(billing, "billing");
        this.billing = billing;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PastSubscription other = (PastSubscription) o;
        return 
            Objects.deepEquals(this.id, other.id) &&
            Objects.deepEquals(this.mode, other.mode) &&
            Objects.deepEquals(this.renewsAt, other.renewsAt) &&
            Objects.deepEquals(this.endsAt, other.endsAt) &&
            Objects.deepEquals(this.canceled, other.canceled) &&
            Objects.deepEquals(this.gracePeriod, other.gracePeriod) &&
            Objects.deepEquals(this.onHold, other.onHold) &&
            Objects.deepEquals(this.canReactivate, other.canReactivate) &&
            Objects.deepEquals(this.canUpgrade, other.canUpgrade) &&
            Objects.deepEquals(this.canDowngrade, other.canDowngrade) &&
            Objects.deepEquals(this.canConvert, other.canConvert) &&
            Objects.deepEquals(this.type, other.type) &&
            Objects.deepEquals(this.transfer, other.transfer) &&
            Objects.deepEquals(this.state, other.state) &&
            Objects.deepEquals(this.billing, other.billing);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            id,
            mode,
            renewsAt,
            endsAt,
            canceled,
            gracePeriod,
            onHold,
            canReactivate,
            canUpgrade,
            canDowngrade,
            canConvert,
            type,
            transfer,
            state,
            billing);
    }
    
    @Override
    public String toString() {
        return Utils.toString(PastSubscription.class,
                "id", id,
                "mode", mode,
                "renewsAt", renewsAt,
                "endsAt", endsAt,
                "canceled", canceled,
                "gracePeriod", gracePeriod,
                "onHold", onHold,
                "canReactivate", canReactivate,
                "canUpgrade", canUpgrade,
                "canDowngrade", canDowngrade,
                "canConvert", canConvert,
                "type", type,
                "transfer", transfer,
                "state", state,
                "billing", billing);
    }
    
    public final static class Builder {
 
        private Optional<String> id = Optional.empty();
 
        private Optional<String> mode = Optional.empty();
 
        private Optional<Long> renewsAt = Optional.empty();
 
        private Optional<Long> endsAt = Optional.empty();
 
        private Optional<Boolean> canceled;
 
        private Optional<Boolean> gracePeriod;
 
        private Optional<Boolean> onHold;
 
        private Optional<Boolean> canReactivate;
 
        private Optional<Boolean> canUpgrade;
 
        private Optional<Boolean> canDowngrade;
 
        private Optional<Boolean> canConvert;
 
        private String type;
 
        private Optional<String> transfer = Optional.empty();
 
        private PostUsersSignInDataState state;
 
        private Billing billing;  
        
        private Builder() {
          // force use of static builder() method
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        public Builder state(PostUsersSignInDataState state) {
            Utils.checkNotNull(state, "state");
            this.state = state;
            return this;
        }

        public Builder billing(Billing billing) {
            Utils.checkNotNull(billing, "billing");
            this.billing = billing;
            return this;
        }
        
        public PastSubscription build() {
            if (canceled == null) {
                canceled = _SINGLETON_VALUE_Canceled.value();
            }
            if (gracePeriod == null) {
                gracePeriod = _SINGLETON_VALUE_GracePeriod.value();
            }
            if (onHold == null) {
                onHold = _SINGLETON_VALUE_OnHold.value();
            }
            if (canReactivate == null) {
                canReactivate = _SINGLETON_VALUE_CanReactivate.value();
            }
            if (canUpgrade == null) {
                canUpgrade = _SINGLETON_VALUE_CanUpgrade.value();
            }
            if (canDowngrade == null) {
                canDowngrade = _SINGLETON_VALUE_CanDowngrade.value();
            }
            if (canConvert == null) {
                canConvert = _SINGLETON_VALUE_CanConvert.value();
            }            return new PastSubscription(
                id,
                mode,
                renewsAt,
                endsAt,
                canceled,
                gracePeriod,
                onHold,
                canReactivate,
                canUpgrade,
                canDowngrade,
                canConvert,
                type,
                transfer,
                state,
                billing);
        }

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

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

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

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

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

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

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

