/// Use Case: Get Member Card /// /// Retrieves the current user's member card information. /// This use case encapsulates the business logic for fetching member card data. /// /// Follows the Single Responsibility Principle - one use case, one operation. library; import 'package:worker/features/home/domain/entities/member_card.dart'; import 'package:worker/features/home/domain/repositories/home_repository.dart'; /// Get Member Card Use Case /// /// Fetches the current authenticated user's member card. /// /// Usage: /// ```dart /// final memberCard = await getMemberCard(); /// ``` /// /// This use case: /// - Retrieves member card from repository (which handles caching) /// - Can add business logic if needed (e.g., validation, transformation) /// - Returns MemberCard entity class GetMemberCard { /// Home repository instance final HomeRepository repository; /// Constructor const GetMemberCard(this.repository); /// Execute the use case /// /// Returns [MemberCard] with user's membership information. /// /// Throws: /// - [UnauthorizedException] if user not authenticated /// - [NetworkException] if network error occurs /// - [CacheException] if local data corrupted Future call() async { // TODO: Add business logic here if needed // For example: // - Validate user authentication // - Check if card is expired and handle accordingly // - Transform data if needed // - Log analytics events return await repository.getMemberCard(); } /// Execute with force refresh /// /// Forces a refresh from the server instead of using cached data. /// /// Use this when: /// - User explicitly pulls to refresh /// - Cached data is known to be stale /// - After points redemption or other updates Future refresh() async { return await repository.refreshMemberCard(); } }