Black Rock Reporting Azure Function
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ClockifyApiIntegrationFunction.cs 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Net;
  3. using System.Net.Http.Headers;
  4. using Microsoft.Azure.Functions.Worker;
  5. using Microsoft.Extensions.Logging;
  6. namespace BlackRockReportFunction
  7. {
  8. public class ClockifyApiIntegrationFunction
  9. {
  10. private readonly ILogger _logger;
  11. public static HttpClient HttpApiClient { get; set; } = new HttpClient();
  12. public ClockifyApiIntegrationFunction(ILoggerFactory loggerFactory)
  13. {
  14. _logger = loggerFactory.CreateLogger<ClockifyApiIntegrationFunction>();
  15. }
  16. public static void InitializeClockifyIntegration()
  17. {
  18. HttpApiClient = new HttpClient();
  19. HttpApiClient.BaseAddress = new Uri("https://reports.api.clockify.me/v1");
  20. HttpApiClient.DefaultRequestHeaders.Accept.Clear();
  21. HttpApiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  22. }
  23. public static void GetReportsFromClockify(string url)
  24. {
  25. //adding api key header
  26. HttpApiClient.DefaultRequestHeaders.Add("X-Api-Key", "*********");
  27. //making request
  28. }
  29. [Function("ClockifyApiIntegrationFunction")]
  30. public void Run([TimerTrigger("*/5 * * * * *")] MyInfo myTimer)
  31. {
  32. _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
  33. }
  34. }
  35. public class MyInfo
  36. {
  37. public MyScheduleStatus ScheduleStatus { get; set; }
  38. public bool IsPastDue { get; set; }
  39. }
  40. public class MyScheduleStatus
  41. {
  42. public DateTime Last { get; set; }
  43. public DateTime Next { get; set; }
  44. public DateTime LastUpdated { get; set; }
  45. }
  46. }