initial commit (migrated)
This commit is contained in:
commit
b594facb51
143 changed files with 11057 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:kuwot/core/error/failure.dart';
|
||||
|
||||
abstract class InAppPurchaseRepository {
|
||||
Stream<List<PurchaseDetails>> get purchaseStream;
|
||||
|
||||
Future<Either<Failure, List<ProductDetails>>> getConsumableProducts();
|
||||
|
||||
Future<Either<Failure, bool>> purchaseConsumableProduct(
|
||||
ProductDetails product,
|
||||
);
|
||||
|
||||
Future<Either<Failure, void>> completePurchase(
|
||||
PurchaseDetails purchaseDetails,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:kuwot/core/domain/no_params.dart';
|
||||
import 'package:kuwot/core/domain/use_case.dart';
|
||||
import 'package:kuwot/core/error/failure.dart';
|
||||
import 'package:kuwot/features/in_app_purchase/domain/repositories/in_app_purchase_repository.dart';
|
||||
|
||||
class GetConsumableProducts extends UseCase<List<ProductDetails>, NoParams> {
|
||||
final InAppPurchaseRepository repository;
|
||||
|
||||
GetConsumableProducts(this.repository);
|
||||
|
||||
@override
|
||||
Future<Either<Failure, List<ProductDetails>>> call(NoParams params) async {
|
||||
return repository.getConsumableProducts();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:kuwot/core/domain/no_params.dart';
|
||||
import 'package:kuwot/core/domain/use_case.dart';
|
||||
import 'package:kuwot/core/error/failure.dart';
|
||||
import 'package:kuwot/features/in_app_purchase/domain/repositories/in_app_purchase_repository.dart';
|
||||
|
||||
class ListenPurchase
|
||||
implements UseCase<Stream<List<PurchaseDetails>>, NoParams> {
|
||||
ListenPurchase(this.repository);
|
||||
|
||||
final InAppPurchaseRepository repository;
|
||||
|
||||
@override
|
||||
Future<Either<Failure, Stream<List<PurchaseDetails>>>> call(NoParams params) {
|
||||
// it always return right because I dont think it will throw an error
|
||||
return Future.value(right(repository.purchaseStream));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import 'package:equatable/equatable.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:kuwot/core/domain/use_case.dart';
|
||||
import 'package:kuwot/core/error/failure.dart';
|
||||
import 'package:kuwot/features/in_app_purchase/domain/repositories/in_app_purchase_repository.dart';
|
||||
|
||||
class PurchaseConsumableProduct
|
||||
extends UseCase<bool, PurchaseConsumableProductParams> {
|
||||
final InAppPurchaseRepository repository;
|
||||
|
||||
PurchaseConsumableProduct(this.repository);
|
||||
|
||||
@override
|
||||
Future<Either<Failure, bool>> call(
|
||||
PurchaseConsumableProductParams params,
|
||||
) async {
|
||||
return repository.purchaseConsumableProduct(params.productDetails);
|
||||
}
|
||||
}
|
||||
|
||||
class PurchaseConsumableProductParams extends Equatable {
|
||||
final ProductDetails productDetails;
|
||||
|
||||
const PurchaseConsumableProductParams({required this.productDetails});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [productDetails];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue