update method

  1. @override
Future<Webhook> update(
  1. Snowflake id,
  2. covariant WebhookUpdateBuilder builder,
  3. {String? token,
  4. String? auditLogReason}
)
override

Update the item with the given id in the API.

Implementers should ensure this method updates the cache.

Implementation

@override
Future<Webhook> update(Snowflake id, WebhookUpdateBuilder builder, {String? token, String? auditLogReason}) async {
  final route = HttpRoute()..webhooks(id: id.toString());
  if (token != null) {
    route.add(HttpRoutePart(token));
  }
  final request = BasicRequest(route, method: 'PATCH', body: jsonEncode(builder.build()), authenticated: token == null, auditLogReason: auditLogReason);

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

  client.updateCacheWith(webhook);
  return webhook;
}