|
|
|
@ -15,32 +15,49 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
class ProductDetailService extends BaseService {
|
|
|
|
|
bool isLogin = false;
|
|
|
|
|
|
|
|
|
|
num _stockQuantity;
|
|
|
|
|
|
|
|
|
|
num get stockQuantity => _stockQuantity;
|
|
|
|
|
|
|
|
|
|
String _stockAvailability;
|
|
|
|
|
|
|
|
|
|
String get stockAvailability => _stockAvailability;
|
|
|
|
|
|
|
|
|
|
bool _isStockAvailable;
|
|
|
|
|
|
|
|
|
|
bool get isStockAvailable => _isStockAvailable;
|
|
|
|
|
|
|
|
|
|
List<ProductDetail> _productDetailList = List();
|
|
|
|
|
|
|
|
|
|
List<ProductDetail> get productDetailList => _productDetailList;
|
|
|
|
|
|
|
|
|
|
List<LocationModel> _productLocationList = List();
|
|
|
|
|
|
|
|
|
|
List<LocationModel> get productLocationList => _productLocationList;
|
|
|
|
|
|
|
|
|
|
List<Wishlist> _addToCartModel = List();
|
|
|
|
|
|
|
|
|
|
List<Wishlist> get addToCartModel => _addToCartModel;
|
|
|
|
|
|
|
|
|
|
List<Wishlist> _wishListProducts = List();
|
|
|
|
|
|
|
|
|
|
List<Wishlist> get wishListProducts => _wishListProducts;
|
|
|
|
|
|
|
|
|
|
List<SpecificationModel> _productSpecification = List();
|
|
|
|
|
List<SpecificationModel> get productSpecification => _productSpecification;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SpecificationModel> get productSpecification => _productSpecification;
|
|
|
|
|
|
|
|
|
|
Future getProductReviews(productID) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL+productID+"?fields=reviews",
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL + productID + "?fields=reviews,stock_quantity,stock_availability,IsStockAvailable", onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_productDetailList.clear();
|
|
|
|
|
response['products'].forEach((item) {
|
|
|
|
|
_productDetailList.add(ProductDetail.fromJson(item));
|
|
|
|
|
print(response);
|
|
|
|
|
});
|
|
|
|
|
_stockQuantity = response['products'][0]['stock_quantity'];
|
|
|
|
|
_stockAvailability = response['products'][0]['stock_availability'];
|
|
|
|
|
_isStockAvailable = response['products'][0]['IsStockAvailable'];
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
@ -52,19 +69,18 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
Map<String, dynamic> request;
|
|
|
|
|
|
|
|
|
|
request = {
|
|
|
|
|
"Channel": 3,
|
|
|
|
|
"DeviceTypeID": 2,
|
|
|
|
|
"IPAdress": "10.20.10.20",
|
|
|
|
|
"LanguageID": 2,
|
|
|
|
|
"PatientOutSA": 0,
|
|
|
|
|
"SKU": "6720020025",
|
|
|
|
|
"SessionID": null,
|
|
|
|
|
"VersionID": 5.6,
|
|
|
|
|
"generalid": "Cs2020@2016\$2958",
|
|
|
|
|
"isDentalAllowedBackend": false
|
|
|
|
|
// "Channel": 3,
|
|
|
|
|
// "DeviceTypeID": 2,
|
|
|
|
|
// "IPAdress": "10.20.10.20",
|
|
|
|
|
// "LanguageID": 2,
|
|
|
|
|
// "PatientOutSA": 0,
|
|
|
|
|
// "SKU": "6720020025",
|
|
|
|
|
// "SessionID": null,
|
|
|
|
|
// "VersionID": 5.6,
|
|
|
|
|
// "generalid": "Cs2020@2016\$2958",
|
|
|
|
|
// "isDentalAllowedBackend": false
|
|
|
|
|
};
|
|
|
|
|
await baseAppClient.post(GET_LOCATION,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.post(GET_LOCATION, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_productLocationList.clear();
|
|
|
|
|
response['PharmList'].forEach((item) {
|
|
|
|
|
_productLocationList.add(LocationModel.fromJson(item));
|
|
|
|
@ -83,19 +99,11 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
Map<String, dynamic> request;
|
|
|
|
|
|
|
|
|
|
request = {
|
|
|
|
|
"shopping_cart_item":
|
|
|
|
|
{
|
|
|
|
|
"quantity": quantity,
|
|
|
|
|
"shopping_cart_type": "1",
|
|
|
|
|
"product_id": itemID,
|
|
|
|
|
"customer_id": customerId,
|
|
|
|
|
"language_id": 1
|
|
|
|
|
}
|
|
|
|
|
"shopping_cart_item": {"quantity": quantity, "shopping_cart_type": "1", "product_id": itemID, "customer_id": customerId, "language_id": 1}
|
|
|
|
|
};
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
|
|
|
|
|
await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_addToCartModel.clear();
|
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
|
_addToCartModel.add(Wishlist.fromJson(item));
|
|
|
|
@ -130,14 +138,12 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
request = {
|
|
|
|
|
"shopping_cart_item": {"quantity": 1, "shopping_cart_type": "Wishlist", "product_id": itemID, "customer_id": customerId, "language_id": 1}
|
|
|
|
|
};
|
|
|
|
|
await baseAppClient.pharmacyPost(GET_SHOPPING_CART,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.pharmacyPost(GET_SHOPPING_CART, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_wishListProducts.clear();
|
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
|
_wishListProducts.add(Wishlist.fromJson(item));
|
|
|
|
|
});
|
|
|
|
|
AppToast.showSuccessToast(message: 'You have added a product to the Wishlist');
|
|
|
|
|
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
@ -148,8 +154,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
Future getWishlistItems() async {
|
|
|
|
|
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
|
hasError = false;
|
|
|
|
|
await baseAppClient.getPharmacy(GET_WISHLIST+customerId+"?shopping_cart_type=2",
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.getPharmacy(GET_WISHLIST + customerId + "?shopping_cart_type=2", onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_wishListProducts.clear();
|
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
|
_wishListProducts.add(Wishlist.fromJson(item));
|
|
|
|
@ -163,8 +168,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
Future deleteItemFromWishlist(itemID) async {
|
|
|
|
|
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
|
hasError = false;
|
|
|
|
|
await baseAppClient.getPharmacy(DELETE_WISHLIST+customerId+"+&product_id="+itemID+"&cart_type=Wishlist",
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.getPharmacy(DELETE_WISHLIST + customerId + "+&product_id=" + itemID + "&cart_type=Wishlist", onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_wishListProducts.clear();
|
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
|
_wishListProducts.add(Wishlist.fromJson(item));
|
|
|
|
@ -180,8 +184,7 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
Future productSpecificationData(itemID) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
|
|
|
|
|
await baseAppClient.getPharmacy(GET_SPECIFICATION+itemID,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await baseAppClient.getPharmacy(GET_SPECIFICATION + itemID, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_productSpecification.clear();
|
|
|
|
|
response['specification'].forEach((item) {
|
|
|
|
|
_productSpecification.add(SpecificationModel.fromJson(item));
|
|
|
|
@ -192,5 +195,4 @@ class ProductDetailService extends BaseService {
|
|
|
|
|
super.error = error;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|