models/notifications/NotificationsQuery.js

export default class NotificationsQuery {
    /**
     * @constructor NotificationsQuery
     *
     * @param {Object} params - Query parameters
     * @param {string[]} [params.statuses=[]] - Statuses list
     * @param {string[]} [params.actions=[]] - Actions list
     * @param {string[]} [params.types=[]] - Types list
     */
    constructor(params) {
        params = params || {};

        this.statuses = params.statuses || [];
        this.actions = params.actions || [];
        this.types = params.types || [];
    }

    /**
     * Creates a new notifications query with the provided statuses.
     *
     * @memberof NotificationsQuery
     * @param {string[]} statuses - statuses to filter for.
     * @return {NotificationsQuery} New query instance.
     */
    static withStatus(statuses) {
        return new NotificationsQuery({
          statuses
        });
    }

    /**
     * Creates a new notifications count query with all the available statuses.
     *
     * @memberof NotificationsQuery
     * @return {NotificationsCountQuery} New query instance.
     */
    static withAllStatus() {
        return new NotificationsQuery();
    }

    /**
     * Sets actions to filter for.
     *
     * @memberof NotificationsQuery
     * @instance
     * @param {string[]} newActions - Actions to filter for.
     * @return {NotificationsQuery} Same instance.
     */
    withActions(newActions) {
        this.actions = newActions;

        return this;
    }

    /**
     * Sets types to filter for.
     *
     * @memberof NotificationsQuery
     * @instance
     * @param {string[]} newTypes - Types to filter for.
     * @return {NotificationsQuery} Same instance.
     */
    ofTypes(newTypes) {
        this.types = newTypes;

        return this;
    }
}