62 lines
1.7 KiB
Dart
62 lines
1.7 KiB
Dart
import '../../core/constants/api_endpoints.dart';
|
|
import '../../core/network/api_response.dart';
|
|
import '../../core/network/dio_client.dart';
|
|
|
|
/// 福利中心服務
|
|
class BonusService {
|
|
final DioClient _client;
|
|
|
|
BonusService(this._client);
|
|
|
|
/// 獲取福利中心狀態
|
|
Future<ApiResponse<Map<String, dynamic>>> getWelfareStatus() async {
|
|
final response = await _client.get<Map<String, dynamic>>(
|
|
ApiEndpoints.bonusWelfare,
|
|
);
|
|
if (response.success && response.data != null) {
|
|
return ApiResponse.success(response.data!, response.message);
|
|
}
|
|
return ApiResponse.fail(response.message ?? '獲取福利狀態失敗');
|
|
}
|
|
|
|
/// 領取首充福利
|
|
Future<ApiResponse<Map<String, dynamic>>> claimNewUserBonus() async {
|
|
return _client.post<Map<String, dynamic>>(
|
|
ApiEndpoints.bonusClaim,
|
|
data: {'type': 'new_user'},
|
|
);
|
|
}
|
|
|
|
/// 領取推廣獎勵
|
|
Future<ApiResponse<Map<String, dynamic>>> claimReferralBonus(
|
|
int referredUserId,
|
|
int milestone,
|
|
) async {
|
|
return _client.post<Map<String, dynamic>>(
|
|
ApiEndpoints.bonusClaim,
|
|
data: {
|
|
'type': 'referral',
|
|
'referredUserId': referredUserId,
|
|
'milestone': milestone,
|
|
},
|
|
);
|
|
}
|
|
|
|
/// 領取間接推廣獎勵
|
|
Future<ApiResponse<Map<String, dynamic>>> claimIndirectReferralBonus(
|
|
int directReferralId,
|
|
int indirectReferredUserId,
|
|
int milestone,
|
|
) async {
|
|
return _client.post<Map<String, dynamic>>(
|
|
ApiEndpoints.bonusClaim,
|
|
data: {
|
|
'type': 'indirect_referral',
|
|
'directReferralId': directReferralId,
|
|
'indirectReferredUserId': indirectReferredUserId,
|
|
'milestone': milestone,
|
|
},
|
|
);
|
|
}
|
|
}
|