ApiKeyModel class abstract

API key record as returned by Better Auth (hashed key is omitted on most endpoints). The plaintext secret is only present on ApiKeyBetterAuth.create.

Available extensions
Annotations
  • @freezed

Constructors

ApiKeyModel({required String id, @Default.new('default') String configId, String? name, String? start, String? prefix, String? key, required String referenceId, int? refillInterval, int? refillAmount, DateTime? lastRefillAt, @Default.new(true) bool enabled, @Default.new(true) bool rateLimitEnabled, int? rateLimitTimeWindow, int? rateLimitMax, @Default.new(0) int requestCount, int? remaining, DateTime? lastRequest, DateTime? expiresAt, required DateTime createdAt, required DateTime updatedAt, Map<String, dynamic>? metadata, Map<String, dynamic>? permissions})
const
factory
ApiKeyModel.fromJson(Map<String, dynamic> json)
factory

Properties

configId String
no setterinherited
copyWith → $ApiKeyModelCopyWith<ApiKeyModel>
Create a copy of ApiKeyModel with the given fields replaced by the non-null parameter values.
no setterinherited
createdAt DateTime
no setterinherited
enabled bool
no setterinherited
expiresAt DateTime?
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
id String
no setterinherited
key String?
Hashed value in storage; omitted from list/get responses. On create, the server overwrites this field with the plaintext secret once.
no setterinherited
lastRefillAt DateTime?
no setterinherited
lastRequest DateTime?
no setterinherited
metadata Map<String, dynamic>?
no setterinherited
name String?
no setterinherited
permissions Map<String, dynamic>?
no setterinherited
prefix String?
no setterinherited
rateLimitEnabled bool
no setterinherited
rateLimitMax int?
no setterinherited
rateLimitTimeWindow int?
no setterinherited
referenceId String
no setterinherited
refillAmount int?
no setterinherited
refillInterval int?
no setterinherited
remaining int?
no setterinherited
requestCount int
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
start String?
no setterinherited
updatedAt DateTime
no setterinherited

Methods

map<TResult extends Object?>(TResult $default(_ApiKeyModel value)) → TResult

Available on ApiKeyModel, provided by the ApiKeyModelPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>(TResult? $default(_ApiKeyModel value)?) → TResult?

Available on ApiKeyModel, provided by the ApiKeyModelPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>(TResult $default(_ApiKeyModel value)?, {required TResult orElse()}) → TResult

Available on ApiKeyModel, provided by the ApiKeyModelPatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>(TResult $default(String id, String configId, String? name, String? start, String? prefix, String? key, String referenceId, int? refillInterval, int? refillAmount, DateTime? lastRefillAt, bool enabled, bool rateLimitEnabled, int? rateLimitTimeWindow, int? rateLimitMax, int requestCount, int? remaining, DateTime? lastRequest, DateTime? expiresAt, DateTime createdAt, DateTime updatedAt, Map<String, dynamic>? metadata, Map<String, dynamic>? permissions)?, {required TResult orElse()}) → TResult

Available on ApiKeyModel, provided by the ApiKeyModelPatterns extension

A variant of when that fallback to an orElse callback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes this ApiKeyModel to a JSON map.
inherited
toString() String
A string representation of this object.
inherited
when<TResult extends Object?>(TResult $default(String id, String configId, String? name, String? start, String? prefix, String? key, String referenceId, int? refillInterval, int? refillAmount, DateTime? lastRefillAt, bool enabled, bool rateLimitEnabled, int? rateLimitTimeWindow, int? rateLimitMax, int requestCount, int? remaining, DateTime? lastRequest, DateTime? expiresAt, DateTime createdAt, DateTime updatedAt, Map<String, dynamic>? metadata, Map<String, dynamic>? permissions)) → TResult

Available on ApiKeyModel, provided by the ApiKeyModelPatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>(TResult? $default(String id, String configId, String? name, String? start, String? prefix, String? key, String referenceId, int? refillInterval, int? refillAmount, DateTime? lastRefillAt, bool enabled, bool rateLimitEnabled, int? rateLimitTimeWindow, int? rateLimitMax, int requestCount, int? remaining, DateTime? lastRequest, DateTime? expiresAt, DateTime createdAt, DateTime updatedAt, Map<String, dynamic>? metadata, Map<String, dynamic>? permissions)?) → TResult?

Available on ApiKeyModel, provided by the ApiKeyModelPatterns extension

A variant of when that fallback to returning null

Operators

operator ==(Object other) bool
The equality operator.
inherited