productdetails
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:fpdart/fpdart.dart';
|
||||
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
|
||||
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
||||
import 'package:grocery_app/src/data/OTPResponseModel.dart';
|
||||
import 'package:grocery_app/src/data/login_response.dart';
|
||||
import 'package:grocery_app/src/data/registration_response.dart';
|
||||
import 'package:grocery_app/src/data/vendor_otpModel.dart';
|
||||
import 'package:grocery_app/src/logic/services/auth_service_locator.dart';
|
||||
@@ -19,8 +20,7 @@ class AuthRepo {
|
||||
try {
|
||||
var response = await _authServices.sendOtp(data);
|
||||
final String model = response.toString();
|
||||
// OtpResponseModel otpResponseModel =
|
||||
// otpResponseModelFromJson(response.toString());
|
||||
|
||||
|
||||
return right(model);
|
||||
} on DioException catch (e) {
|
||||
@@ -42,7 +42,7 @@ class AuthRepo {
|
||||
authToken: vendorOtpModel.data!.accessToken ?? "");
|
||||
}
|
||||
|
||||
// final String model = response.toString();
|
||||
|
||||
|
||||
return right(vendorOtpModel);
|
||||
} on DioException catch (e) {
|
||||
@@ -51,6 +51,27 @@ class AuthRepo {
|
||||
}
|
||||
}
|
||||
|
||||
FutureResult<LoginResponse> loginOtp(data) async {
|
||||
try {
|
||||
var response = await _authServices.loginOtp(data);
|
||||
|
||||
LoginResponse loginResponse = loginResponseFromJson(response.toString());
|
||||
|
||||
if (loginResponse.accessToken != null)
|
||||
{
|
||||
await SharedPrefUtils.setToken(
|
||||
authToken: loginResponse.accessToken ?? "");
|
||||
}
|
||||
|
||||
// final String model = response.toString();
|
||||
|
||||
return right(loginResponse);
|
||||
} on DioException catch (e) {
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
// FutureResult<LoginResponse> login(data) async {
|
||||
// try {
|
||||
// var response = await _authServices.login(data);
|
||||
|
||||
@@ -9,8 +9,10 @@ import 'package:grocery_app/src/data/banners.dart';
|
||||
import 'package:grocery_app/src/data/best_dealProduct.dart';
|
||||
import 'package:grocery_app/src/data/check_pin_response.dart';
|
||||
import 'package:grocery_app/src/data/product_category.dart';
|
||||
import 'package:grocery_app/src/data/product_details.dart';
|
||||
import 'package:grocery_app/src/data/wish_list_model.dart';
|
||||
import 'package:grocery_app/src/logic/services/home_locator.dart';
|
||||
import 'package:grocery_app/src/ui/productdetails/product_details.dart';
|
||||
|
||||
class ProductRepo {
|
||||
final ProductService _productService;
|
||||
@@ -34,6 +36,24 @@ class ProductRepo {
|
||||
}
|
||||
}
|
||||
|
||||
FutureResult<ProductDetailsData> getProductDetails(
|
||||
data, BuildContext context, id) async {
|
||||
try {
|
||||
var response = await _productService.getProductDetails(data, id);
|
||||
|
||||
ProductDetailsData loginResponse = productDetailsdataFromJson(response.toString());
|
||||
|
||||
final String model = response.toString();
|
||||
|
||||
return right(loginResponse);
|
||||
} on DioException catch (e) {
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
FutureResult<BestDealProduct> getBestDealProduct(
|
||||
data, BuildContext context) async {
|
||||
try {
|
||||
@@ -103,14 +123,26 @@ class ProductRepo {
|
||||
}
|
||||
}
|
||||
|
||||
FutureResult<CheckPinResponse> checkPin(data,pin) async {
|
||||
FutureResult<CheckPinResponse> checkPin(data, pin) async {
|
||||
try {
|
||||
var response = await _productService.checkPin(data,pin);
|
||||
CheckPinResponse allCartItems = checkPinResponseFromJson(response.toString());
|
||||
var response = await _productService.checkPin(data, pin);
|
||||
CheckPinResponse allCartItems =
|
||||
checkPinResponseFromJson(response.toString());
|
||||
|
||||
return right(allCartItems);
|
||||
} on DioException catch (e) {
|
||||
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
FutureResult<String> deleteItem(data, id) async {
|
||||
try {
|
||||
var response = await _productService.deleteItem(data, id);
|
||||
final String model = response.toString();
|
||||
|
||||
return right(model);
|
||||
} on DioException catch (e) {
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user