models/communities/FollowersQuery.js

import UserId from './../UserId.js';
import CommunitiesIds from './CommunitiesIds.js';

export default class FollowersQuery {
    /**
     * Creates a FollowersQuery
     *
     * @constructor FollowersQuery
     * @param {CommunitiesIds} ids - Entity IDs.
     */
    constructor(ids) {
        this.ids = ids;
    }

    /**
     * Get followers of topic with ID.
     *
     * @memberof FollowersQuery
     * @param {string} id - Topic ID.
     * @return {FollowersQuery} New query.
     */
    static ofTopic(id) {
        return new FollowersQuery(CommunitiesIds.topic(id));
    }

    /**
     * Get followers of group with ID.
     *
     * @memberof FollowersQuery
     * @param {string} id - Group ID.
     * @return {FollowersQuery} New query.
     */
    static ofGroup(id) {
        return new FollowersQuery(CommunitiesIds.group(id));
    }

    /**
     * Get followers of user with ID.
     *
     * @memberof FollowersQuery
     * @param {UserId} id - User ID.
     * @return {FollowersQuery} New query.
     */
    static ofUser(id) {
        return new FollowersQuery(CommunitiesIds.user(id));
    }

    /**
     * Get followers of label.
     *
     * @memberof FollowersQuery
     * @param {string} id - Label.
     * @return {FollowersQuery} New query.
     */
    static ofLabel(id) {
        return new FollowersQuery(CommunitiesIds.label(id));
    }

    /**
     * Get followers of tag.
     *
     * @memberof FollowersQuery
     * @param {string} id - Tag.
     * @return {FollowersQuery} New query.
     */
    static ofTag(id) {
        return new FollowersQuery(CommunitiesIds.tag(id));
    }

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

        return this;
    }
}