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

30 lines
683 B
JavaScript
Raw Normal View History

/** @typedef {import('../models/OfferCode')} OfferCode */
/**
* @typedef {object} OfferCodeChangeEventData
* @prop {string} offerId
* @prop {OfferCode} previousCode
* @prop {OfferCode} currentCode
*/
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);
}
}
module.exports = OfferCodeChangeEvent;