models/communities/MembersQuery.js

export default class MembersQuery {
    /**
     * Creates a MembersQuery.
     *
     * @constructor MembersQuery
     * @param {string} groupId - Group ID
     */
    constructor(groupId) {
        this.groupId = groupId;
    }

    /**
     * Create a query to get members of a group.
     *
     * @memberof MembersQuery
     * @param {string} groupId - Group ID.
     * @return {MembersQuery} New query.
     */
    static ofGroup(groupId) {
        return new MembersQuery(groupId);
    }

    /**
     * Filters members by role.
     *
     * @memberof MembersQuery
     * @instance
     * @param {number} role - Member role.
     * @return {MembersQuery} Same instance.
     */
    withRole(role) {
        this.role = role;
        return this;
    }

    /**
     * Filters members by status.
     *
     * @memberof MembersQuery
     * @instance
     * @param {number} status - Member status.
     * @return {MembersQuery} Same instance.
     */
    withStatus(status) {
        this.status = status;
        return this;
    }

    /**
     * Filters memebrs by username or display name.
     *
     * @memberof MembersQuery
     * @instance
     * @param {string} searchTerm - Beginning of username or display name.
     * @return {MembersQuery} Same query.
     */
    withName(searchTerm) {
        this.searchTerm = searchTerm;

        return this;
    }
}