Untis API Integration
This commit is contained in:
@@ -9,8 +9,12 @@ internal class WebUntisSettingsConfig
|
||||
public string? EncryptedIcalUrl { get; set; }
|
||||
public DateTime? LastSyncAt { get; set; }
|
||||
public string LastSyncStatus { get; set; } = "";
|
||||
public string? EncryptedApiCredentials { get; set; }
|
||||
public int? TeacherUntisId { get; set; }
|
||||
}
|
||||
|
||||
public sealed record WebUntisCredentials(string School, string Host, string Username, string Password);
|
||||
|
||||
/// <summary>
|
||||
/// Einstellungen für den WebUntis-iCal-Abgleich (Nutzer-Feedback, siehe TODO.md). Liegt wie
|
||||
/// AiSettingsService/SyncSettingsService in LehrerApp.Desktop statt LehrerApp.Core, da die
|
||||
@@ -30,6 +34,8 @@ public class WebUntisSettingsService
|
||||
|
||||
public bool Enabled => _config.Enabled;
|
||||
public bool IsConfigured => _config.EncryptedIcalUrl is not null;
|
||||
public bool ApiIsConfigured => _config.EncryptedApiCredentials is not null;
|
||||
public int? TeacherUntisId => _config.TeacherUntisId;
|
||||
public DateTime? LastSyncAt => _config.LastSyncAt;
|
||||
public string LastSyncStatus => _config.LastSyncStatus;
|
||||
|
||||
@@ -63,6 +69,29 @@ public class WebUntisSettingsService
|
||||
Save();
|
||||
}
|
||||
|
||||
public void SetApiCredentials(WebUntisCredentials credentials)
|
||||
{
|
||||
_config.EncryptedApiCredentials = SyncCrypto.EncryptObject(credentials, _urlKey);
|
||||
Save();
|
||||
}
|
||||
|
||||
public WebUntisCredentials? GetApiCredentials() => _config.EncryptedApiCredentials is null
|
||||
? null
|
||||
: SyncCrypto.DecryptObject<WebUntisCredentials>(_config.EncryptedApiCredentials, _urlKey);
|
||||
|
||||
public void ClearApiCredentials()
|
||||
{
|
||||
_config.EncryptedApiCredentials = null;
|
||||
_config.TeacherUntisId = null;
|
||||
Save();
|
||||
}
|
||||
|
||||
public void SetTeacherUntisId(int? teacherUntisId)
|
||||
{
|
||||
_config.TeacherUntisId = teacherUntisId;
|
||||
Save();
|
||||
}
|
||||
|
||||
public void SetLastSync(DateTime at, string status)
|
||||
{
|
||||
_config.LastSyncAt = at;
|
||||
|
||||
Reference in New Issue
Block a user