/// Use Case: Get User Info
///
/// Retrieves the current authenticated user's information.
/// This use case encapsulates the business logic for fetching user info.
library;

import 'package:worker/features/account/domain/entities/user_info.dart';
import 'package:worker/features/account/domain/repositories/user_info_repository.dart';

/// Get User Info Use Case
///
/// Fetches the current authenticated user's information from the API.
///
/// Usage:
/// ```dart
/// final getUserInfo = GetUserInfo(repository);
/// final userInfo = await getUserInfo();
/// ```
///
/// This use case:
/// - Retrieves user info from repository
/// - Can add business logic if needed (e.g., validation, analytics)
/// - Returns UserInfo entity
class GetUserInfo {
  /// User info repository instance
  final UserInfoRepository repository;

  /// Constructor
  const GetUserInfo(this.repository);

  /// Execute the use case
  ///
  /// Returns [UserInfo] with user's account information.
  ///
  /// Throws:
  /// - [UnauthorizedException] if user not authenticated
  /// - [NetworkException] if network error occurs
  /// - [ServerException] if server error occurs
  Future<UserInfo> call() async {
    // TODO: Add business logic here if needed
    // For example:
    // - Log analytics event
    // - Validate user session
    // - Transform data if needed
    // - Check feature flags

    return await repository.getUserInfo();
  }

  /// Execute with force refresh
  ///
  /// Forces a refresh from the server instead of using cached data.
  ///
  /// Use this when:
  /// - User explicitly pulls to refresh
  /// - After profile updates
  /// - After points redemption
  /// - When fresh data is critical
  Future<UserInfo> refresh() async {
    return await repository.refreshUserInfo();
  }
}
