TryGhost/Ghost

View on GitHub
ghost/member-events/lib/SubscriptionCancelledEvent.js

Summary

Maintainability
A
2 hrs
Test Coverage
/**
 * @typedef {object} SubscriptionCancelledEventData
 * @prop {string} source
 * @prop {string} memberId
 * @prop {string} tierId
 * @prop {string} subscriptionId
 */

module.exports = class SubscriptionCancelledEvent {
    /**
     * @param {SubscriptionCancelledEventData} data
     * @param {Date} timestamp
     */
    constructor(data, timestamp) {
        this.data = data;
        this.timestamp = timestamp;
    }

    /**
     * @param {SubscriptionCancelledEventData} data
     * @param {Date} [timestamp]
     */
    static create(data, timestamp) {
        return new SubscriptionCancelledEvent(data, timestamp || new Date);
    }
};