in src/WebJobs.Extensions.Twilio/Config/TwilioExtensionConfigProvider.cs [85:161]
internal static CreateMessageOptions CreateMessageOptions(JObject messageOptions)
{
var options = new CreateMessageOptions(new PhoneNumber(GetValueOrDefault<string>(messageOptions, "to")))
{
Body = GetValueOrDefault<string>(messageOptions, "body"),
ForceDelivery = GetValueOrDefault<bool?>(messageOptions, "forceDelivery"),
ValidityPeriod = GetValueOrDefault<int?>(messageOptions, "validityPeriod"),
ProvideFeedback = GetValueOrDefault<bool?>(messageOptions, "provideFeedback"),
MaxPrice = GetValueOrDefault<decimal?>(messageOptions, "maxPrice"),
ApplicationSid = GetValueOrDefault<string>(messageOptions, "applicationSid"),
MessagingServiceSid = GetValueOrDefault<string>(messageOptions, "messagingServiceSid"),
PathAccountSid = GetValueOrDefault<string>(messageOptions, "pathAccountSid"),
Attempt = GetValueOrDefault<int?>(messageOptions, "attempt"),
SmartEncoded = GetValueOrDefault<bool?>(messageOptions, "smartEncoded"),
ShortenUrls = GetValueOrDefault<bool?>(messageOptions, "shortenUrls"),
SendAt = GetValueOrDefault<DateTime?>(messageOptions, "sendAt"),
SendAsMms = GetValueOrDefault<bool?>(messageOptions, "sendAsMms"),
ContentSid = GetValueOrDefault<string>(messageOptions, "contentSid"),
ContentVariables = GetValueOrDefault<string>(messageOptions, "contentVariables")
};
string value = GetValueOrDefault<string>(messageOptions, "from");
if (!string.IsNullOrEmpty(value))
{
options.From = new PhoneNumber(value);
}
value = GetValueOrDefault<string>(messageOptions, "statusCallback");
if (!string.IsNullOrEmpty(value))
{
options.StatusCallback = new Uri(value);
}
JArray mediaUrls = GetValueOrDefault<JArray>(messageOptions, "mediaUrl");
if (mediaUrls != null)
{
List<Uri> uris = new List<Uri>();
foreach (var url in mediaUrls)
{
uris.Add(new Uri((string)url));
}
options.MediaUrl = uris;
}
var contentRetention = GetValueOrDefault<string>(messageOptions, "ContentRetention");
if (!string.IsNullOrEmpty(contentRetention))
{
options.ContentRetention = contentRetention;
}
var addressRetention = GetValueOrDefault<string>(messageOptions, "addressRetention");
if (!string.IsNullOrEmpty(addressRetention))
{
options.AddressRetention = addressRetention;
}
var persistentActions = GetValueOrDefault<JArray>(messageOptions, "persistentAction");
if (persistentActions != null)
{
var actions = new List<string>();
foreach (var action in persistentActions)
{
actions.Add((string)action);
}
options.PersistentAction = actions;
}
var scheduleType = GetValueOrDefault<string>(messageOptions, "scheduleType");
if (!string.IsNullOrEmpty(scheduleType))
{
options.ScheduleType = scheduleType;
}
return options;
}