You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.8 KiB
57 lines
1.8 KiB
2 years ago
|
import 'package:dio/dio.dart';
|
||
|
|
||
|
import '../app/constants.dart';
|
||
|
import '../model/ac_company_response_model.dart';
|
||
|
import '../model/ac_mou_response_model.dart';
|
||
|
import '../model/mitra_response_model.dart';
|
||
|
import 'base_repository.dart';
|
||
|
|
||
|
class MitraRepository extends BaseRepository {
|
||
|
MitraRepository({required super.dio});
|
||
|
Future<List<MitraResponseModel>> search({
|
||
|
required String query,
|
||
|
CancelToken? cancelToken,
|
||
|
}) async {
|
||
|
final param = {"query": query};
|
||
|
final service = "${Constants.baseUrl}md/search";
|
||
|
final resp = await post(
|
||
|
service: service, jsonParam: param, cancelToken: cancelToken);
|
||
|
final List<MitraResponseModel> result = List.empty(growable: true);
|
||
|
for (final el in resp["data"]) {
|
||
|
final model = MitraResponseModel.fromJson(el);
|
||
|
result.add(model);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
Future<List<AcCompanyModel>> lookupCompany({
|
||
|
required String query,
|
||
|
CancelToken? cancelToken,
|
||
|
}) async {
|
||
|
final param = {"query": query};
|
||
|
final service = "${Constants.baseUrl}md/lookup_company";
|
||
|
final resp = await post(
|
||
|
service: service, jsonParam: param, cancelToken: cancelToken);
|
||
|
final List<AcCompanyModel> result = List.empty(growable: true);
|
||
|
for (final el in resp["data"]) {
|
||
|
final model = AcCompanyModel.fromJson(el);
|
||
|
result.add(model);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
Future<List<AcMouResponseModel>> lookupMou({
|
||
|
required String companyID,
|
||
|
CancelToken? cancelToken,
|
||
|
}) async {
|
||
|
final service = "${Constants.baseUrl}md/lookup_mou/$companyID";
|
||
|
final resp = await get(service: service, cancelToken: cancelToken);
|
||
|
final List<AcMouResponseModel> result = List.empty(growable: true);
|
||
|
for (final el in resp["data"]) {
|
||
|
final model = AcMouResponseModel.fromJson(el);
|
||
|
result.add(model);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
}
|