import 'package:dio/dio.dart';
import 'package:fpdart/fpdart.dart';
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
import 'package:grocery_app/src/core/utils/response_type_def.dart';
import 'package:grocery_app/src/data/check_product.dart';
import 'package:grocery_app/src/data/myOrder.dart';
import 'package:grocery_app/src/data/order_OTP.dart';
import 'package:grocery_app/src/data/order_paymnet.dart';
import 'package:grocery_app/src/logic/services/orderSirvice.dart';

class OrderRepo {
  final OrderService _orderService;
  OrderRepo(this._orderService);

  FutureResult<MyOrder> myOrder(data) async {
    try {
      var response = await _orderService.myOrder(data);

      MyOrder productCategory = myOrderFromJson(response.toString());
      print("ldkjglfdhglkj  ${productCategory}");

      return right(productCategory);
    } on DioException catch (e) {
      var error = CustomDioExceptions.handleError(e);
      return left(error);
    }
  }
 


  

   FutureResult<DeliveryOtpmodel> getAssignedOtp(data) async {
    try {
      var response = await _orderService.getAssignedOtp(data);

      DeliveryOtpmodel storeModel =
          deliveryOtpmodelFromJson(response.toString());

      //final String model = response.toString();
      return right(storeModel);
    } on DioException catch (e) {
      var error = CustomDioExceptions.handleError(e);
      return left(error);
    }
  }

  FutureResult<String> updateStatus(data, orderItemId) async {
    try {
      var response = await _orderService.updateStatus(data, orderItemId);

      final String model = response.toString();
      return right(model);
    } on DioException catch (e) {
      var error = CustomDioExceptions.handleError(e);
      return left(error);
    }
  }



}
