77032262c4
fixes https://github.com/TryGhost/Team/issues/2542 fixes https://github.com/TryGhost/Team/issues/2543 fixes https://github.com/TryGhost/Team/issues/2544 - Hides incomplete subscriptions - Shows Past Due subscriptions - Fixed UI issues with 3+ subscriptions - Fixed missing complimentary subscription when one subscription was incomplete/inactive - Fixed sending a paid subscription started email for incomplete subscriptions. This change also required us to actually send the email when the incomplete subscription eventually becomes active. So the introduction of a new `SubscriptionActivatedEvent` made sense/was required (because sending a SubscriptionCreatedEvent again would cause other issues).
32 lines
915 B
JavaScript
32 lines
915 B
JavaScript
/**
|
|
* Fired when a subscription is created. This can also happen when inactive subscriptions are created (incomplete, canceled...).
|
|
*
|
|
* @typedef {object} SubscriptionCreatedEventData
|
|
* @prop {string} source
|
|
* @prop {string} memberId
|
|
* @prop {string} batchId
|
|
* @prop {string} tierId
|
|
* @prop {string} subscriptionId
|
|
* @prop {string} offerId
|
|
* @prop {import('@tryghost/member-attribution/lib/attribution').Attribution} [attribution]
|
|
*/
|
|
|
|
module.exports = class SubscriptionCreatedEvent {
|
|
/**
|
|
* @param {SubscriptionCreatedEventData} data
|
|
* @param {Date} timestamp
|
|
*/
|
|
constructor(data, timestamp) {
|
|
this.data = data;
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
/**
|
|
* @param {SubscriptionCreatedEventData} data
|
|
* @param {Date} [timestamp]
|
|
*/
|
|
static create(data, timestamp) {
|
|
return new SubscriptionCreatedEvent(data, timestamp ?? new Date);
|
|
}
|
|
};
|