UNPKG

@wepublish/api

Version:
58 lines (57 loc) 2.52 kB
import { Action, LookupActionInput } from './subscription-event-dictionary.type'; import { PrismaClient, Subscription, SubscriptionEvent } from '@prisma/client'; /** * This class loads all subscription flows and allows filtering by member plan, * payment method, periodicity, renewal and EITHER the daysAwayFromEnding or a * list of event names. */ export declare class SubscriptionEventDictionary { private readonly prismaService; private allFlows; constructor(prismaService: PrismaClient); /** * Get the earliest date when an invoice must be created. * @param date The current date. * @returns The earliest date. */ getEarliestInvoiceCreationDate(date: Date): Promise<Date>; /** * Get an array of the dates where custom events have been defined. * @param date The current date. * @returns An array of dates. */ getDatesWithCustomEvent(date: Date): Promise<Date[]>; /** * Try to get the MailTemplates for a specific filter of [memberPlan, * paymentMethod, periodicity, autoRenewal]. You additionally need to pass * either `daysAwayFromEnding` or `events` to filter further. If any * filter leads to an empty result set, the templates of the default flow are * returned. * @param query The filter of the above properties. * @returns An array of MailTemplates. */ getActionsForSubscriptions(query: LookupActionInput): Promise<Action[]>; /** * Load all subscription flows. This is automatically called once per instance. * {@link getActionsForSubscriptions}. */ private initialize; /** * Filter the MailTemplates stored for a specific flow. They can either be * filtered by `daysAwayFromEnding` or by `lookupEvents`. * @param timeline The leaf of the store. * @param daysAwayFromEnding Number of days away from ending. * @param lookupEvents The event identifiers. * @returns Array of mail templates. */ private getActionByDay; private normalizeDate; /** * Get the External Mail Template name for a specific subscription and subscription event. * @param prisma The Prisma client. * @param subsciption The subscription to search for. * @param subscriptionEvent The event to search for. * @returns The external template identifier OR undefined of none was found. */ getSubsciptionTemplateIdentifier(subsciption: Subscription, subscriptionEvent: SubscriptionEvent): Promise<string | undefined>; }