|
|
|
@@ -21,7 +21,7 @@ namespace BlackRockReportFunction |
|
|
|
|
|
|
|
public static async Task InitializeClockifyIntegration() |
|
|
|
{ |
|
|
|
//client.DefaultRequestHeaders.Add("X-API-Key", clockifyApiKey); /// |
|
|
|
//client.DefaultRequestHeaders.Add("X-API-Key", clockifyApiKey); |
|
|
|
|
|
|
|
client.DefaultRequestHeaders.Add("X-API-Key", "MmU2ZTA2MGItMTM1ZS00ZTg1LTkwMjAtMDkzYThiZmNmYmIy"); |
|
|
|
|
|
|
|
@@ -39,11 +39,14 @@ namespace BlackRockReportFunction |
|
|
|
|
|
|
|
[Function("ClockifyApiIntegrationFunction")] |
|
|
|
[QueueOutput("queue1")] |
|
|
|
public string Run([TimerTrigger("*/15 * * * * *" )] MyInfo myTimer) //TODO: Set on Friday at 20 o'clock |
|
|
|
public string Run([TimerTrigger("*/15 * * * * *" )] MyInfo myTimer) //TODO: Set on Friday at 20 o'clock "0 0 20 * * 5" |
|
|
|
{ |
|
|
|
InitializeClockifyIntegration(); // Clockify API Integration |
|
|
|
|
|
|
|
var json = "{\"dateRangeStart\":\"2022-05-30T00:00:00.000\",\"dateRangeEnd\":\"2022-06-05T23:59:59.000\",\"summaryFilter\":{\"groups\":[\"USER\",\"TIMEENTRY\"]},\"clients\":{\"ids\":[\"61488f8d9eb0753d0e40d761\"]},\"projects\":{\"ids\":[\"6242f015f6fe850b94cd0c64\"]},\"amountShown\":\"HIDE_AMOUNT\"}"; |
|
|
|
var monday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday).ToString("yyyy-MM-dd"); |
|
|
|
var friday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Friday).ToString("yyyy-MM-dd"); // TO DO: Set end day of week |
|
|
|
|
|
|
|
var json = "{\"dateRangeStart\":\""+monday+"T00:00:00.000\",\"dateRangeEnd\":\""+friday+"T23:59:59.000\",\"summaryFilter\":{\"groups\":[\"USER\",\"TIMEENTRY\"]},\"clients\":{\"ids\":[\"61488f8d9eb0753d0e40d761\"]},\"projects\":{\"ids\":[\"6242f015f6fe850b94cd0c64\"]},\"amountShown\":\"HIDE_AMOUNT\"}"; |
|
|
|
|
|
|
|
HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json"); |
|
|
|
|
|
|
|
@@ -56,7 +59,7 @@ namespace BlackRockReportFunction |
|
|
|
_logger.LogInformation($"Data collection successfull!"); |
|
|
|
|
|
|
|
return JsonConvert.SerializeObject(JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result), Formatting.Indented); |
|
|
|
//var responseContent = JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result); // TO DO: Convert JSON to csv |
|
|
|
//var responseContent = JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |