module author Christos Panagiotakopoulos <chrispanag@gmail.com>
 *  copyright license import { TemplateAttachment } from './attachments' ; import { Button } from './buttons' ; import { ElementInput , GenericTemplateOptions } from './interfaces' ; extends TemplateAttachment export class ButtonTemplate extends TemplateAttachment { param { string } text param { Button [ ] } buttons constructor ( text , buttons = [ ] ) { let serializedButtons = [ ] ; if ( buttons . length > 0 ) { serializedButtons = buttons . map ( ( b ) => b . serialize ( ) ) ; } super ( { template_type : 'button' , text , buttons : serializedButtons } ) ; } } export class OneTimeNotificationRequestTemplate extends TemplateAttachment { param { string } text param { any } payload constructor ( title , payload ) { super ( { template_type : 'one_time_notif_req' , title , payload } ) ; } } extends TemplateAttachment export class GenericTemplate extends TemplateAttachment { param options param { Array } options . elements param { string } options . image_aspect_ratio param { string } sharable constructor ( { elements , image_aspect_ratio = 'horizontal' , sharable = 'false' } ) { super ( { template_type : 'generic' , elements , image_aspect_ratio , sharable } ) ; } } extends TemplateAttachment export class MediaTemplate extends TemplateAttachment { /**
     * Create a MediaTemplate
     */ constructor ( attachment_id , buttons = null , media_type = 'image' ) { let serializedButtons = [ ] ; if ( buttons ) { serializedButtons = buttons . map ( ( b ) => b . serialize ( ) ) ; } super ( { template_type : 'media' , elements : [ { media_type , attachment_id , buttons : serializedButtons } ] } ) ; } } /**
 * Create a card element of a Generic Template
 */ export function cardElement ( { title = null , subtitle = null , image_url = null , buttons = [ ] } ) { let serializedButtons = [ ] ; if ( buttons ) { serializedButtons = buttons . map ( ( b ) => b . serialize ( ) ) ; } return { title , subtitle , image_url , buttons : serializedButtons } ; }