|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacy/brands_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacy/final_products_model.dart';
|
|
|
|
|
@ -22,20 +23,20 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
List<CategoriseParentModel> get parentCategoriseList => _parentCategoriseList;
|
|
|
|
|
|
|
|
|
|
//service three
|
|
|
|
|
List<ParentProductsModel> _parentProductsList = List();
|
|
|
|
|
List<ParentProductsModel> get parentProductsList => _parentProductsList;
|
|
|
|
|
List<PharmacyProduct> _parentProductsList = List();
|
|
|
|
|
List<PharmacyProduct> get parentProductsList => _parentProductsList;
|
|
|
|
|
|
|
|
|
|
//service four
|
|
|
|
|
List<SubCategoriesModel> _subCategoriseList = List();
|
|
|
|
|
List<SubCategoriesModel> get subCategoriseList => _subCategoriseList;
|
|
|
|
|
|
|
|
|
|
//service five
|
|
|
|
|
List<SubProductsModel> _subProductsList = List();
|
|
|
|
|
List<SubProductsModel> get subProductsList => _subProductsList;
|
|
|
|
|
List<PharmacyProduct> _subProductsList = List();
|
|
|
|
|
List<PharmacyProduct> get subProductsList => _subProductsList;
|
|
|
|
|
|
|
|
|
|
//service six
|
|
|
|
|
List<FinalProductsModel> _finalProducts = List();
|
|
|
|
|
List<FinalProductsModel> get finalProducts => _finalProducts;
|
|
|
|
|
List<PharmacyProduct> _finalProducts = List();
|
|
|
|
|
List<PharmacyProduct> get finalProducts => _finalProducts;
|
|
|
|
|
|
|
|
|
|
//service 7
|
|
|
|
|
|
|
|
|
|
@ -44,8 +45,8 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
|
|
|
|
|
// service 8
|
|
|
|
|
|
|
|
|
|
List<SearchProductsModel> _searchList = List();
|
|
|
|
|
List<SearchProductsModel> get searchList => _searchList;
|
|
|
|
|
List<PharmacyProduct> _searchList = List();
|
|
|
|
|
List<PharmacyProduct> get searchList => _searchList;
|
|
|
|
|
|
|
|
|
|
List<ScanQrModel> _scanList = List();
|
|
|
|
|
List<ScanQrModel> get scanList => _scanList;
|
|
|
|
|
@ -101,7 +102,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
endPoint,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_searchList.add(SearchProductsModel.fromJson(item));
|
|
|
|
|
_searchList.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onFailure: (String error, int statusCode) {
|
|
|
|
|
@ -157,7 +158,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
endPoint,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_parentProductsList.add(ParentProductsModel.fromJson(item));
|
|
|
|
|
_parentProductsList.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onFailure: (String error, int statusCode) {
|
|
|
|
|
@ -197,7 +198,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
endPoint,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_subProductsList.add(SubProductsModel.fromJson(item));
|
|
|
|
|
_subProductsList.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onFailure: (String error, int statusCode) {
|
|
|
|
|
@ -216,7 +217,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
endPoint,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_finalProducts.add(FinalProductsModel.fromJson(item));
|
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onFailure: (String error, int statusCode) {
|
|
|
|
|
@ -235,25 +236,30 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
GET_BRAND_ITEMS,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_finalProducts.add(FinalProductsModel.fromJson(item));
|
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, queryParams: queryParams,
|
|
|
|
|
},
|
|
|
|
|
queryParams: queryParams,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getLastVisitedProducts() async {
|
|
|
|
|
String lastVisited = "";
|
|
|
|
|
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) {
|
|
|
|
|
lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
|
|
|
|
|
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) !=
|
|
|
|
|
null) {
|
|
|
|
|
lastVisited =
|
|
|
|
|
await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient
|
|
|
|
|
.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited",
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_finalProducts.clear();
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_finalProducts.add(FinalProductsModel.fromJson(item));
|
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
@ -268,13 +274,14 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
Future getBestSellerProducts() async {
|
|
|
|
|
Map<String, String> queryParams = {
|
|
|
|
|
'fields':
|
|
|
|
|
'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews',
|
|
|
|
|
'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews',
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_finalProducts.clear();
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_finalProducts.add(FinalProductsModel.fromJson(item));
|
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
|