fetch method

  1. @override
Future<Webhook> fetch(
  1. Snowflake id, {
  2. String? token,
})
override

Fetch the item with the given id from the API.

Implementers should ensure this method updates the cache.

Implementation

@override
Future<Webhook> fetch(Snowflake id, {String? token}) async {
  final route = HttpRoute()..webhooks(id: id.toString());
  if (token != null) {
    route.add(HttpRoutePart(token));
  }
  final request = BasicRequest(route, authenticated: token == null);

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

  client.updateCacheWith(webhook);
  return webhook;
}