Current File : //home/tradevaly/new.tradevaly.com.bd/fresh/lib/data/repository/wishlist_repo.dart |
import 'package:flutter/material.dart';
import 'package:flutter_grocery/data/datasource/remote/dio/dio_client.dart';
import 'package:flutter_grocery/data/datasource/remote/exception/api_error_handler.dart';
import 'package:flutter_grocery/data/model/response/base/api_response.dart';
import 'package:flutter_grocery/utill/app_constants.dart';
class WishListRepo {
final DioClient dioClient;
WishListRepo({@required this.dioClient});
Future<ApiResponse> getWishList() async {
try {
final response = await dioClient.get(AppConstants.WISH_LIST_GET_URI);
return ApiResponse.withSuccess(response);
} catch (e) {
return ApiResponse.withError(ApiErrorHandler.getMessage(e));
}
}
Future<ApiResponse> addWishList(List<int> productID) async {
try {
final response = await dioClient.post(AppConstants.WISH_LIST_GET_URI, data: {'product_ids' : productID});
return ApiResponse.withSuccess(response);
} catch (e) {
return ApiResponse.withError(ApiErrorHandler.getMessage(e));
}
}
Future<ApiResponse> removeWishList(List<int> productID) async {
try {
final response = await dioClient.delete(AppConstants.WISH_LIST_GET_URI, data: {'product_ids' : productID, '_method':'delete'});
return ApiResponse.withSuccess(response);
} catch (e) {
return ApiResponse.withError(ApiErrorHandler.getMessage(e));
}
}
}