namespace SharepointToolbox.Core.Models;
///
/// Discriminated result type for app registration operations.
/// Use the static factory methods to construct instances.
///
public class AppRegistrationResult
{
public bool IsSuccess { get; }
public bool IsFallback { get; }
public string? AppId { get; }
public string? ErrorMessage { get; }
private AppRegistrationResult(bool isSuccess, bool isFallback, string? appId, string? errorMessage)
{
IsSuccess = isSuccess;
IsFallback = isFallback;
AppId = appId;
ErrorMessage = errorMessage;
}
/// Registration succeeded; carries the newly-created appId.
public static AppRegistrationResult Success(string appId) =>
new(isSuccess: true, isFallback: false, appId: appId, errorMessage: null);
/// Registration failed; carries an error message.
public static AppRegistrationResult Failure(string errorMessage) =>
new(isSuccess: false, isFallback: false, appId: null, errorMessage: errorMessage);
/// User lacks the required permissions — caller should show fallback instructions.
public static AppRegistrationResult FallbackRequired() =>
new(isSuccess: false, isFallback: true, appId: null, errorMessage: null);
}