Ghost/ghost/offers/lib/domain/events/OfferCodeChangeEvent.js

28 lines
661 B
JavaScript
Raw Normal View History

/** @typedef {import('../models/OfferCode')} OfferCode */
/**
* @typedef {object} OfferCodeChangeEventData
* @prop {string} offerId
* @prop {OfferCode} previousCode
* @prop {OfferCode} currentCode
*/
module.exports = class OfferCodeChangeEvent {
/**
* @param {OfferCodeChangeEventData} data
* @param {Date} timestamp
*/
constructor(data, timestamp) {
this.data = data;
this.timestamp = timestamp;
}
/**
* @param {OfferCodeChangeEventData} data
* @param {Date} [timestamp]
*/
static create(data, timestamp) {
return new OfferCodeChangeEvent(data, timestamp || new Date);
}
};