UNPKG

medusa-plugin-sendgrid-typescript

Version:
31 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.config = void 0; async function restockHandler({ data, eventName, container, pluginOptions, }) { const sendGridService = container.resolve("sendgridService"); const templateId = await sendGridService.getTemplateId("restock-notification.restocked"); if (!templateId) { return; } const fetchedData = await sendGridService.fetchData("restock-notification.restocked", data, null); if (!data.emails) { return; } return await Promise.all(fetchedData.emails.map(async (e) => { const sendOptions = { templateId: templateId, from: sendGridService.options_.from, to: e, dynamicTemplateData: fetchedData, }; return await sendGridService.sendEmail(sendOptions); })); } exports.default = restockHandler; exports.config = { event: "restock-notification.restocked", context: { subscriberId: "restock-handler", }, }; //# sourceMappingURL=restock.js.map