import '../models/company_model.dart';
import '../models/work_status_model.dart';
import '../models/work_supervisor_model.dart';

import '../app/constant.dart';
import '../models/work_type_model.dart';
import 'base_repository.dart';

class CompanyRepository extends BaseRepository {
  CompanyRepository({required super.dio});

  Future<List<CompanyModel>> search({required String keyword}) async {
    // http: //10.9.9.3/one-api/v1/courier/mobile/inputcourier/search_company_all/?search=sas
    final url = Constant.baseUrl +
        "/v1/courier/mobile/inputcourier/search_company_all/?search=$keyword";
    final resp = await get(service: url);
    List<CompanyModel> data;
    // print(resp['data']);
    if (resp['status'] == 'OK') {
      data = [];
      if (resp['data'] != null) {
        resp['data']['records'].forEach((e) {
          final model = CompanyModel.fromJson(e);
          data.add(model);
        });
      } else {
        data = [];
      }
    } else {
      data = [];
    }

    return data;
  }
}
