/* 
 * 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 dev.plexapi.sdk.utils.SpeakeasyMetadata;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Long;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.Objects;
import java.util.Optional;


public class GetSessionHistoryRequest {

    /**
     * Sorts the results by the specified field followed by the direction (asc, desc)
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=sort")
    private Optional<String> sort;

    /**
     * Filter results by those that are related to a specific users id
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=accountId")
    private Optional<Long> accountId;

    /**
     * Filters content by field and direction/equality
     * (Unknown if viewedAt is the only supported column)
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=filter")
    private Optional<? extends QueryParamFilter> filter;

    /**
     * Filters the results based on the id of a valid library section
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=librarySectionID")
    private Optional<Long> librarySectionID;

    @JsonCreator
    public GetSessionHistoryRequest(
            Optional<String> sort,
            Optional<Long> accountId,
            Optional<? extends QueryParamFilter> filter,
            Optional<Long> librarySectionID) {
        Utils.checkNotNull(sort, "sort");
        Utils.checkNotNull(accountId, "accountId");
        Utils.checkNotNull(filter, "filter");
        Utils.checkNotNull(librarySectionID, "librarySectionID");
        this.sort = sort;
        this.accountId = accountId;
        this.filter = filter;
        this.librarySectionID = librarySectionID;
    }
    
    public GetSessionHistoryRequest() {
        this(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
    }

    /**
     * Sorts the results by the specified field followed by the direction (asc, desc)
     * 
     */
    @JsonIgnore
    public Optional<String> sort() {
        return sort;
    }

    /**
     * Filter results by those that are related to a specific users id
     * 
     */
    @JsonIgnore
    public Optional<Long> accountId() {
        return accountId;
    }

    /**
     * Filters content by field and direction/equality
     * (Unknown if viewedAt is the only supported column)
     * 
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<QueryParamFilter> filter() {
        return (Optional<QueryParamFilter>) filter;
    }

    /**
     * Filters the results based on the id of a valid library section
     * 
     */
    @JsonIgnore
    public Optional<Long> librarySectionID() {
        return librarySectionID;
    }

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

    /**
     * Sorts the results by the specified field followed by the direction (asc, desc)
     * 
     */
    public GetSessionHistoryRequest withSort(String sort) {
        Utils.checkNotNull(sort, "sort");
        this.sort = Optional.ofNullable(sort);
        return this;
    }

    /**
     * Sorts the results by the specified field followed by the direction (asc, desc)
     * 
     */
    public GetSessionHistoryRequest withSort(Optional<String> sort) {
        Utils.checkNotNull(sort, "sort");
        this.sort = sort;
        return this;
    }

    /**
     * Filter results by those that are related to a specific users id
     * 
     */
    public GetSessionHistoryRequest withAccountId(long accountId) {
        Utils.checkNotNull(accountId, "accountId");
        this.accountId = Optional.ofNullable(accountId);
        return this;
    }

    /**
     * Filter results by those that are related to a specific users id
     * 
     */
    public GetSessionHistoryRequest withAccountId(Optional<Long> accountId) {
        Utils.checkNotNull(accountId, "accountId");
        this.accountId = accountId;
        return this;
    }

    /**
     * Filters content by field and direction/equality
     * (Unknown if viewedAt is the only supported column)
     * 
     */
    public GetSessionHistoryRequest withFilter(QueryParamFilter filter) {
        Utils.checkNotNull(filter, "filter");
        this.filter = Optional.ofNullable(filter);
        return this;
    }

    /**
     * Filters content by field and direction/equality
     * (Unknown if viewedAt is the only supported column)
     * 
     */
    public GetSessionHistoryRequest withFilter(Optional<? extends QueryParamFilter> filter) {
        Utils.checkNotNull(filter, "filter");
        this.filter = filter;
        return this;
    }

    /**
     * Filters the results based on the id of a valid library section
     * 
     */
    public GetSessionHistoryRequest withLibrarySectionID(long librarySectionID) {
        Utils.checkNotNull(librarySectionID, "librarySectionID");
        this.librarySectionID = Optional.ofNullable(librarySectionID);
        return this;
    }

    /**
     * Filters the results based on the id of a valid library section
     * 
     */
    public GetSessionHistoryRequest withLibrarySectionID(Optional<Long> librarySectionID) {
        Utils.checkNotNull(librarySectionID, "librarySectionID");
        this.librarySectionID = librarySectionID;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GetSessionHistoryRequest other = (GetSessionHistoryRequest) o;
        return 
            Objects.deepEquals(this.sort, other.sort) &&
            Objects.deepEquals(this.accountId, other.accountId) &&
            Objects.deepEquals(this.filter, other.filter) &&
            Objects.deepEquals(this.librarySectionID, other.librarySectionID);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            sort,
            accountId,
            filter,
            librarySectionID);
    }
    
    @Override
    public String toString() {
        return Utils.toString(GetSessionHistoryRequest.class,
                "sort", sort,
                "accountId", accountId,
                "filter", filter,
                "librarySectionID", librarySectionID);
    }
    
    public final static class Builder {
 
        private Optional<String> sort = Optional.empty();
 
        private Optional<Long> accountId = Optional.empty();
 
        private Optional<? extends QueryParamFilter> filter = Optional.empty();
 
        private Optional<Long> librarySectionID = Optional.empty();  
        
        private Builder() {
          // force use of static builder() method
        }

        /**
         * Sorts the results by the specified field followed by the direction (asc, desc)
         * 
         */
        public Builder sort(String sort) {
            Utils.checkNotNull(sort, "sort");
            this.sort = Optional.ofNullable(sort);
            return this;
        }

        /**
         * Sorts the results by the specified field followed by the direction (asc, desc)
         * 
         */
        public Builder sort(Optional<String> sort) {
            Utils.checkNotNull(sort, "sort");
            this.sort = sort;
            return this;
        }

        /**
         * Filter results by those that are related to a specific users id
         * 
         */
        public Builder accountId(long accountId) {
            Utils.checkNotNull(accountId, "accountId");
            this.accountId = Optional.ofNullable(accountId);
            return this;
        }

        /**
         * Filter results by those that are related to a specific users id
         * 
         */
        public Builder accountId(Optional<Long> accountId) {
            Utils.checkNotNull(accountId, "accountId");
            this.accountId = accountId;
            return this;
        }

        /**
         * Filters content by field and direction/equality
         * (Unknown if viewedAt is the only supported column)
         * 
         */
        public Builder filter(QueryParamFilter filter) {
            Utils.checkNotNull(filter, "filter");
            this.filter = Optional.ofNullable(filter);
            return this;
        }

        /**
         * Filters content by field and direction/equality
         * (Unknown if viewedAt is the only supported column)
         * 
         */
        public Builder filter(Optional<? extends QueryParamFilter> filter) {
            Utils.checkNotNull(filter, "filter");
            this.filter = filter;
            return this;
        }

        /**
         * Filters the results based on the id of a valid library section
         * 
         */
        public Builder librarySectionID(long librarySectionID) {
            Utils.checkNotNull(librarySectionID, "librarySectionID");
            this.librarySectionID = Optional.ofNullable(librarySectionID);
            return this;
        }

        /**
         * Filters the results based on the id of a valid library section
         * 
         */
        public Builder librarySectionID(Optional<Long> librarySectionID) {
            Utils.checkNotNull(librarySectionID, "librarySectionID");
            this.librarySectionID = librarySectionID;
            return this;
        }
        
        public GetSessionHistoryRequest build() {
            return new GetSessionHistoryRequest(
                sort,
                accountId,
                filter,
                librarySectionID);
        }
    }
}

