import 'dart:convert';

import 'package:queuedisplay/model/branch_model.dart';
import 'package:queuedisplay/model/counter_model.dart';

import '../app/constant.dart';

import 'base_repository.dart';

class CounterRepository extends BaseRepository {
  CounterRepository({required super.dio});
  Future<List<Counter>> getData() async {
    final url =
        "${Constant.baseUrl}antrian/AntrianCounterDedicated/list_counter";
    final resp = await getService(service: url);
    // print(resp);

    final List<Counter> listCounter = List.empty(growable: true);

    resp['data']['records'].forEach((e) {
      final model = Counter.fromJson(e);
      listCounter.add(model);
    });

    return listCounter;
  }

  Future<List<BranchModel>> getBranch() async {
    // https://devcpone.aplikasi.web.id/one-api/mockup/fo/antrian/AntrianByStationAndLocation/getbranch
    final url =
        "${Constant.baseUrl}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;
  }
}
