DirectusApiManager class
- Implemented types
Constructors
-
DirectusApiManager({required String baseURL, Client? httpClient, ILocalDirectusCacheInterface? cacheEngine, IDirectusAPI? api, Future<
void> saveRefreshTokenCallback(String)?, Future<String?> loadRefreshTokenCallback()?}) -
Creates a new DirectusApiManager instance.
baseURL: The base URL of the Directus instancehttpClient: The HTTP client to use. If not provided, a newClientwill be created.saveRefreshTokenCallback: A function that will be called when a new refresh token is received from the server. The function should save the token for later use.loadRefreshTokenCallback: A function that will be called when a new refresh token is needed to be sent to the server. The function should return the saved token.
Properties
- accessToken → String?
-
no setteroverride
- baseUrl → String
-
no setteroverride
- cachedCurrentUser ↔ DirectusUser?
-
getter/setter pair
- cacheEngine → ILocalDirectusCacheInterface?
-
Fill this property to aumtomatically have a configurable local cache
You can use the already provided JsonCacheEngine to have an already implemented cache.
Or you can create your own engine by extending ILocalDirectusCacheInterface an providing an instance of your engine in this property
final
- client → Client
-
no setter
- currentAuthToken → String?
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- refreshToken ↔ String?
-
getter/setter pairoverride-getter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldRefreshToken → bool
-
no setteroverride
- webSocketBaseUrl → String
-
no setteroverride
Methods
-
clearCacheForObject<
T extends DirectusData> (T object) → Future< void> -
Clears the cache for the object with the given
object. -
clearCacheForObjectWithId<
T extends DirectusData> (dynamic id) → Future< void> -
Clears the cache for the object with the given
id. It is important to specify the type of the object with theTannotation when calling the function. Example :clearCacheForObjectWithId<DirectusUser>(id);If you already have a full object of that type prefer using clearCacheForObject instead that will automatically infer the type of the received object. -
clearCacheWithKey(
String cacheEntryKey) → Future< void> -
Clears the cache for the object with the given
cacheEntryKey.override -
confirmPasswordReset(
{required String token, required String password}) → Future< bool> -
Saves the new password chosen by the user after requesting a password reset using the requestPasswordReset function.
override
-
convertPathToFullURL(
{required String path}) → String -
createMultipleItems<
T extends DirectusData> ({String? fields, required Iterable< T> objectList, List<String> extraTags = const []}) → Future<DirectusItemCreationResult< T> > -
override
-
createNewDirectusUser(
{required String email, required String password, String? firstname, String? lastname, String? roleUUID, Map< String, dynamic> otherProperties = const {}, required Type createItemFunction(dynamic json)}) → Future<DirectusItemCreationResult< DirectusUser> > -
createNewItem<
T extends DirectusData> ({required T objectToCreate, String? fields, List< String> extraTagsToClear = const []}) → Future<DirectusItemCreationResult< T> > -
override
-
currentDirectusUser(
{String fields = "*", bool canUseCacheForResponse = false, bool canSaveResponseToCache = true, bool canUseOldCachedResponseAsFallback = true, Duration maxCacheAge = const Duration(days: 1)}) → Future< DirectusUser?> -
Returns all the information about the currently logged in user.
Returns null if no user is logged in.
fields: A comma separated list of fields to return. If not provided, all fields will be returned.override -
deleteFile(
{required String fileId}) → Future< bool> -
override
-
deleteItem<
T extends DirectusData> ({required String objectId, bool mustBeAuthenticated = true, List< String> extraTagsToClear = const []}) → Future<bool> -
override
-
deleteMultipleItems<
T extends DirectusData> ({required Iterable objectIdsToDelete, bool mustBeAuthenticated = true, List< String> extraTagsToClear = const []}) → Future<bool> -
override
-
deleteUser(
{required DirectusUser user, bool mustBeAuthenticated = true}) → Future< bool> -
discardCurrentUserCache(
) → void -
Discards the cached current user information.
override
-
findListOfItems<
T extends DirectusData> ({Filter? filter, List< SortProperty> ? sortBy, String? fields, int? limit, int? offset, String? requestIdentifier, bool canUseCacheForResponse = false, bool canSaveResponseToCache = true, bool canUseOldCachedResponseAsFallback = true, List<String> extraTags = const [], Duration maxCacheAge = const Duration(days: 1)}) → Future<Iterable< T> > -
override
-
getDirectusUser(
String userId, {String fields = "*"}) → Future< DirectusUser?> -
Fetches the Directus user with the given
userId. Returns null if no user with the givenuserIdexists.fields: A comma separated list of fields to return. If not provided, all fields will be returned. -
getDirectusUserList(
{Filter? filter, int limit = -1, String? fields, List< SortProperty> ? sortBy, int? offset}) → Future<Iterable< DirectusUser> > -
getSpecificItem<
T extends DirectusData> ({required String id, String? fields, String? requestIdentifier, bool canUseCacheForResponse = false, bool canSaveResponseToCache = true, bool canUseOldCachedResponseAsFallback = true, List< String> extraTags = const [], Duration maxCacheAge = const Duration(days: 1)}) → Future<T?> -
override
-
hasLoggedInUser(
) → Future< bool> -
override
-
loginDirectusUser(
String username, String password, {String? oneTimePassword}) → Future< DirectusLoginResult> -
Logs in a user with the given
username,passwordand optionaloneTimePassword. Returns a Future DirectusLoginResult object that contains the result of the login attempt.override -
logoutDirectusUser(
) → Future< bool> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerDirectusUser(
{required String email, required String password, String? firstname, String? lastname}) → Future< bool> -
override
-
removeCacheEntriesWithTags(
List< String> tags) → Future<void> -
Removes from cache any object with any of the given
tags. -
requestPasswordReset(
{required String email, String? resetUrl}) → Future< bool> -
Sends a password request to the server for the provided
email. Your server must have email sending configured. It will send an email (from the template located at/extensions/templates/password-reset.liquid) to the user with a link to page to finalize his password reset. Your directus server already has a web page where the user will be sent to choose and save a new password.override -
sendRequestToEndpoint<
T> ({required BaseRequest prepareRequest(), required T jsonConverter(Response), String? requestIdentifier, bool canUseCacheForResponse = false, bool canSaveResponseToCache = true, bool canUseOldCachedResponseAsFallback = true, List< String> extraTagsToAssociate = const [], List<String> extraTagsToClear = const [], Duration maxCacheAge = const Duration(days: 1)}) → Future<T> -
override
-
startWebsocketSubscription(
DirectusWebSocketSubscription< DirectusData> subscription) → Future<void> -
stopWebsocketSubscription(
String webSocketSubscriptionId) → Future< void> -
subscriptionWasRemoved(
String webSocketSubscriptionId) → Future< void> -
toString(
) → String -
A string representation of this object.
inherited
-
tryAndRefreshToken(
) → Future< bool> -
Tries to refresh the current auth token.
This function is called automatically when a request is made and the token is expired.
There is no need to call this function manually from outside the framework.
override
-
updateDirectusUser(
{required DirectusUser updatedUser, String fields = "*"}) → Future< DirectusUser> -
updateExistingFile(
{required List< int> fileBytes, required String fileId, required String filename, String? contentType}) → Future<DirectusFile> -
override
-
updateItem<
T extends DirectusData> ({required T objectToUpdate, String? fields, List< String> extraTagsToClear = const [], bool force = false}) → Future<T> -
Update the item with the given
objectToUpdate. You have to specify a Type which extends DirectusData.override -
uploadFile(
{required List< int> fileBytes, required String filename, String? title, String? contentType, String? folder, String storage = "local", Map<String, dynamic> ? additionalFields}) → Future<DirectusFile> -
override
-
uploadFileFromUrl(
{required String remoteUrl, String? title, String? folder}) → Future< DirectusFile> -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited