public List <MessageResource> GetMessagesFromTwilio(PluginConfig pluginConfig, int secondsAgo) { this.Log.LogDebug("Starting GetMessagesFromTwilio"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; TwilioClient.Init(pluginConfig.AccountSID, pluginConfig.AuthToken); ReadMessageOptions options = new ReadMessageOptions { To = new PhoneNumber(pluginConfig.FromNumber), DateSentAfter = DateTime.Now.AddSeconds(secondsAgo * -1) }; ResourceSet <MessageResource> messages = MessageResource.Read(options); foreach (MessageResource message in messages) { string from = message.From.ToString(); string body = message.Body; string created = message.DateCreated.GetValueOrDefault(DateTime.MinValue).ToLongDateString(); this.Log.LogDebug(string.Format("From: {0}, created: {1}, body: {2}", from, created, body)); } return(messages.Where((message) => message.DateCreated.GetValueOrDefault(DateTime.MinValue).CompareTo(options.DateSentAfter) >= 0).ToList()); }