CarpService class
Provide access to the CARP web services endpoint.
The (current) assumption is that each Flutter app (using this library) will only connect to one CARP web service backend. Therefore this is a singleton and should be used like:
CarpService().configure(myApp);
CarpUser user = await CarpService().authenticate(username: "user@dtu.dk", password: "password");
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.
read-only
- authEndpointUri → String
-
The URI for the authenticated endpoint for this CarpService.
read-only
- authenticated → bool
-
Is a user authenticated?
If
true
, the authenticated user is currentUser.read-only -
authStateChanges
→ Stream<
AuthEvent> -
Notifies about changes to the user's authentication state (such as sign-in or
sign-out) as defined in AuthEvent.
read-only
- consentDocumentEndpointUri → String
-
The URL for the consent document end point for this CarpService.
read-only
- currentUser → CarpUser
-
Gets the current user.
Returns
null
if no user is authenticated.read-only - currentUserEndpointUri → String
-
The URL for the current user end point for this CarpService.
read-only
- deploymentRPCEndpointUri → String
-
The URL for the deployment RPC endpoint. [...]
read-only
- documentEndpointUri → String
-
The URL for the document end point for this CarpService.
read-only
- forgottenPasswordEmail → String
-
The URL for sending email about a forgotten password.
read-only
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
-
headers
→ Map<
String, String> -
The headers for any authenticated HTTP REST call to this CarpService.
read-only
- isConfigured → bool
-
Has this service been configured?
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- userEndpointUri → String
-
The URL for the user endpoint for this CarpService.
read-only
Methods
-
authenticate(
{String username, String password}) → Future< CarpUser> -
Authenticate to this CARP service using a
username
andpassword
. [...] -
authenticateWithDialog(
BuildContext context, {String username}) → Future - Authenticate to this CARP service by showing a modal dialog form for the user to enter his/her username and password. [...]
-
authenticateWithToken(
{String username, OAuthToken token}) → Future< CarpUser> - Authenticate to this CARP web service using username and a previously stored OAuthToken access token. [...]
-
changePassword(
{String currentPassword, String newPassword}) → Future< CarpUser> - Change the password of the current user. [...]
-
collection(
String path) → CollectionReference - Gets a CollectionReference for the current CARP Service path.
-
configure(
CarpApp app) → void - Configure the default instance of the CarpService.
-
createConsentDocument(
Map< String, dynamic> document) → Future<ConsentDocument> - Create a new consent document. Returns the created ConsentDocument if the document is uploaded correctly.
-
createUser(
{String username, String password, String firstName, String lastName}) → Future< CarpUser> - Create and register a new CARP user. [...]
-
deployment(
[String studyDeploymentId]) → DeploymentReference -
Gets a DeploymentReference for a
studyDeploymentId
. If thestudyDeploymentId
is not provided, the study deployment id specified in the CarpApp is used. -
document(
String path) → DocumentReference - Gets a DocumentReference for the specified CARP Service path.
-
documentById(
int id) → DocumentReference - Gets a DocumentReference for the specified unique id.
-
documentsByQuery(
String query) → Future< List< DocumentSnapshot> > - Get a list documents from a query.
-
getConsentDocument(
int id) → Future< ConsentDocument> - Asynchronously gets a ConsentDocument.
-
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]) → FileStorageReference -
Creates a new FileStorageReference initialized at the current CarpService storage location.
id
can be omitted if a local file is not uploaded yet. -
getStudyInvitation(
BuildContext context, {bool showInvitations = true}) → Future< ActiveParticipationInvitation> - Get a study invitation from CARP by allowing the user to select from multiple invitations (if more than one is available). [...]
-
getUserBody(
String accountId, String password, String firstName, String lastName) → Map< String, String> -
invitations(
[String accountId]) → Future< List< ActiveParticipationInvitation> > -
Get the list of active participation invitations for an
accountId
. This will return all deployments that this account (user) is invited to. [...] -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
refresh(
) → Future< OAuthToken> - Get a new access token for the current user based on the previously granted refresh token.
-
sendForgottenPasswordEmail(
{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. Return the email, returned from CARP if successful. [...]
-
signOut(
) → Future - Sign out the current user.
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited