models/communities/CommunitiesIds.js

import CommunitiesEntityType from './CommunitiesEntityType';
import UserId from '../UserId';
import UserIdList from '../UserIdList';

export default class CommunitiesIds {
    /**
     * Creates a CommunitiesIds
     *
     * @constructor CommunitiesIds
     * @param {number} type - Entity type.
     * @param {string[]} ids - Entity IDs.
     */
    constructor(type, ids) {
        this.ids = ids || [];
        if (type > -1) {
            this.type = type;
        }
    }

    /**
     * CommunitiesIds for a single topic
     *
     * @memberof CommunitiesIds
     * @param {string} id - Topic ID.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static topic(id) {
        return new CommunitiesIds(CommunitiesEntityType.Topic, [id]);
    }

    /**
     * CommunitiesIds for multiple topics
     *
     * @memberof CommunitiesIds
     * @param {string[]} ids - Topic IDs.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static topics(ids) {
        return new CommunitiesIds(CommunitiesEntityType.Topic, ids);
    }

    /**
     * CommunitiesIds for a single group
     *
     * @memberof CommunitiesIds
     * @param {string} id - Group ID.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static group(id) {
        return new CommunitiesIds(CommunitiesEntityType.Group, [id]);
    }

    /**
     * CommunitiesIds for multiple groups
     *
     * @memberof CommunitiesIds
     * @param {string[]} ids - Group IDs.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static groups(ids) {
        return new CommunitiesIds(CommunitiesEntityType.Group, ids);
    }

    /**
     * CommunitiesIds for a single user
     *
     * @memberof CommunitiesIds
     * @param {UserId} userId - User ID.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static user(userId) {
        return new CommunitiesIds(CommunitiesEntityType.User, [userId.id]);
    }

    /**
     * CommunitiesIds for multiple users
     *
     * @memberof CommunitiesIds
     * @param {UserIdList} userIdList - User ID list.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static users(userIdList) {
        return new CommunitiesIds(CommunitiesEntityType.User, userIdList.ids);
    }

    /**
     * CommunitiesIds for a single activity
     *
     * @memberof CommunitiesIds
     * @param {string} id - Activity ID.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static activity(id) {
        return new CommunitiesIds(CommunitiesEntityType.Activity, [id]);
    }

    /**
     * CommunitiesIds for a single label
     *
     * @memberof CommunitiesIds
     * @param {string} id - Label.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
     static label(id) {
        return new CommunitiesIds(CommunitiesEntityType.Label, [id]);
    }

    /**
     * CommunitiesIds for multiple labels
     *
     * @memberof CommunitiesIds
     * @param {string[]} ids - Labels.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
     static labels(ids) {
        return new CommunitiesIds(CommunitiesEntityType.Label, ids);
    }

    /**
     * CommunitiesIds for a single tag
     *
     * @memberof CommunitiesIds
     * @param {string} id - Tag.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
     static tag(id) {
        return new CommunitiesIds(CommunitiesEntityType.Tag, [id]);
    }

    /**
     * CommunitiesIds for multiple tags
     *
     * @memberof CommunitiesIds
     * @param {string[]} ids - Tags.
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
     static tags(ids) {
        return new CommunitiesIds(CommunitiesEntityType.Tag, ids);
    }


    /**
     * CommunitiesIds for a timeline
     *
     * @memberof CommunitiesIds
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static timeline() {
        return new CommunitiesIds(CommunitiesEntityType.App, ['timeline']);
    }

    /**
     * CommunitiesIds for everywhere (no specific entity/entities)
     *
     * @memberof CommunitiesIds
     * @return {CommunitiesIds} - CommunitiesIds instance.
     */
    static everywhere() {
        return new CommunitiesIds();
    }
}