|
|
|
|
@ -10,8 +10,6 @@ import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
import 'package:mc_common_app/config/dependencies.dart';
|
|
|
|
|
import 'package:mc_common_app/models/general_models/m_response.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:mc_common_app/models/provider_branches_models/profile/branch.dart';
|
|
|
|
|
import 'package:mc_common_app/models/provider_branches_models/profile/categroy.dart';
|
|
|
|
|
@ -20,9 +18,18 @@ import 'package:mc_common_app/models/provider_branches_models/profile/services.d
|
|
|
|
|
import 'package:mc_common_app/models/provider_branches_models/provider_model.dart';
|
|
|
|
|
|
|
|
|
|
abstract class BranchRepo {
|
|
|
|
|
Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> updateBranch(int id, String branchName, String branchDescription, String cityId, String address, String latitude, String longitude, {bool isNeedToDelete = true});
|
|
|
|
|
Future<MResponse> createBranch(String branchName, String branchDescription,
|
|
|
|
|
String cityId, String address, String latitude, String longitude);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> updateBranch(
|
|
|
|
|
int id,
|
|
|
|
|
String branchName,
|
|
|
|
|
String branchDescription,
|
|
|
|
|
String cityId,
|
|
|
|
|
String address,
|
|
|
|
|
String latitude,
|
|
|
|
|
String longitude,
|
|
|
|
|
{bool isNeedToDelete = true});
|
|
|
|
|
|
|
|
|
|
Future<Branch> fetchAllBranches();
|
|
|
|
|
|
|
|
|
|
@ -30,11 +37,14 @@ abstract class BranchRepo {
|
|
|
|
|
|
|
|
|
|
Future<Services> fetchServicesByCategoryId(String serviceCategoryId);
|
|
|
|
|
|
|
|
|
|
Future<Services> fetchProviderServices(String branchID, String serviceCategoryId);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> createNewService(List<Map<String, dynamic>> map);
|
|
|
|
|
|
|
|
|
|
Future<Document> getServiceProviderDocument(dynamic userId);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> serviceProviderDocumentsUpdate(List<DocumentData>? documents);
|
|
|
|
|
Future<MResponse> serviceProviderDocumentsUpdate(
|
|
|
|
|
List<DocumentData>? documents);
|
|
|
|
|
|
|
|
|
|
Future<ProviderModel> getBranchAndServices();
|
|
|
|
|
|
|
|
|
|
@ -42,7 +52,8 @@ abstract class BranchRepo {
|
|
|
|
|
|
|
|
|
|
Future<MResponse> updateService(List<Map<String, dynamic>> map);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> getMatchedServices(int oldBranchId, int newBranchId, int categoryId);
|
|
|
|
|
Future<MResponse> getMatchedServices(
|
|
|
|
|
int oldBranchId, int newBranchId, int categoryId);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> duplicateItems(Map<String, dynamic> map);
|
|
|
|
|
|
|
|
|
|
@ -53,11 +64,14 @@ abstract class BranchRepo {
|
|
|
|
|
Future<MResponse> assignDealerToBranch(Map<String, dynamic> map);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> removeDealerFromBranch(Map<String, dynamic> map);
|
|
|
|
|
|
|
|
|
|
Future<MResponse> addNewServicesInAppointment(Map<String, dynamic> map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class BranchRepoImp implements BranchRepo {
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
|
|
|
|
|
Future<MResponse> createBranch(String branchName, String branchDescription,
|
|
|
|
|
String cityId, String address, String latitude, String longitude) async {
|
|
|
|
|
var postParams = {
|
|
|
|
|
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
|
|
|
|
|
"branchName": branchName,
|
|
|
|
|
@ -70,23 +84,37 @@ class BranchRepoImp implements BranchRepo {
|
|
|
|
|
};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
debugPrint("token " + t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.createProviderBranch,
|
|
|
|
|
postParams,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<Branch> fetchAllBranches() async {
|
|
|
|
|
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
|
|
|
|
var postParams = {
|
|
|
|
|
"ServiceProviderID":
|
|
|
|
|
AppState().getUser.data?.userInfo?.providerId.toString() ?? ""
|
|
|
|
|
};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
debugPrint("token " + t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject((json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet, queryParameters: postParams, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet,
|
|
|
|
|
queryParameters: postParams, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<Category> fetchBranchCategory() async {
|
|
|
|
|
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
|
|
|
|
var postParams = {
|
|
|
|
|
"ServiceProviderID":
|
|
|
|
|
AppState().getUser.data?.userInfo?.providerId.toString() ?? ""
|
|
|
|
|
};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
debugPrint("token " + t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject((json) => Category.fromJson(json), ApiConsts.ServiceCategory_Get, queryParameters: postParams, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => Category.fromJson(json), ApiConsts.ServiceCategory_Get,
|
|
|
|
|
queryParameters: postParams, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -94,13 +122,19 @@ class BranchRepoImp implements BranchRepo {
|
|
|
|
|
var postParams = {"ServiceCategoryID": serviceCategoryId};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
debugPrint("token " + t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject((json) => Services.fromJson(json), ApiConsts.Services_Get, queryParameters: postParams, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => Services.fromJson(json), ApiConsts.Services_Get,
|
|
|
|
|
queryParameters: postParams, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> createNewService(List<Map<String, dynamic>> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderService_Create, map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.ServiceProviderService_Create,
|
|
|
|
|
map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -110,13 +144,15 @@ class BranchRepoImp implements BranchRepo {
|
|
|
|
|
};
|
|
|
|
|
String? token = AppState().getUser.data?.accessToken;
|
|
|
|
|
debugPrint(token);
|
|
|
|
|
return await injector
|
|
|
|
|
.get<ApiClient>()
|
|
|
|
|
.getJsonForObject((json) => Document.fromJson(json), ApiConsts.GetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => Document.fromJson(json), ApiConsts.GetProviderDocument,
|
|
|
|
|
queryParameters: queryParameters,
|
|
|
|
|
token: AppState().getUser.data!.accessToken ?? "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> serviceProviderDocumentsUpdate(List<DocumentData>? documents) async {
|
|
|
|
|
Future<MResponse> serviceProviderDocumentsUpdate(
|
|
|
|
|
List<DocumentData>? documents) async {
|
|
|
|
|
List<Map<String, dynamic>> map = [];
|
|
|
|
|
for (int i = 0; i < documents!.length; i++) {
|
|
|
|
|
if (documents[i].document != null) {
|
|
|
|
|
@ -133,19 +169,36 @@ class BranchRepoImp implements BranchRepo {
|
|
|
|
|
}
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
debugPrint("token " + t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderDocument_Update, map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.ServiceProviderDocument_Update,
|
|
|
|
|
map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<ProviderModel> getBranchAndServices() async {
|
|
|
|
|
var postParams = {"serviceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
|
|
|
|
var postParams = {
|
|
|
|
|
"serviceProviderID":
|
|
|
|
|
AppState().getUser.data?.userInfo?.providerId.toString() ?? ""
|
|
|
|
|
};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
print("tokeen121 " + t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject((json) => ProviderModel.fromJson(json), ApiConsts.BranchesAndServices, queryParameters: postParams, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => ProviderModel.fromJson(json), ApiConsts.BranchesAndServices,
|
|
|
|
|
queryParameters: postParams, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> updateBranch(int id, String branchName, String branchDescription, String cityId, String address, String latitude, String longitude, {bool isNeedToDelete = true}) async {
|
|
|
|
|
Future<MResponse> updateBranch(
|
|
|
|
|
int id,
|
|
|
|
|
String branchName,
|
|
|
|
|
String branchDescription,
|
|
|
|
|
String cityId,
|
|
|
|
|
String address,
|
|
|
|
|
String latitude,
|
|
|
|
|
String longitude,
|
|
|
|
|
{bool isNeedToDelete = true}) async {
|
|
|
|
|
String lat = "0", long = "0";
|
|
|
|
|
try {
|
|
|
|
|
lat = latitude.substring(0, 9);
|
|
|
|
|
@ -163,59 +216,109 @@ class BranchRepoImp implements BranchRepo {
|
|
|
|
|
"isActive": isNeedToDelete
|
|
|
|
|
};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.updateProviderBranch, postParams, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.updateProviderBranch,
|
|
|
|
|
postParams,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> createService(List<Map<String, dynamic>> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderService_Create, map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.ServiceProviderService_Create,
|
|
|
|
|
map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> updateService(List<Map<String, dynamic>> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderService_Update, map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.ServiceProviderService_Update,
|
|
|
|
|
map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> getMatchedServices(int oldBranchId, int newBranchId, int categoryId) async {
|
|
|
|
|
Future<MResponse> getMatchedServices(
|
|
|
|
|
int oldBranchId, int newBranchId, int categoryId) async {
|
|
|
|
|
var postParams = {
|
|
|
|
|
"ProviderBranchIDExisted": oldBranchId.toString(),
|
|
|
|
|
"ProviderBranchIDNew": newBranchId.toString(),
|
|
|
|
|
"CategoryID": categoryId.toString(),
|
|
|
|
|
};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject((json) => MResponse.fromJson(json), ApiConsts.getMatchedServices, queryParameters: postParams, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json), ApiConsts.getMatchedServices,
|
|
|
|
|
queryParameters: postParams, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> duplicateItems(Map<String, dynamic> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.duplicateItems, map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json), ApiConsts.duplicateItems, map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> getAllProviderDealers(Map<String, dynamic> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject((json) => MResponse.fromJson(json), ApiConsts.getAllProviderDealers, queryParameters: map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json), ApiConsts.getAllProviderDealers,
|
|
|
|
|
queryParameters: map, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> getBranchUsers(Map<String, dynamic> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject((json) => MResponse.fromJson(json), ApiConsts.getBranchUser, queryParameters: map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json), ApiConsts.getBranchUser,
|
|
|
|
|
queryParameters: map, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> assignDealerToBranch(Map<String, dynamic> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.assignDealerToBranch, map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json), ApiConsts.assignDealerToBranch, map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> removeDealerFromBranch(Map<String, dynamic> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.removeDealerFromBranch, map, token: t);
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.removeDealerFromBranch,
|
|
|
|
|
map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<Services> fetchProviderServices(String branchID, String serviceCategoryId) async {
|
|
|
|
|
var postParams = {
|
|
|
|
|
"ServiceCategoryID": serviceCategoryId,
|
|
|
|
|
"ProviderBranchID": branchID,
|
|
|
|
|
};
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
debugPrint("token " + t);
|
|
|
|
|
return await injector.get<ApiClient>().getJsonForObject(
|
|
|
|
|
(json) => Services.fromJson(json), ApiConsts.GetProviderServices,
|
|
|
|
|
queryParameters: postParams, token: t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<MResponse> addNewServicesInAppointment(Map<String, dynamic> map) async {
|
|
|
|
|
String t = AppState().getUser.data!.accessToken ?? "";
|
|
|
|
|
return await injector.get<ApiClient>().postJsonForObject(
|
|
|
|
|
(json) => MResponse.fromJson(json),
|
|
|
|
|
ApiConsts.AddNewServicesInAppointment,
|
|
|
|
|
map,
|
|
|
|
|
token: t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|