fix keyboard catch, fix loading

refactoring
This commit is contained in:
Alex Bezdieniezhnykh
2024-11-25 13:03:46 +02:00
parent b61bed3b51
commit 30b9b9aa80
18 changed files with 88 additions and 117 deletions
+6 -6
View File
@@ -17,13 +17,13 @@ public class AzaionApiClient(HttpClient httpClient) : IDisposable
private SecureString Password { get; set; } = new();
private string JwtToken { get; set; } = null!;
public void Login(string email, string password)
public void EnterCredentials(ApiCredentials credentials)
{
if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
if (string.IsNullOrWhiteSpace(credentials.Email) || string.IsNullOrWhiteSpace(credentials.Password))
throw new Exception("Email or password is empty!");
Email = email;
Password = password.ToSecureString();
Email = credentials.Email;
Password = credentials.Password.ToSecureString();
}
public async Task<Stream> GetResource(string fileName, string password, HardwareInfo hardware)
@@ -38,7 +38,7 @@ public class AzaionApiClient(HttpClient httpClient) : IDisposable
private async Task<string> Authorize()
{
if (string.IsNullOrEmpty(Email) || Password.Length == 0)
throw new Exception("Email or password is empty! Please do Login first!");
throw new Exception("Email or password is empty! Please do EnterCredentials first!");
var payload = new
{
@@ -50,7 +50,7 @@ public class AzaionApiClient(HttpClient httpClient) : IDisposable
new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, JSON_MEDIA));
if (!response.IsSuccessStatusCode)
throw new Exception($"Login failed: {response.StatusCode}");
throw new Exception($"EnterCredentials failed: {response.StatusCode}");
var responseData = await response.Content.ReadAsStringAsync();