import 'package:taafee_mobile/core/apis/apis.dart';
import 'package:taafee_mobile/core/network/http.dart';
import 'package:taafee_mobile/features/category/data_layer/model/category.dart';

class CategoryService {
  Future<List<CategoryModel>> getCategories(
      {String? value, void Function(Object)? onConnectionError}) async {
    Request request = Request(
      EndPoint.category,
      RequestMethod.get,
      authorized: true,
      cacheable: true,
      queryParams: {
        if (value != null) "name": value,
      },
    );
    Map<String, dynamic> response =
        await request.sendRequest(onConnectionError: onConnectionError);

    return CategoryModel.fromJsonList(response);
  }
}
