gild method

Future<void> gild({
  1. int months = 1,
})

Gives Reddit Gold to the Redditor. months is the number of months of Reddit Gold to be given to the Redditor.

Throws a DRAWGildingError if the Redditor has insufficient gold creddits.

Implementation

Future<void> gild({int months = 1}) async {
  final body = {
    'username': _name,
    'months': months.toString(),
  };
  final path = Uri.https(Reddit.defaultOAuthApiEndpoint,
      apiPath['gild_user'].replaceAll(_usernameRegExp, _name));
  final result = await _throwOnInvalidRedditor(
      () async => await reddit.auth.post(path, body));
  if (result is Map) {
    throw DRAWGildingException(result.cast<String, String>());
  }
}