import 'package:shared_preferences/shared_preferences.dart';

import '../../../Helper/Constants/Apiconstants.dart';
import '../../../Model/Response/Customers/GetCustomerById/GetCustomerByTenantId.dart';
import '../../../Model/Response/Customers/GetCustomerById/Getdropcustomerbytenantid.dart';
import '../../Provider/Customers/getCustomerbytenantidprovider.dart';


class GetCustomersByTenantIdRepository{
  GetCustomersByTenantIdProvider getCustomersByTenantIdProvider = GetCustomersByTenantIdProvider();
  int? tenantId;

  Future<GetCustomerByTenantId?> getCustomerByTenantId() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getCustomerByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&pageno=1&pagesize=20');
    return result;
  }

  Future<GetCustomerByTenantId?> getCustomerKeywordByTenantId(keyword) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getCustomerByTenantId('${ApiConstants.getCustomerSearchByTenantId}/?tenantid=$tenantId&keyword=$keyword');
    return result;
  }

  Future<GetCustomerByTenantId?> getTenantsByTenantId() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getTenantsByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&locationid=1');
    return result;
  }

  Future<GetCustomerByTenantId?> getCustomerByPageLimitTenantId(page,limit) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getTenantsByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&pageno=$page&pagesize=$limit');
    return result;
  }


  Future<GetDropCustomerByTenantId?> getDropCustomerByTenantId() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getDropCustomerByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId');
    return result;
  }

  Future<GetDropCustomerByTenantId?> getDropCustomerKeywordByTenantId(keyword) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getDropCustomerByTenantId('${ApiConstants.getCustomerSearchByTenantId}/?tenantid=$tenantId&keyword=$keyword');
    return result;
  }

  Future<GetDropCustomerByTenantId?> getDropCustomerByPageLimitTenantId(page,limit) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getDropCustomerByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&pageno=$page&pagesize=$limit');
    return result;
  }



  Future<GetDropCustomerByTenantId?> getDropTenantByTenantId() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    tenantId = prefs.getInt('tenantId');
    var result = await getCustomersByTenantIdProvider.getDropTenantByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&locationid=1');
    return result;
  }




}
