TryGhost/Ghost

View on GitHub
ghost/email-events/lib/EmailUnsubscribedEvent.js

Summary

Maintainability
B
6 hrs
Test Coverage
module.exports = class EmailUnsubscribedEvent {
    /**
     * @readonly
     * @type {string}
     */
    email;

    /**
     * @readonly
     * @type {string}
     */
    memberId;

    /**
     * @readonly
     * @type {string}
     */
    emailId;

    /**
     * @readonly
     * @type {Date}
     */
    timestamp;

    /**
     * @private
     */
    constructor({email, memberId, emailId, timestamp}) {
        this.memberId = memberId;
        this.emailId = emailId;
        this.email = email;
        this.timestamp = timestamp;
    }

    static create(data) {
        return new EmailUnsubscribedEvent({
            ...data,
            timestamp: data.timestamp || new Date
        });
    }
};