41 lines
1.4 KiB
Dart
41 lines
1.4 KiB
Dart
import '../../core/network/api_client.dart';
|
|
import 'shop_models.dart';
|
|
|
|
/// دسترسی به endpointهای فروشگاه و پاداشها.
|
|
class ShopRepository {
|
|
final ApiClient _api;
|
|
ShopRepository(this._api);
|
|
|
|
Future<ShopData> getShop() async {
|
|
final res = await _api.dio.get('/shop');
|
|
return ShopData.fromJson(Map<String, dynamic>.from(res.data));
|
|
}
|
|
|
|
Future<void> buyCard(String cardId) =>
|
|
_api.dio.post('/shop/buy-card', data: {'card_id': cardId});
|
|
|
|
Future<void> selectCard(String cardId) =>
|
|
_api.dio.post('/shop/select-card', data: {'card_id': cardId});
|
|
|
|
/// تأیید خرید IAP. در حالت واقعی token از SDK بازار/مایکت میآید؛
|
|
/// فعلاً توکن توسعهای فرستاده میشود (بکاند در حالت dev هر توکن غیرخالی را میپذیرد).
|
|
Future<void> purchase({
|
|
required String store,
|
|
required String kind,
|
|
required String productId,
|
|
required String token,
|
|
}) =>
|
|
_api.dio.post('/shop/purchase', data: {
|
|
'store': store,
|
|
'kind': kind,
|
|
'product_id': productId,
|
|
'token': token,
|
|
});
|
|
|
|
/// سکه رایگان پس از تبلیغ rewarded. token از SDK تپسل میآید (فعلاً توسعهای).
|
|
Future<int> adReward(String token) async {
|
|
final res = await _api.dio.post('/rewards/ad', data: {'token': token});
|
|
return (res.data['amount'] ?? 0) as int;
|
|
}
|
|
}
|