Created
November 27, 2019 03:21
-
-
Save jwynia/f6e188b18633465afc6d48b430a81174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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