Builds a promotion mechanic type, which is the behaviour behind a promotion such as a prize draw or an instant win. Obtained from promotionMechanicTypeBuilder on the controller mappings. Set the templates used to edit, summarise and show the mechanic to participants, plus the functions that create its metrics and save its details, then call build to register it. Both chained setters and plain bean setters are exported, so either style works from JavaScript.

Group: Builders


Properties

PropertyReturnsDescription
createMetricsFnStringName of the function that creates the metrics recorded for promotions using this mechanic.
descriptionStringDescription shown to administrators alongside the mechanic name.
editTemplateStringRepository path of the template used to configure a promotion that uses this mechanic.
iconStringIcon class shown beside the mechanic in the promotion editor. Defaults to a generic picture icon.
idStringUnique identifier for the mechanic type, stored against promotions that use it.
participantTemplateStringRepository path of the template shown to a participant taking part in the promotion.
saveMechanicDetailsFnStringName of the function called to save the mechanic's own settings when a promotion is saved.
summaryTemplateStringRepository path of the template that renders the mechanic's summary in the admin promotion list.
supportsWebsitebooleanWhether promotions using this mechanic can be run on a public website as well as in the admin console.
titleStringHuman readable name shown when an administrator chooses a mechanic for a promotion.

Methods

build() · getId() · getTitle() · getIcon() · getDescription() · setDescription(String description) · getEditTemplate() · setEditTemplate(String editTemplate) · getSummaryTemplate() · setSummaryTemplate(String summaryTemplate) · getParticipantTemplate() · setParticipantTemplate(String participantTemplate) · getCreateMetricsFn() · setCreateMetricsFn(String createMetricsFn) · getSaveMechanicDetailsFn() · setSaveMechanicDetailsFn(String saveMechanicDetailsFn) · isSupportsWebsite() · setSupportsWebsite(boolean supportsWebsite) · description(String s) · icon(String s) · editTemplate(String s) · summaryTemplate(String s) · participantTemplate(String s) · createMetricsFn(String s) · saveMechanicDetailsFn(String s) · supportsWebsite(boolean b) · configSchemaFn(String s) · readConfigFn(String s) · saveConfigFn(String s) · supportsConfigUpdate(boolean b)

build()

Returns: RepoAppPromotionMechanicType

Creates the promotion mechanic type from the configured values and registers it against this app. The type is still created and returned once the engine has initialised, but it is no longer registered.

getId()

Returns: String

Unique identifier for the mechanic type, stored against promotions that use it.

getTitle()

Returns: String

Human readable name shown when an administrator chooses a mechanic for a promotion.

getIcon()

Returns: String

Icon class shown beside the mechanic in the promotion editor. Defaults to a generic picture icon.

getDescription()

Returns: String

Description shown to administrators alongside the mechanic name.

setDescription(String description)

Returns: void

Sets the description shown to administrators alongside the mechanic name.

ParameterDescription
descriptionthe description text

getEditTemplate()

Returns: String

Repository path of the template used to configure a promotion that uses this mechanic.

setEditTemplate(String editTemplate)

Returns: void

Sets the repository path of the template used to configure a promotion that uses this mechanic.

ParameterDescription
editTemplatethe edit template path

getSummaryTemplate()

Returns: String

Repository path of the template that renders the mechanic's summary in the admin promotion list.

setSummaryTemplate(String summaryTemplate)

Returns: void

Sets the repository path of the template that renders the mechanic's summary in the admin promotion list.

ParameterDescription
summaryTemplatethe summary template path

getParticipantTemplate()

Returns: String

Repository path of the template shown to a participant taking part in the promotion.

setParticipantTemplate(String participantTemplate)

Returns: void

Sets the repository path of the template shown to a participant taking part in the promotion.

ParameterDescription
participantTemplatethe participant template path

getCreateMetricsFn()

Returns: String

Name of the function that creates the metrics recorded for promotions using this mechanic.

setCreateMetricsFn(String createMetricsFn)

Returns: void

Sets the name of the function that creates the metrics recorded for promotions using this mechanic.

