

import 'package:shared_preferences/shared_preferences.dart';
import '../../../Helper/Constants/Apiconstants.dart';
import '../../../Model/Request/products/update_product.dart';
import '../../../Model/Response/products/product_info.dart';
import '../../../Model/Response/products/product_response.dart';
import '../../../Model/Response/products/product_update_response.dart';
import '../../Provider/Products_provider/get_products.dart';

class ProductsRepository {

  int? tenantId;
  int? locationId;

  int? categoryId;

  GetProductsProvider getProductsProvider = GetProductsProvider();

  Future<GetProducts?> getProducts({int? subCategoryId, String? keyword}) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    locationId = prefs.getInt('locationId');
    categoryId = prefs.getInt('categoryId');

    var result = await getProductsProvider.getProducts('https://fiesta.nearle.app/live/api/v1/mob/products/getlocationproducts?tenantid=${tenantId}&page=1&pagesize=40&locationid=$locationId');
    return result;
  }


  Future<ProductUpdateResponse?> productUpdate(ProductUpdateRequest data) async {
    var result = await getProductsProvider.updateProducts(data, 'https://fiesta.nearle.app/live/api/v1/mob/products/updateproductlocation');
    return result;
  }


  String productDetail = "https://fiesta.nearle.app/live/api/v1/mob/orders/getorderdetails";

  Future<ProductDetailResponse?> getProductDetail(int orderheaderid) async {
    var result = await getProductsProvider.getProductDetail('$productDetail?orderheaderid=$orderheaderid');
    return result;
  }



}