fetch method

Future<Invite> fetch(
  1. String code,
  2. {bool? withCounts,
  3. bool? withExpiration,
  4. Snowflake? scheduledEventId}
)

Implementation

Future<Invite> fetch(String code, {bool? withCounts, bool? withExpiration, Snowflake? scheduledEventId}) async {
  final route = HttpRoute()..invites(id: code);
  final request = BasicRequest(route, queryParameters: {
    if (withCounts != null) 'with_counts': withCounts.toString(),
    if (withExpiration != null) 'with_expiration': withExpiration.toString(),
    if (scheduledEventId != null) 'guild_scheduled_event_id': scheduledEventId.toString(),
  });

  final response = await client.httpHandler.executeSafe(request);
  final invite = parse(response.jsonBody as Map<String, Object?>);

  client.updateCacheWith(invite);
  return invite;
}