addCart method

  1. @override
Future<Either<Failure, Cart>> addCart(
  1. Cart cart
)
override

Implementation

@override
Future<Either<Failure, Cart>> addCart(Cart cart) async {
  final result =await _gateway.addCart(cart.toJson());
  return result.fold(
    Left.new,
    (json) {
      try{
        final cart = Cart.fromJson(json);
        return Right(cart);
      }catch(e, stackTrace){
        return Left(
          Failure(
            title: 'Error en el UserRepositoryImpl',
            code: 'mapping_error',
            description: "Error al mapear el carrito despues de agregar el carrito",
            stackTrace: stackTrace.toString(),
            type: FailureSeverity.warning
          )
        );
      }
    }
  );
}