models/communities/AnnouncementsQuery.js

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

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

    /**
     * Get announcements for user's feed.
     *
     * @memberof AnnouncementsQuery
     * @param {UserId} id - User ID.
     * @return {AnnouncementsQuery} - A new query.
     */
    static forFeedOf(id) {
        return new AnnouncementsQuery(CommunitiesIds.user(id));
    }

    /**
     * Get announcements in topic.
     *
     * @memberof AnnouncementsQuery
     * @param {string} id - Topic ID.
     * @return {AnnouncementsQuery} - A new query.
     */
    static inTopic(id) {
        return new AnnouncementsQuery(CommunitiesIds.topic(id));
    }

    /**
     * Get announcements in a group.
     *
     * @memberof AnnouncementsQuery
     * @param {string} id - Group ID.
     * @return {AnnouncementsQuery} - A new query.
     */
    static inGroup(id) {
        return new AnnouncementsQuery(CommunitiesIds.group(id));
    }

    /**
     * Get announcements for all feeds and targeting users timeline.
     *
     * @memberof AnnouncementsQuery
     * @return {AnnouncementsQuery} - A new query.
     */
    static timeline() {
        return new AnnouncementsQuery(CommunitiesIds.timeline());
    }

    /**
     * Get activities with the specified poll status.
     *
     * @memberof AnnouncementsQuery
     * @instance
     * @param {number} status - Poll status value.
     * @return {AnnouncementsQuery} - A new query.
     */
    withPollStatus(status) {
        this.pollStatus = !!Object.keys(PollStatus)[status]
            ? status
            : null;
        return this;
    }
}