UNPKG

@webuildbots/webuildbots-sdk

Version:
55 lines (54 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var helpers_types_1 = require("../../helpers/helpers-types"); var ChoiceBuilder = /** @class */ (function () { function ChoiceBuilder(action, session, profile, functionArgs) { this.action = action; this.session = session; this.profile = profile; this.functionArgs = functionArgs; this.choice = {}; this.choice = { action: action }; } ChoiceBuilder.prototype.addTitle = function (lang, text) { this.choice.title = this.choice.title || {}; this.choice.title[lang] = text; return this; }; ChoiceBuilder.prototype.setTitle = function (polylang) { this.choice.title = polylang; return this; }; ChoiceBuilder.prototype.selectedTitle = function (text) { this.choice.selectedTitle = text; return this; }; ChoiceBuilder.prototype.persistentMenu = function (isPersistentMenu) { this.choice.persistentMenu = isPersistentMenu; return this; }; ChoiceBuilder.prototype.userStatus = function (userStatus) { this.choice.userStatus = userStatus; return this; }; ChoiceBuilder.prototype.build = function () { if (this.session) { this.choice.session = this.session; } if (this.profile) { this.choice.profile = this.profile; } if (this.functionArgs) { this.choice.functionArgs = this.functionArgs; } if (!this.choice.title) { throw new Error('This block requires a title, you need to call setTitle(..) or addTitle(..) with a truthy value for the title'); } // Clone here so we an use the same builder twice return helpers_types_1.clone(this.choice); }; return ChoiceBuilder; }()); exports.default = ChoiceBuilder;