-
Notifications
You must be signed in to change notification settings - Fork 177
/
Copy pathInfobipWhatsAppExtensions.cs
33 lines (30 loc) · 1.21 KB
/
InfobipWhatsAppExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Bot.Builder.Community.Adapters.Infobip.WhatsApp.Models;
using Microsoft.Bot.Schema;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Bot.Builder.Community.Adapters.Infobip.WhatsApp
{
public static class InfobipWhatsAppExtensions
{
public static async Task DownloadContent(this Attachment self)
{
var attachment = await InfobipWhatsAppClient.GetAttachmentAsync(self.ContentUrl).ConfigureAwait(false);
self.Content = attachment?.Content;
self.ContentType = attachment?.ContentType;
}
public static void AddInfobipWhatsAppTemplateMessage(this Activity activity, InfobipWhatsAppTemplateMessage message)
{
var attachment = new Attachment
{
ContentType = InfobipWhatsAppAttachmentContentTypes.WhatsAppMessageTemplate,
Content = message
};
AddAttachment(activity, attachment);
}
private static void AddAttachment(Activity activity, Attachment attachment)
{
if (activity.Attachments == null) activity.Attachments = new List<Attachment>();
activity.Attachments.Add(attachment);
}
}
}