import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import 'package:superport/core/errors/failures.dart';
import 'package:superport/domain/usecases/base_usecase.dart';
import 'package:superport/data/models/lookups/lookup_data.dart';
import 'package:superport/domain/repositories/lookups_repository.dart';

/// 타입별 Lookups 조회 UseCase
@injectable
class GetLookupsByTypeUseCase
    implements UseCase<LookupData, GetLookupsByTypeParams> {
  final LookupsRepository _repository;

  GetLookupsByTypeUseCase(this._repository);

  @override
  Future<Either<Failure, LookupData>> call(
    GetLookupsByTypeParams params,
  ) async {
    return await _repository.getLookupsByType(params.type);
  }
}

/// GetLookupsByType UseCase 파라미터
class GetLookupsByTypeParams {
  final String type;

  const GetLookupsByTypeParams({required this.type});

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is GetLookupsByTypeParams &&
          runtimeType == other.runtimeType &&
          type == other.type;

  @override
  int get hashCode => type.hashCode;

  @override
  String toString() => 'GetLookupsByTypeParams(type: $type)';
}
