|
|
|
@ -95,9 +95,8 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
Future searchProducts({String productName}) async {
|
|
|
|
Future searchProducts({String productName}) async {
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
_searchList.clear();
|
|
|
|
_searchList.clear();
|
|
|
|
String endPoint = productName != null
|
|
|
|
String endPoint =
|
|
|
|
? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1'
|
|
|
|
productName != null ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' : GET_SEARCH_PRODUCTS + "";
|
|
|
|
: GET_SEARCH_PRODUCTS + "";
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
endPoint,
|
|
|
|
endPoint,
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
@ -132,8 +131,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
Future getCategoriseParent({String id}) async {
|
|
|
|
Future getCategoriseParent({String id}) async {
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
_parentCategoriseList.clear();
|
|
|
|
_parentCategoriseList.clear();
|
|
|
|
String endPoint =
|
|
|
|
String endPoint = id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + "";
|
|
|
|
id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + "";
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
endPoint,
|
|
|
|
endPoint,
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
@ -151,9 +149,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
Future getParentProducts({String id}) async {
|
|
|
|
Future getParentProducts({String id}) async {
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
_parentProductsList.clear();
|
|
|
|
_parentProductsList.clear();
|
|
|
|
String endPoint = id != null
|
|
|
|
String endPoint = id != null ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' : GET_PARENT_PRODUCTS + "";
|
|
|
|
? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50'
|
|
|
|
|
|
|
|
: GET_PARENT_PRODUCTS + "";
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
endPoint,
|
|
|
|
endPoint,
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
@ -172,8 +168,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
_subCategoriseList.clear();
|
|
|
|
_subCategoriseList.clear();
|
|
|
|
|
|
|
|
|
|
|
|
String endPoint =
|
|
|
|
String endPoint = id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + "";
|
|
|
|
id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + "";
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
endPoint,
|
|
|
|
endPoint,
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
@ -191,9 +186,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
Future getSubProducts({String id}) async {
|
|
|
|
Future getSubProducts({String id}) async {
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
_subProductsList.clear();
|
|
|
|
_subProductsList.clear();
|
|
|
|
String endPoint = id != null
|
|
|
|
String endPoint = id != null ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' : GET_SUB_PRODUCTS + "";
|
|
|
|
? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50'
|
|
|
|
|
|
|
|
: GET_SUB_PRODUCTS + "";
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
endPoint,
|
|
|
|
endPoint,
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
@ -211,8 +204,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
Future getFinalProducts({String id}) async {
|
|
|
|
Future getFinalProducts({String id}) async {
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
_finalProducts.clear();
|
|
|
|
_finalProducts.clear();
|
|
|
|
String endPoint =
|
|
|
|
String endPoint = id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + "";
|
|
|
|
id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + "";
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
endPoint,
|
|
|
|
endPoint,
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
@ -249,14 +241,11 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
|
|
|
|
|
|
|
Future getLastVisitedProducts() async {
|
|
|
|
Future getLastVisitedProducts() async {
|
|
|
|
String lastVisited = "";
|
|
|
|
String lastVisited = "";
|
|
|
|
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) !=
|
|
|
|
if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) {
|
|
|
|
null) {
|
|
|
|
lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
|
|
|
|
lastVisited =
|
|
|
|
|
|
|
|
await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await baseAppClient
|
|
|
|
await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited",
|
|
|
|
.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited",
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
|
|
|
_finalProducts.clear();
|
|
|
|
_finalProducts.clear();
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
@ -277,8 +266,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
'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 {
|
|
|
|
try {
|
|
|
|
await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT,
|
|
|
|
await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
|
|
|
_finalProducts.clear();
|
|
|
|
_finalProducts.clear();
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
@ -292,8 +280,7 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future getFilteredProducts(
|
|
|
|
Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async {
|
|
|
|
{String categoryId, String brandId, String min, String max}) async {
|
|
|
|
|
|
|
|
hasError = false;
|
|
|
|
hasError = false;
|
|
|
|
String endPoint;
|
|
|
|
String endPoint;
|
|
|
|
|
|
|
|
|
|
|
|
@ -317,24 +304,47 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async {
|
|
|
|
|
|
|
|
hasError = false;
|
|
|
|
|
|
|
|
String endPoint;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_subProductsList.clear();
|
|
|
|
|
|
|
|
endPoint = FILTERED_PRODUCTS +
|
|
|
|
|
|
|
|
"$categoryId" +
|
|
|
|
|
|
|
|
"&manufacturerids=$brandId" +
|
|
|
|
|
|
|
|
"&price_min=$min" +
|
|
|
|
|
|
|
|
"&price_max=$max&page=1&limit=50";
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(
|
|
|
|
|
|
|
|
endPoint,
|
|
|
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
|
|
|
_subProductsList.add(PharmacyProduct.fromJson(item));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
hasError = true;
|
|
|
|
|
|
|
|
super.error = error;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future getMostViewedProducts() async {
|
|
|
|
Future getMostViewedProducts() async {
|
|
|
|
Map<String, String> queryParams = {
|
|
|
|
Map<String, String> queryParams = {
|
|
|
|
'fields':
|
|
|
|
'fields':
|
|
|
|
'id,discount_ids,name,reviews,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',
|
|
|
|
'id,discount_ids,name,reviews,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',
|
|
|
|
};
|
|
|
|
};
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS,
|
|
|
|
await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
_finalProducts.clear();
|
|
|
|
_finalProducts.clear();
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
print("most viewed products ---------");
|
|
|
|
print("most viewed products ---------");
|
|
|
|
print(response);
|
|
|
|
print(response);
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
hasError = true;
|
|
|
|
hasError = true;
|
|
|
|
super.error = error;
|
|
|
|
super.error = error;
|
|
|
|
}, queryParams: queryParams);
|
|
|
|
}, queryParams: queryParams);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
throw error;
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -342,22 +352,20 @@ class PharmacyCategoriseService extends BaseService {
|
|
|
|
|
|
|
|
|
|
|
|
Future getNewProducts() async {
|
|
|
|
Future getNewProducts() async {
|
|
|
|
Map<String, String> queryParams = {
|
|
|
|
Map<String, String> queryParams = {
|
|
|
|
'fields':
|
|
|
|
'fields': 'Id,name,namen,localized_names,price,images,sku,stock_availability,published',
|
|
|
|
'Id,name,namen,localized_names,price,images,sku,stock_availability,published',
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await baseAppClient.getPharmacy(GET_NEW_PRODUCTS,
|
|
|
|
await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
_finalProducts.clear();
|
|
|
|
_finalProducts.clear();
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
_finalProducts.add(PharmacyProduct.fromJson(item));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
print("new products ---------");
|
|
|
|
print("new products ---------");
|
|
|
|
print(response);
|
|
|
|
print(response);
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
hasError = true;
|
|
|
|
hasError = true;
|
|
|
|
super.error = error;
|
|
|
|
super.error = error;
|
|
|
|
}, queryParams: queryParams);
|
|
|
|
}, queryParams: queryParams);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
throw error;
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|