using System.Net.Http.Json; using System.Text.Json; using System.Text.Json.Serialization; using MatrixRoomUtils.Authentication; namespace MatrixRoomUtils.Responses; public class LoginResponse { [JsonPropertyName("access_token")] public string AccessToken { get; set; } [JsonPropertyName("device_id")] public string DeviceId { get; set; } [JsonPropertyName("home_server")] public string HomeServer { get; set; } [JsonPropertyName("user_id")] public string UserId { get; set; } public async Task GetProfile() { var hc = new HttpClient(); var resp = await hc.GetAsync($"{HomeServer}/_matrix/client/r0/profile/{UserId}"); var data = await resp.Content.ReadFromJsonAsync(); if(!resp.IsSuccessStatusCode) Console.WriteLine("Profile: " + data.ToString()); return data.Deserialize(); } public async Task GetCanonicalHomeserverUrl() { return await MatrixAccount.ResolveHomeserverFromWellKnown(HomeServer); } }