|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/pharmacy/products.dart';
|
|
|
|
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class WishListService extends BaseService {
|
|
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
bool isLogin = false;
|
|
|
|
List<Wishlist> _wishListProducts = List();
|
|
|
|
List<Wishlist> get wishListProducts => _wishListProducts;
|
|
|
|
|
|
|
|
// Future<Map> getWishlist() async {
|
|
|
|
// var isLogin = await sharedPref.getString(LOGIN_TOKEN_ID);
|
|
|
|
// this.isLogin = isLogin != null;
|
|
|
|
//// if (!isLogin) {
|
|
|
|
//// // if not login
|
|
|
|
//// } else {
|
|
|
|
//// try {
|
|
|
|
//// await baseAppClient.get(
|
|
|
|
//// GET_WISHLIST +'/productsbyids/5308,3608,2316,963,5045,2714,1480,',//+ "272843" + "?shopping_cart_type=2",
|
|
|
|
//// onSuccess: (dynamic response, int statusCode) {
|
|
|
|
//// wishListProducts.clear();
|
|
|
|
//// response['shopping_carts'].forEach((item) {
|
|
|
|
//// wishListProducts.add(Product.fromJson(item));
|
|
|
|
//// });
|
|
|
|
//// }, onFailure: (String error, int statusCode) {
|
|
|
|
//// hasError = true;
|
|
|
|
//// super.error = error;
|
|
|
|
//// });
|
|
|
|
//// } catch (error) {
|
|
|
|
//// throw error;
|
|
|
|
//// }
|
|
|
|
//// }
|
|
|
|
// hasError = false;
|
|
|
|
// try {
|
|
|
|
// await baseAppClient.getPharmacy(GET_WISHLIST+"1367368?shopping_cart_type=2",
|
|
|
|
// onSuccess: (dynamic response, int statusCode) {
|
|
|
|
// wishListProducts.clear();
|
|
|
|
// response.forEach((item) {
|
|
|
|
// wishListProducts.add(Wishlist.fromJson(response));
|
|
|
|
// });
|
|
|
|
// }, onFailure: (String error, int statusCode) {
|
|
|
|
// hasError = true;
|
|
|
|
// super.error = error;
|
|
|
|
// });
|
|
|
|
// } catch (error) {
|
|
|
|
// throw error;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
Future getWishlist() async {
|
|
|
|
hasError = false;
|
|
|
|
await baseAppClient.getPharmacy(GET_WISHLIST+"1367368?shopping_cart_type=2",
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
_wishListProducts.clear();
|
|
|
|
response['shopping_carts'].forEach((item) {
|
|
|
|
_wishListProducts.add(Wishlist.fromJson(item));
|
|
|
|
});
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
hasError = true;
|
|
|
|
super.error = error;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|