models/communities/TopicsQuery.js

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

export default class TopicsQuery {
    /**
     * Creates a TopicsQuery.
     *
     * @constructor TopicsQuery
     */
     constructor() {
        this.search = null;
        this.userId = null;
    }

    /**
     * Get all topics.
     *
     * @memberof TopicsQuery
     * @return {TopicsQuery} - New TopicsQuery instance.
     */
    static all() {
        const instance = new TopicsQuery();
        return instance;
    }

    /**
     * Find topics by name or description.
     *
     * @memberof TopicsQuery
     * @param {string} searchTerm - Topics name/description or part of it.
     * @return {TopicsQuery} - New TopicsQuery instance.
     */
    static find(searchTerm) {
        const instance = new TopicsQuery();
        instance.search = searchTerm;
        return instance;
    }

    /**
     * Get topics followed by a specific user.
     *
     * @memberof TopicsQuery
     * @instance
     * @param {UserId} userId - User ID.
     * @return {TopicsQuery} - New TopicsQuery instance.
     */
    followedBy(userId) {
        this.userId = userId;
        return this;
    }

    /**
     * Get only trending topics.
     *
     * @memberof TopicsQuery
     * @instance
     * @param {boolean} trending - Only trending topics or all.
     * @return {TopicsQuery} Same query.
     */
     onlyTrending(trending) {
        this.trending = trending;
        return this;
    }

    /**
     * Get topics matching the specified properties.
     *
     * @memberof TopicsQuery
     * @instance
     * @param {Object<string, string>} properties - Properties.
     * @return {TopicsQuery} same query.
     */
     withProperties(properties) {
        this.properties = properties;
        return this;
    }

    /**
     * Get topics matching the specified labels.
     *
     * @memberof TopicsQuery
     * @instance
     * @param {string[]} labels - Labels list.
     * @return {TopicsQuery} same query.
     */
    withLabels(labels) {
        this.labels = labels;
        return this;
    }
}