claimReward method

Future<ApiResponseModel<bool?>> claimReward({
  1. required String id,
  2. required int rewardIndex,
  3. required String companyId,
})

Claims a community reward.

id is the ID of the challenge. rewardIndex is the index of the reward to claim. companyId is the company ID. Returns success status.

Implementation

Future<ApiResponseModel<bool?>> claimReward({
  required String id,
  required int rewardIndex,
  required String companyId,
}) async {
  final url = "$_baseUrl/challenges/$id/rewards/$rewardIndex/claim";

  final payload = {
    'apiKey': _apiKey,
    'companyId': companyId,
  };

  debugPrint("flutter_mon_sms_pro/challenges/claimReward/payload: $payload");

  final r = await _dio.post(url, data: payload);

  debugPrint("flutter_mon_sms_pro/challenges/claimReward/data: ${r.data}");

  final response = ApiResponseModel.fromJson(
    r.data,
    (data) => (data as Map<String, dynamic>)['claimed'] as bool?,
  );

  return response;
}