update method
Update an API key
Implementation
Future<ApiKey> update({
required String keyId,
String? name,
int? expiresIn,
String? userId,
int? remaining,
Map<String, dynamic>? metadata,
int? refillAmount,
int? refillInterval,
int? rateLimitTimeWindow,
int? rateLimitMax,
bool? rateLimitEnabled,
}) async {
try {
final Map<String, dynamic> body = {'keyId': keyId};
if (name != null) body['name'] = name;
if (expiresIn != null) body['expiresIn'] = expiresIn;
if (userId != null) body['userId'] = userId;
if (remaining != null) body['remaining'] = remaining;
if (metadata != null) body['metadata'] = metadata;
if (refillAmount != null) body['refillAmount'] = refillAmount;
if (refillInterval != null) body['refillInterval'] = refillInterval;
if (rateLimitTimeWindow != null) body['rateLimitTimeWindow'] = rateLimitTimeWindow;
if (rateLimitMax != null) body['rateLimitMax'] = rateLimitMax;
if (rateLimitEnabled != null) body['rateLimitEnabled'] = rateLimitEnabled;
final res = await super.dio.post(
'/api-key/update',
data: body,
options: await super.getOptions(isTokenRequired: true),
);
return ApiKey.fromJson(res.data);
} catch (e) {
final message = getErrorMessage(e);
if (message == null) rethrow;
throw message;
}
}