ParameterDescription
createMetricsFnthe create metrics function name

getSaveMechanicDetailsFn()

Returns: String

Name of the function called to save the mechanic's own settings when a promotion is saved.

setSaveMechanicDetailsFn(String saveMechanicDetailsFn)

Returns: void

Sets the name of the function called to save the mechanic's own settings when a promotion is saved.

ParameterDescription
saveMechanicDetailsFnthe save details function name

isSupportsWebsite()

Returns: boolean

Whether promotions using this mechanic can be run on a public website as well as in the admin console.

setSupportsWebsite(boolean supportsWebsite)

Returns: void

Sets whether promotions using this mechanic can be run on a public website.

ParameterDescription
supportsWebsitetrue if the mechanic supports websites

description(String s)

Returns: PromotionMechanicTypeBuilder

Sets the description shown to administrators alongside the mechanic name.

ParameterDescription
sthe description text

icon(String s)

Returns: PromotionMechanicTypeBuilder

Sets the icon class shown beside the mechanic in the promotion editor, replacing the default picture icon.

ParameterDescription
sthe icon CSS classes

editTemplate(String s)

Returns: PromotionMechanicTypeBuilder

Sets the repository path of the template used to configure a promotion that uses this mechanic.

ParameterDescription
sthe edit template path

summaryTemplate(String s)

Returns: PromotionMechanicTypeBuilder

Sets the repository path of the template that renders the mechanic's summary in the admin promotion list.

ParameterDescription
sthe summary template path

participantTemplate(String s)

Returns: PromotionMechanicTypeBuilder

Sets the repository path of the template shown to a participant taking part in the promotion.

ParameterDescription
sthe participant template path

createMetricsFn(String s)

Returns: PromotionMechanicTypeBuilder

Sets the name of the function that creates the metrics recorded for promotions using this mechanic.

ParameterDescription
sthe create metrics function name

saveMechanicDetailsFn(String s)

Returns: PromotionMechanicTypeBuilder

Sets the name of the function called to save the mechanic's own settings when a promotion is saved.

ParameterDescription
sthe save details function name

supportsWebsite(boolean b)

Returns: PromotionMechanicTypeBuilder

Sets whether promotions using this mechanic can be run on a public website.

ParameterDescription
btrue if the mechanic supports websites

configSchemaFn(String s)

Returns: PromotionMechanicTypeBuilder

Sets the name of the function returning this mechanic's settings as a JSON Schema, which is what lets a caller that never rendered the edit template - an AI tool, an importer - configure the mechanic. Without it the mechanic can only be set up through its own admin UI. The function takes no arguments and must return the schema as a JSON string, ie JSON.stringify(schema). It is called each time the schema is needed, so an enum may list what the account actually has, for example its points buckets.

ParameterDescription
sthe config schema function name

readConfigFn(String s)

Returns: PromotionMechanicTypeBuilder

Sets the name of the function returning a promotion's current mechanic settings, in the shape the config schema describes. Needed for update as well as review: saving writes every setting from what it is given, so changing one means reading the rest back and passing them through unchanged. The function takes the promotion and must return the settings as a JSON string, ie JSON.stringify(config).

ParameterDescription
sthe read config function name

saveConfigFn(String s)

Returns: PromotionMechanicTypeBuilder

Sets the name of the function saving a mechanic's settings from a configuration object rather than a form post. Only needed where the settings are nested or repeating: leave it unset and the configuration is flattened into form parameters and passed to the save mechanic details function, which is all a mechanic with flat settings needs. The function takes the promotion and the settings as a JSON string, and must return a JsonResult.

ParameterDescription
sthe save config function name

supportsConfigUpdate(boolean b)

Returns: PromotionMechanicTypeBuilder

Sets whether saving over an existing configuration changes it. Several mechanics only ever create their configuration and ignore a second save, so saying so lets a caller offer update where it works and explain itself where it does not, rather than reporting a success that changed nothing.

ParameterDescription
btrue if the mechanic can be reconfigured after it has been set up
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.