import 'package:ticket_booth/app/constant.dart';
import 'package:ticket_booth/model/booth.dart';
import 'package:ticket_booth/model/branch_model.dart';
import 'package:ticket_booth/repository/base_repository.dart';

class BoothRepository extends BaseRepository {
  BoothRepository({required super.dio});
  Future<List<Booth>> getData({required String hostIP}) async {
    final url =
        "$hostIP/one-api/mockup/masterdata/one-md-ticket-dispenser/ticketbooth/index";
    print(url);
    // final url = "$hostIP/one-api/training/ticketbooth/index";
    final resp = await getBooth(service: url);
    final List<Booth> listBooth = List.empty(growable: true);
    resp['data']['records'].forEach((e) {
      final model = Booth.fromJson(e);
      listBooth.add(model);
    });
    return listBooth;
  }

  Future<List<BranchModel>> getBranch({required String hostIP}) async {
    // https://devcpone.aplikasi.web.id/one-api/mockup/fo/antrian/AntrianByStationAndLocation/getbranch
    final url =
        "$hostIP/one-api/mockup/fo/antrian/AntrianByStationAndLocation/getbranch";
    print(url);
    // final url = "$hostIP/one-api/training/ticketbooth/index";
    final resp = await getBooth(service: url);
    final List<BranchModel> listBooth = List.empty(growable: true);
    resp['data']['records'].forEach((e) {
      final model = BranchModel.fromJson(e);
      listBooth.add(model);
    });
    return listBooth;
  }
}
