CarpService class

Provide access to a CARP web service endpoint.

The (current) assumption is that each Flutter app (using this library) will only connect to one CARP web service backend. Therefore the CarpService class is a singleton and should be used like:

  CarpService().configure(myApp);
  CarpUser user = await CarpService().authenticate(username: "user@dtu.dk", password: "password");
Inheritance

Constructors

CarpService()
Returns the singleton default instance of the CarpService. Before this instance can be used, it must be configured using the configure method.
factory

Properties

app CarpApp?
The CARP app associated with the CARP Web Service. Returns null if this service has not yet been congfigured via the configure method.
no setterinherited
authEndpointUri String
The URI for the authenticated endpoint for this CarpService.
no setter
authenticated bool
Is a user authenticated? If true, the authenticated user is currentUser.
no setter
authStateChanges Stream<AuthEvent>
Notifies about changes to the user's authentication state (such as sign-in or sign-out) as defined in AuthEvent.
no setter
consentDocumentEndpointUri String
The URL for the consent document end point for this CarpService.
no setter
currentUser CarpUser?
Gets the current user. Returns null if no user is authenticated.
no setterinherited
currentUserEndpointUri String
The URL for the current user end point for this CarpService.
no setter
documentEndpointUri String
The URL for the document end point for this CarpService.
no setter
fileEndpointUri String
The URL for the file end point for this CarpService.
no setter
forgottenPasswordEmailUri String
The URL for sending email about a forgotten password.
no setter
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
The headers for any authenticated HTTP REST call to this CarpService.
no setteroverride
isConfigured bool
Has this service been configured?
no setterinherited
resetPasswordUrl String
The URL for the reset password page for this CarpService.
no setter
rpcEndpointName String
The endpoint name for this service at CARP.
no setteroverride
rpcEndpointUri String
The URL for this service's endpoint at CARP.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
userEndpointUri String
The URL for the user endpoint for this CarpService.
no setter

Methods

authenticate({required String username, required String password}) Future<CarpUser>
Authenticate to this CARP service using a username and password.
authenticateWithDialog(BuildContext context, {String? username, bool allowClose = false}) Future<CarpUser?>
Authenticate to this CARP service by showing a modal dialog form for the user to enter his/her username and password.
authenticateWithToken({required String username, required OAuthToken token}) Future<CarpUser>
Authenticate to this CARP web service using username and a previously stored OAuthToken access token.
changePassword({required String currentPassword, required String newPassword}) Future<CarpUser>
Change the password of the current user.
collection(String path) CollectionReference
Gets a CollectionReference for the specified path.
configure(CarpApp app) → void
Configure the this instance of a Carp Service.
inherited
configureFrom(CarpBaseService service) → void
Configure from another service which has alreay been configured and potentially authenticated.
inherited
createConsentDocument(Map<String, dynamic> document) Future<ConsentDocument>
Create a new (signed) consent document for this user. Returns the created ConsentDocument if the document is uploaded correctly.
document(String path) DocumentReference
Gets a DocumentReference for the specified path.
documentById(int id) DocumentReference
Gets a DocumentReference for the specified unique id.
documents() Future<List<DocumentSnapshot>>
Get all documents for this study.
documentsByQuery(String query) Future<List<DocumentSnapshot>>
Get a list documents from a query.
getAllFiles() Future<List<CarpFileResponse>>
Get all file objects in the study.
getConsentDocument(int id) Future<ConsentDocument>
Asynchronously gets an uploaded (signed) ConsentDocument based on its id.
getCurrentUserProfile() Future<CarpUser>
Asynchronously gets the CARP profile of the current user.
getDataPointReference() DataPointReference
Creates a new DataPointReference initialized at the current CarpService storage location.
getFileStorageReference([int id = -1]) FileStorageReference
Get a FileStorageReference that reference a file at the current CarpService storage location. id can be omitted if a local file is not uploaded yet.
getFileStorageReferenceByName(String name) Future<FileStorageReference?>
Get a FileStorageReference that reference a file with the original name name at the current CarpService storage location.
logout() Future<void>
Logout from CARP
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queryFiles([String? query]) Future<List<CarpFileResponse>>
Returns file objects in the study based on a query.
refresh() Future<OAuthToken>
Get a new access token for the current user based on the previously granted refresh token.
sendForgottenPasswordEmail({required String email}) Future<String>
Triggers the CARP backend to send a password-reset email to the given email address, which must correspond to an existing user of the current app.
signOut() Future
Sign out the current user.
toString() String
A string representation of this object.
inherited

Operators

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