@ebenos/viber-elements
Version:
Elements Library for the Ebony framework.
187 lines • 5.96 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Picture = exports.RichMedia = exports.Button = void 0;
/**Viber RichMedia Button */
class Button {
constructor(o) {
this.Columns = 6;
this.Rows = 1;
this.ActionType = 'reply';
this.TextSize = 'regular';
this.TextVAlign = 'middle';
this.TextHAlign = 'center';
this.Silent = false;
this.BgLoop = true;
this.TextOpacity = 100;
this.OpenURLType = 'internal';
this.OpenURLMediaType = 'not-media';
this.TextShouldFit = false;
if (o.Columns !== undefined) {
this.Columns = o.Columns;
}
if (o.Rows !== undefined) {
this.Rows = o.Rows;
}
if (o.TextSize !== undefined) {
this.TextSize = o.TextSize;
}
if (o.Silent !== undefined) {
this.Silent = o.Silent;
}
if (o.TextVAlign !== undefined) {
this.TextVAlign = o.TextVAlign;
}
if (o.TextHAlign !== undefined) {
this.TextHAlign = o.TextHAlign;
}
if (o.ActionType !== undefined) {
this.ActionType = o.ActionType;
}
if (o.BgLoop !== undefined) {
this.BgLoop = o.BgLoop;
}
if (o.TextOpacity !== undefined) {
this.TextOpacity = o.TextOpacity;
}
if (o.OpenURLType !== undefined) {
this.OpenURLType = o.OpenURLType;
}
if (o.TextShouldFit !== undefined) {
this.TextShouldFit = o.TextShouldFit;
}
this.ActionBody = o.ActionBody;
this.Image = o.Image;
this.Text = o.Text;
this.BgColor = o.BgColor;
this.BgMediaType = o.BgMediaType;
this.BgMedia = o.BgMedia;
this.BgMediaScaleType = o.BgMediaScaleType;
this.ImageScaleType = o.ImageScaleType;
this.TextPaddings = o.TextPaddings;
this.TextBgGradientColor = o.TextBgGradientColor;
this.InternalBrowser = o.InternalBrowser;
this.Map = o.Map;
this.Frame = o.Frame;
this.MediaPlayer = o.MediaPlayer;
}
serialize() {
const obj = {
ActionType: this.ActionType,
TextVAlign: this.TextVAlign,
TextHAlign: this.TextHAlign,
ActionBody: this.ActionBody,
TextSize: this.TextSize,
Silent: this.Silent,
Columns: this.Columns,
BgLoop: this.BgLoop,
TextOpacity: this.TextOpacity,
OpenURLType: this.OpenURLType,
OpenURLMediaType: this.OpenURLMediaType,
TextShouldFit: this.TextShouldFit,
Rows: this.Rows
};
if (this.Image !== undefined) {
obj.Image = this.Image;
}
if (this.Text !== undefined) {
obj.Text = this.Text;
}
if (this.BgColor !== undefined) {
obj.BgColor = this.BgColor;
}
if (this.BgMediaType !== undefined) {
obj.BgMediaType = this.BgMediaType;
}
if (this.BgMedia !== undefined) {
obj.BgMedia = this.BgMedia;
}
if (this.BgMediaScaleType !== undefined) {
obj.BgMediaScaleType = this.BgMediaScaleType;
}
if (this.ImageScaleType !== undefined) {
obj.ImageScaleType = this.ImageScaleType;
}
if (this.TextPaddings !== undefined) {
obj.TextPaddings = this.TextPaddings;
}
if (this.TextOpacity !== undefined) {
obj.TextOpacity = this.TextOpacity;
}
if (this.TextSize !== undefined) {
obj.TextSize = this.TextSize;
}
if (this.TextBgGradientColor !== undefined) {
obj.TextBgGradientColor = this.TextBgGradientColor;
}
if (this.InternalBrowser !== undefined) {
obj.InternalBrowser = this.InternalBrowser;
}
if (this.Map !== undefined) {
obj.Map = this.Map;
}
if (this.Frame !== undefined) {
obj.Frame = this.Frame;
}
if (this.MediaPlayer !== undefined) {
obj.MediaPlayer = this.MediaPlayer;
}
return obj;
}
}
exports.Button = Button;
/** Viber RichMedia Attachment */
class RichMedia {
constructor(options) {
this.HeightScale = 100;
const { ButtonsGroupColumns, ButtonsGroupRows, BgColor, Buttons, HeightScale } = options;
this.ButtonsGroupColumns = ButtonsGroupColumns;
this.ButtonsGroupRows = ButtonsGroupRows;
this.BgColor = BgColor;
this.Buttons = Buttons;
if (HeightScale !== undefined) {
this.HeightScale = HeightScale;
}
}
serialize() {
const obj = {
Type: 'rich_media',
Buttons: this.Buttons.map((b) => b.serialize()),
HeightScale: this.HeightScale
};
if (this.ButtonsGroupColumns !== undefined) {
obj.ButtonsGroupColumns = this.ButtonsGroupColumns;
}
if (this.ButtonsGroupRows !== undefined) {
obj.ButtonsGroupRows = this.ButtonsGroupRows;
}
if (this.BgColor !== undefined) {
obj.BgColor = this.BgColor;
}
return obj;
}
}
exports.RichMedia = RichMedia;
/** Viber Image Attachment */
class Picture {
/**
*
* @param media - (Required) URL of the image
* @param thumbnail - URL of a reduced size image
*/
constructor(options) {
const { media, thumbnail } = options;
this.media = media;
this.thumbnail = thumbnail;
}
serialize() {
const obj = {
media: this.media
};
if (this.thumbnail !== undefined) {
obj.thumbnail = this.thumbnail;
}
return obj;
}
}
exports.Picture = Picture;
//# sourceMappingURL=attachments.js.map