/*jshint esversion: 6 */ export class WCExtension { text(text: String){ return { "type": "text", "content" : text }; } image(url: string, buttons: any, assetId?: string) { return this.media("image", url, assetId); } audio(url: string, buttons: any, assetId?: string) { return this.media("audio", url, assetId); } video(url: string, buttons: any, assetId?: string) { return this.media("video", url, assetId); } media(type: string, url: string, assetId?: string) { const template: any = { "type": type, "media_id": assetId }; if (!assetId){ template.url = url; } return template; } genericTemplate(templates) { return { type : "news", "news": { articles : templates } }; } genericItem(title, subtitle, imageUrl, actionUrl, buttons, assetId, content, author) { const template : any = { "title": title, "description": subtitle, "url": actionUrl, "content": content, "author": author }; if (assetId){ template.thumb_media_id = assetId; } else { template.picurl = imageUrl; } return template; } typing(duration){ return { "type" : "typing", "duration": duration }; } }