using System;
using System.Collections.Generic;
using System.Text.Json.Nodes;
namespace DysonNetwork.Common.Models;
///
/// Represents user information from an OIDC provider
///
public class OidcUserInfo
{
///
/// The unique identifier for the user from the OIDC provider
///
public string? UserId { get; set; }
///
/// The user's email address
///
public string? Email { get; set; }
///
/// Whether the user's email has been verified by the OIDC provider
///
public bool EmailVerified { get; set; }
///
/// The user's given name (first name)
///
public string? GivenName { get; set; }
///
/// The user's family name (last name)
///
public string? FamilyName { get; set; }
///
/// The user's full name
///
public string? Name { get; set; }
///
/// The user's preferred username
///
public string? PreferredUsername { get; set; }
///
/// URL to the user's profile picture
///
public string? Picture { get; set; }
///
/// The OIDC provider name (e.g., "google", "github")
///
public string? Provider { get; set; }
///
/// OAuth access token from the provider
///
public string? AccessToken { get; set; }
///
/// OAuth refresh token from the provider (if available)
///
public string? RefreshToken { get; set; }
///
/// When the access token expires (if available)
///
public DateTimeOffset? ExpiresAt { get; set; }
///
/// Additional claims from the ID token or user info endpoint
///
public Dictionary? Claims { get; set; }
///
/// Converts the user info to a metadata dictionary for storage
///
public Dictionary ToMetadata()
{
var metadata = new Dictionary();
if (!string.IsNullOrWhiteSpace(UserId))
metadata["user_id"] = UserId;
if (!string.IsNullOrWhiteSpace(Email))
metadata["email"] = Email;
metadata["email_verified"] = EmailVerified;
if (!string.IsNullOrWhiteSpace(GivenName))
metadata["given_name"] = GivenName;
if (!string.IsNullOrWhiteSpace(FamilyName))
metadata["family_name"] = FamilyName;
if (!string.IsNullOrWhiteSpace(Name))
metadata["name"] = Name;
if (!string.IsNullOrWhiteSpace(PreferredUsername))
metadata["preferred_username"] = PreferredUsername;
if (!string.IsNullOrWhiteSpace(Picture))
metadata["picture"] = Picture;
if (!string.IsNullOrWhiteSpace(Provider))
metadata["provider"] = Provider;
if (ExpiresAt.HasValue)
metadata["expires_at"] = ExpiresAt.Value;
return metadata;
}
}