import 'package:boilerplate/data/models/product/get_product_list_req_model.dart';
import 'package:boilerplate/data/repositories/product_repository.dart';
import 'package:boilerplate/domain/entities/product/product_data.dart';
import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';

import '../../../core/di/injection_init.dart';
import '../../../core/utils/print_utils.dart';
import '../../../core/utils/shared_preferences_util.dart';
import '../../../data/models/app/failure.dart';

@injectable
class GetNewProductListUseCase {
  final ProductRepository _productRepo;

  GetNewProductListUseCase(this._productRepo);

  Future<Either<List<ProductData>, Failure>> execute(
      GetProductListReqModel req) async {
    print("req => ${req}");
    try {
      final data = await _productRepo.getNewProduct(req);
      print("productlist => ${data.result.data.length}");
      ;
      return Left(data.result.data);
    } catch (err) {
      print('GetProductListUseCase Error : $err');
      return Right(Failure(
        errMessage: '$err',
      ));
    }
  }
}
