/* DO NOT EDIT */
/* This file was generated by Stone */

package com.dropbox.core.v2.sharing;

import com.dropbox.core.DbxException;

import java.util.List;

/**
 * The request builder returned by {@link
 * DbxUserSharingRequests#addFileMemberBuilder}.
 *
 * <p> Use this class to set optional request parameters and complete the
 * request. </p>
 */
public class AddFileMemberBuilder {
    private final DbxUserSharingRequests _client;
    private final AddFileMemberArgs.Builder _builder;

    /**
     * Creates a new instance of this builder.
     *
     * @param _client  Dropbox namespace-specific client used to issue sharing
     *     requests.
     * @param _builder  Request argument builder.
     *
     * @return instsance of this builder
     */
    AddFileMemberBuilder(DbxUserSharingRequests _client, AddFileMemberArgs.Builder _builder) {
        if (_client == null) {
            throw new NullPointerException("_client");
        }
        this._client = _client;
        if (_builder == null) {
            throw new NullPointerException("_builder");
        }
        this._builder = _builder;
    }

    /**
     * Set value for optional field.
     *
     * @param customMessage  Message to send to added members in their
     *     invitation.
     *
     * @return this builder
     */
    public AddFileMemberBuilder withCustomMessage(String customMessage) {
        this._builder.withCustomMessage(customMessage);
        return this;
    }

    /**
     * Set value for optional field.
     *
     * <p> If left unset or set to {@code null}, defaults to {@code false}. </p>
     *
     * @param quiet  Whether added members should be notified via email and
     *     device notifications of their invitation. Defaults to {@code false}
     *     when set to {@code null}.
     *
     * @return this builder
     */
    public AddFileMemberBuilder withQuiet(Boolean quiet) {
        this._builder.withQuiet(quiet);
        return this;
    }

    /**
     * Set value for optional field.
     *
     * <p> If left unset or set to {@code null}, defaults to {@code
     * AccessLevel.VIEWER}. </p>
     *
     * @param accessLevel  AccessLevel union object, describing what access
     *     level we want to give new members. Must not be {@code null}. Defaults
     *     to {@code AccessLevel.VIEWER} when set to {@code null}.
     *
     * @return this builder
     *
     * @throws IllegalArgumentException  If any argument does not meet its
     *     preconditions.
     */
    public AddFileMemberBuilder withAccessLevel(AccessLevel accessLevel) {
        this._builder.withAccessLevel(accessLevel);
        return this;
    }

    /**
     * Set value for optional field.
     *
     * <p> If left unset or set to {@code null}, defaults to {@code false}. </p>
     *
     * @param addMessageAsComment  If the custom message should be added as a
     *     comment on the file. Defaults to {@code false} when set to {@code
     *     null}.
     *
     * @return this builder
     */
    public AddFileMemberBuilder withAddMessageAsComment(Boolean addMessageAsComment) {
        this._builder.withAddMessageAsComment(addMessageAsComment);
        return this;
    }

    /**
     * Issues the request.
     */
    public List<FileMemberActionResult> start() throws AddFileMemberErrorException, DbxException {
        AddFileMemberArgs arg_ = this._builder.build();
        return _client.addFileMember(arg_);
    }
}
