import NotificationButton from './NotificationButton.js';
import NotificationBadge from './NotificationBadge.js';
import NotificationCustomization from './NotificationCustomization.js';
import MediaAttachment from './../MediaAttachment.js';
import Action from './../actions/Action.js';
export default class NotificationContent {
/**
* @constructor NotificationContent
*
* @param {Object} contentMap - Content parameters
* @param {sring} [contentMap.text] - Text
* @param {sring} [contentMap.title] - Title
* @param {MediaAttachment} [contentMap.mediaAttachment] - Attachment
* @param {sring} [contentMap.templateName] - Template name
* @param {Object<string, string>} [contentMap.templatePlaceholders={}] - Template placeholders
* @param {Action} [contentMap.action] - Action
* @param {NotificationButton[]} [contentMap.actionButtons=[]] - Action buttons
* @param {NotificationCustomization} [contentMap.customization] - customization
* @param {NotificationBadge} [contentMap.badge] - badge
*/
constructor (contentMap) {
this.text = contentMap.text || null;
this.title = contentMap.title || null;
this.mediaAttachment = contentMap.mediaAttachment
? new MediaAttachment(contentMap.mediaAttachment)
: null;
this.templateName = contentMap.templateName || null;
this.templatePlaceholders = contentMap.templatePlaceholders || {};
this.action = contentMap.action
? new Action(contentMap.action)
: null;
this.actionButtons = contentMap.actionButtons
? contentMap.actionButtons
.map((item) => new NotificationButton(item))
: [];
this.customization = contentMap.customization
? new NotificationCustomization(contentMap.customization)
: null;
this.badge = contentMap.badge
? new NotificationBadge(contentMap.badge)
: null;
}
/**
* Creates a new NotificationContent instance.
*
* @memberof NotificationContent
* @param {string} text - Notification text.
* @return {NotificationContent} New NotificationContent instance.
*/
static withText(text) {
return new NotificationContent({ text });
}
/**
* Creates a new NotificationContent instance from the template configured on the GetSocial Dashboard.
*
* @memberof NotificationContent
* @param {string} templateName - Name of the template on the GetSocial Dashboard. Case-sensitive.
* @return {NotificationContent} New NotificationContent instance.
*/
static withTemplate(templateName) {
return new NotificationContent({ templateName });
}
}