|
|
|
@@ -1,4 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Net; |
|
|
|
using System.Net.Http.Headers; |
|
|
|
using Microsoft.Azure.Functions.Worker; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
|
|
|
|
@@ -7,17 +9,40 @@ namespace BlackRockReportFunction |
|
|
|
public class ClockifyApiIntegrationFunction |
|
|
|
{ |
|
|
|
private readonly ILogger _logger; |
|
|
|
public static HttpClient HttpApiClient { get; set; } = new HttpClient(); |
|
|
|
|
|
|
|
public ClockifyApiIntegrationFunction(ILoggerFactory loggerFactory) |
|
|
|
{ |
|
|
|
_logger = loggerFactory.CreateLogger<ClockifyApiIntegrationFunction>(); |
|
|
|
} |
|
|
|
|
|
|
|
public static void InitializeClockifyIntegration() |
|
|
|
{ |
|
|
|
HttpApiClient = new HttpClient(); |
|
|
|
HttpApiClient.BaseAddress = new Uri("https://reports.api.clockify.me/v1"); |
|
|
|
HttpApiClient.DefaultRequestHeaders.Accept.Clear(); |
|
|
|
HttpApiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |
|
|
|
} |
|
|
|
|
|
|
|
public static void GetReportsFromClockify(string url) |
|
|
|
{ |
|
|
|
//adding api key header |
|
|
|
HttpApiClient.DefaultRequestHeaders.Add("X-Api-Key", "*********"); |
|
|
|
|
|
|
|
//making request |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Function("ClockifyApiIntegrationFunction")] |
|
|
|
public void Run([TimerTrigger("*/5 * * * * *")] MyInfo myTimer) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class MyInfo |