grantReward method

Future<UserGrantRewardResponseData> grantReward({
  1. required String key,
  2. String? operationId,
})

Grants a reward to this user. Requires a secret API key.

key identifies the reward. operationId makes the grant idempotent.

Implementation

Future<UserGrantRewardResponseData> grantReward({
  required String key,
  String? operationId,
}) async {
  final request = UserGrantRewardRequest((b) => b
    ..key = key
    ..operationId = operationId);
  final response = await _sdk._rewardsActions.grantReward(
    appUserId: appUserId,
    xApiKey: _sdk.apiKey,
    userGrantRewardRequest: request,
  );
  final body = response.data ??
      (throw StateError(
        'grantReward: response body was empty for user $appUserId '
        'and reward key $key.',
      ));
  return body.data;
}