Skip to content

Instantly share code, notes, and snippets.

@jwynia
Created November 27, 2019 03:21
Show Gist options
  • Select an option

  • Save jwynia/f6e188b18633465afc6d48b430a81174 to your computer and use it in GitHub Desktop.

Select an option

Save jwynia/f6e188b18633465afc6d48b430a81174 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
var twilioSid = "GOGETYOURS";
var twilioToken = "GOGETYOURS";
var mapsApiKey = "GOGETYOURS";
GoogleSigned.AssignAllServices(new GoogleSigned(mapsApiKey));
while (true)
{
CheckCommute(twilioSid,twilioToken);
System.Threading.Thread.Sleep(900000);
}
}
private static void CheckCommute(string twilioSid, string twilioToken)
{
Console.WriteLine("Checking...");
DirectionRequest request = new DirectionRequest();
request.Origin = new Location("123 Maple Ln, 55448");
request.Destination = new Location("Vandalay Industries, 123 Main St, Minneapolis, MN");
var directionService = new DirectionService();
var response = directionService.GetResponse(request);
var durationMinutes = int.Parse(response.Routes.First().Legs.First().Duration.ToString().Split(' ')[0]);
if (durationMinutes < 30)
{
TwilioClient.Init(twilioSid, twilioToken);
var message = MessageResource.Create(
body: $"Commute is down to {durationMinutes} minutes.",
from: new Twilio.Types.PhoneNumber("+15555551234"),
to: new Twilio.Types.PhoneNumber("+15555551234")
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment