| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using BlackRockReportFunction.Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
-
- namespace BlackRockReportFunction.Bussines
- {
- public class ClockifyReports
- {
-
- static HttpClient client = new HttpClient();
-
-
- static void InitializeClockifyIntegration()
- {
- client.BaseAddress = new Uri("https://reports.api.clockify.me/v1");
-
- client.DefaultRequestHeaders.Accept.Clear();
-
- client.DefaultRequestHeaders.Accept
- .Add(new MediaTypeWithQualityHeaderValue("application/json"));
- }
-
- static async Task<Uri> CreateClockifyReport(ClockifyReport clockifyReport)
- {
- HttpResponseMessage httpResponseMessage = await client
- .PostAsJsonAsync("api/clockifyreport", clockifyReport);
-
- httpResponseMessage.EnsureSuccessStatusCode();
-
- return httpResponseMessage.Headers.Location;
- }
-
- static async Task<ClockifyReport> GetClockifyReportAsync(string path)
- {
- ClockifyReport clockifyReport = null;
- HttpResponseMessage httpResponseMessage= await client.GetAsync(path);
-
- if (httpResponseMessage.IsSuccessStatusCode)
- {
- clockifyReport = await httpResponseMessage.Content.ReadAsAsync<ClockifyReport>();
- }
-
- return clockifyReport;
- }
- }
- }
|