import 'package:taafee_mobile/core/apis/apis.dart';
import 'package:taafee_mobile/core/network/http.dart';
import 'package:taafee_mobile/features/card/data_layer/model/card_model.dart';
import 'package:taafee_mobile/features/home/data_layer/model/city.dart';
import 'package:taafee_mobile/features/home/data_layer/model/search.dart';

class HomeService {
  Future<List<CityModel>> getCities({String? value}) async {
    Request request = Request(
      EndPoint.city,
      RequestMethod.get,
      authorized: true,
      queryParams: {
        if (value != null) "nameAndCountry": value,
      },
    );
    Map<String, dynamic> response = await request.sendRequest();
    return CityModel.fromJsonList(response);
  }

  /// ------------------------search----------------------------------///
  Future<List<CardModel>> searchCards(SearchModel searchModel) async {
    Request request = Request(EndPoint.search, RequestMethod.get,
        queryParams: searchModel.toJson(), authorized: true);
    Map<String, dynamic> response = await request.sendRequest();
    return CardModel.fromJsonList(response);
  }
}
