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

package dev.plexapi.sdk.models.operations;

import com.fasterxml.jackson.core.type.TypeReference;
import dev.plexapi.sdk.utils.LazySingletonValue;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Double;
import java.lang.String;
import java.util.Optional;

public class PerformSearchRequestBuilder {

    private String query;
    private Optional<Double> sectionId = Optional.empty();
    private Optional<Double> limit = Utils.readDefaultOrConstValue(
                            "limit",
                            "3",
                            new TypeReference<Optional<Double>>() {});
    private final SDKMethodInterfaces.MethodCallPerformSearch sdk;

    public PerformSearchRequestBuilder(SDKMethodInterfaces.MethodCallPerformSearch sdk) {
        this.sdk = sdk;
    }

    public PerformSearchRequestBuilder query(String query) {
        Utils.checkNotNull(query, "query");
        this.query = query;
        return this;
    }
                
    public PerformSearchRequestBuilder sectionId(double sectionId) {
        Utils.checkNotNull(sectionId, "sectionId");
        this.sectionId = Optional.of(sectionId);
        return this;
    }

    public PerformSearchRequestBuilder sectionId(Optional<Double> sectionId) {
        Utils.checkNotNull(sectionId, "sectionId");
        this.sectionId = sectionId;
        return this;
    }
                
    public PerformSearchRequestBuilder limit(double limit) {
        Utils.checkNotNull(limit, "limit");
        this.limit = Optional.of(limit);
        return this;
    }

    public PerformSearchRequestBuilder limit(Optional<Double> limit) {
        Utils.checkNotNull(limit, "limit");
        this.limit = limit;
        return this;
    }

    public PerformSearchResponse call() throws Exception {
        if (limit == null) {
            limit = _SINGLETON_VALUE_Limit.value();
        }
        return sdk.performSearch(
            query,
            sectionId,
            limit);
    }

    private static final LazySingletonValue<Optional<Double>> _SINGLETON_VALUE_Limit =
            new LazySingletonValue<>(
                    "limit",
                    "3",
                    new TypeReference<Optional<Double>>() {});
}
