public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { // initialize integration services var todoistService = new TodoistIntegrationService(HttpConfiguration.TodoistApiKey, HttpConfiguration.TableStorageConnectionString, HttpConfiguration.GiosUserId); var habiticaService = new HabiticaIntegrationService(HttpConfiguration.HabiticaUserId, HttpConfiguration.HabiticaApiKey, HttpConfiguration.TableStorageConnectionString, HttpConfiguration.GiosUserId); // get all changed items from todoist var items = await todoistService.ReadItemChanges(); // perform actions await habiticaService.Add(items.WhereAdded()); await habiticaService.Update(items.WhereUpdated()); await habiticaService.Complete(items.WhereCompleted()); await habiticaService.Delete(items.WhereDeleted()); // commit read changes await todoistService.CommitRead(); // return success return(new OkResult()); }
public static async Task Run([TimerTrigger("0 */30 * * * *")] TimerInfo myTimer, ILogger log) { // initialize integration services var todoistService = new TodoistIntegrationService(ScheduledConfiguration.TodoistApiKey, ScheduledConfiguration.TableStorageConnectionString, ScheduledConfiguration.GiosUserId); var habiticaService = new HabiticaIntegrationService(ScheduledConfiguration.HabiticaUserId, ScheduledConfiguration.HabiticaApiKey, ScheduledConfiguration.TableStorageConnectionString, ScheduledConfiguration.GiosUserId); // get all changed items from todoist var items = await todoistService.ReadItemChanges(); // perform actions await habiticaService.Add(items.WhereAdded()); await habiticaService.Update(items.WhereUpdated()); await habiticaService.Complete(items.WhereCompleted()); await habiticaService.Delete(items.WhereDeleted()); // commit read changes await todoistService.CommitRead(); }