UNPKG

@botonic/plugin-flow-builder

Version:

Botonic plugin for **Hubtype Flow Builder**: run and bridge flow-driven logic from bots on the **current** line.

43 lines 2.02 kB
import { __awaiter } from "tslib"; import { BotServerMessageFactory, } from '@botonic/core'; import { trackOneContent } from '../../tracking'; import { ContentFieldsBase } from '../content-fields-base'; import { FlowWhatsappButtonListSection } from './flow-whatsapp-button-list-section'; export class FlowWhatsappButtonList extends ContentFieldsBase { constructor() { super(...arguments); this.text = ''; this.listButtonText = ''; this.sections = []; } static fromHubtypeCMS(component, locale, cmsApi) { const newWhatsappButtonList = new FlowWhatsappButtonList(component.id); newWhatsappButtonList.code = component.code; newWhatsappButtonList.text = this.getTextByLocale(locale, component.content.text); newWhatsappButtonList.listButtonText = this.getTextByLocale(locale, component.content.button_text); newWhatsappButtonList.sections = component.content.sections.map(section => FlowWhatsappButtonListSection.fromHubtypeCMS(section, locale, cmsApi)); newWhatsappButtonList.followUp = component.follow_up; return newWhatsappButtonList; } trackFlow(botonicContext) { return __awaiter(this, void 0, void 0, function* () { yield trackOneContent(botonicContext, this); }); } processContent(botonicContext) { return __awaiter(this, void 0, void 0, function* () { yield this.trackFlow(botonicContext); return this.filterContent(botonicContext, this); }); } toBotonic(botonicContext) { const replacedText = this.replaceVariables(this.text, botonicContext); return BotServerMessageFactory.createWhatsappButtonList({ body: replacedText, button: this.listButtonText, sections: this.sections.map((section, sectionIndex) => section.addSectionToBotonic(sectionIndex)), // TODO: Add metadata at this point? }); } } //# sourceMappingURL=flow-whatsapp-button-list.js.map