Skip to main content

UserApi

@icure/medical-device-sdk / UserApi

SDK API: UserApi

The UserApi interface provides methods to manage users.

Table of contents

Methods

Methods

checkTokenValidity

checkTokenValidity(userId, token): Promise<boolean>

Checks that the provided token is (still) valid for the provided user id (or user login). Check token validity for a user.

Parameters

NameTypeDescription
userIdstringThe UUID that identifies the user uniquely
tokenstringThe token that will be checked

Returns

Promise<boolean>

Defined in

src/apis/UserApi.ts:18


createAndInviteUser

createAndInviteUser(patient, messageFactory, tokenDuration?): Promise<User>

Creates a User from an existing patient with a short-lived authentication token. It sends an invitation with the credentials and the link to complete the signup.

Parameters

NameTypeDescription
patientPatientthe Patient to create the user for.
messageFactoryEmailMessageFactory | SMSMessageFactorya MessageFactory that generates an EmailMessage or a SMSMessage.
tokenDuration?numberthe validity duration of the short-lived token, in seconds (default 48 hours)

Returns

Promise<User>

Defined in

src/apis/UserApi.ts:26


createOrModifyUser

createOrModifyUser(user): Promise<User>

A user must have a login, an email or a mobilePhone defined, a user should be linked to either a Healthcare Professional, a Patient or a Device. When modifying an user, you must ensure that the rev obtained when getting or creating the user is present as the rev is used to guarantee that the user has not been modified by a third party. Create a new user or modify an existing one.

Parameters

NameTypeDescription
userUserThe user that must be created in the database.

Returns

Promise<User>

Defined in

src/apis/UserApi.ts:33


createToken

createToken(userId, durationInSeconds?): Promise<string>

A token is used to authenticate the user. It is just like a password but it is destined to be used by programs instead of humans. Tokens have a limited validity period (one month). Create a token for a user.

Parameters

NameTypeDescription
userIdstringThe UUID that identifies the user uniquely
durationInSeconds?numberthe validity duration of the token, in seconds

Returns

Promise<string>

Defined in

src/apis/UserApi.ts:40


deleteUser

deleteUser(userId): Promise<string>

Deletes the user identified by the provided unique userId. Delete an existing user.

Parameters

NameTypeDescription
userIdstringThe UUID that uniquely identifies the user to be deleted.

Returns

Promise<string>

Defined in

src/apis/UserApi.ts:46


filterUsers

filterUsers(filter, nextUserId?, limit?): Promise<PaginatedListUser>

Filters are complex selectors that are built by combining basic building blocks. Examples of filters available for Users are AllUsersFilter and UsersByIdsFilter. This method returns a paginated list of users (with a cursor that lets you query the following items). Load users from the database by filtering them using the provided Filter.

Parameters

NameTypeDescription
filterFilter<User>The Filter object that describes which condition(s) the elements whose the ids should be returned must fulfill
nextUserId?stringThe id of the first User in the next page
limit?numberThe number of users to return in the queried page

Returns

Promise<PaginatedListUser>

Defined in

src/apis/UserApi.ts:54


getLoggedUser

getLoggedUser(): Promise<User>

When you make a call to the server, an authentication token is used to identify you. This call returns the complete User object that corresponds to your authentication credentials. Get the details of the logged User.

Returns

Promise<User>

Defined in

src/apis/UserApi.ts:59


getUser

getUser(userId): Promise<User>

Each user is uniquely identified by a user id. The user id is a UUID. This userId is the preferred method to retrieve one specific user. Get a User by id.

Parameters

NameTypeDescription
userIdstringThe UUID that identifies the user uniquely

Returns

Promise<User>

Defined in

src/apis/UserApi.ts:65


getUserByEmail

getUserByEmail(email): Promise<User>

Get a User by email.

Each user is uniquely identified by an email

Parameters

NameTypeDescription
emailstringThe email that identifies the user uniquely

Returns

Promise<User>

Defined in

src/apis/UserApi.ts:74


matchUsers

matchUsers(filter): Promise<string[]>

Filters are complex selectors that are built by combining basic building blocks. Examples of filters available for Users are AllUsersFilter and UsersByIdsFilter. This method returns the list of the ids of the users matching the filter. Load user ids from the database by filtering them using the provided Filter.

Parameters

NameTypeDescription
filterFilter<User>The Filter object that describes which condition(s) the elements whose the ids should be returned must fulfill

Returns

Promise<string[]>

Defined in

src/apis/UserApi.ts:81


shareAllFutureDataWith

shareAllFutureDataWith(dataOwnerIds, type?): Promise<User>

Add autoDelegations values to the user.

Parameters

NameTypeDescription
dataOwnerIdsstring[]Array of DataOwnerId to add
type?SharedDataTypeType of AutoDelegation to add. Shares all data by default.

Returns

Promise<User>

Updated user

Defined in

src/apis/UserApi.ts:107


stopSharingDataWith

stopSharingDataWith(dataOwnerIds, type?): Promise<User>

Removes autoDelegations values to the user.

Parameters

NameTypeDescription
dataOwnerIdsstring[]Array of DataOwnerId to add
type?SharedDataTypeType of AutoDelegation to removes. Shares all data by default.

Returns

Promise<User>

Updated user

Defined in

src/apis/UserApi.ts:115


subscribeToUserEvents

subscribeToUserEvents(eventTypes, filter, eventFired, options?): Promise<Connection>

Opens a WebSocket Connection in order to receive all the Users corresponding to specific filter criteria.

Parameters

NameTypeDescription
eventTypes("CREATE" | "UPDATE" | "DELETE")[]Type of event you would like to listen. It can be CREATE, UPDATE or DELETE
filterFilter<User>Filter criteria to filter to the users you would like to receive
eventFired(user: User) => Promise<void>Action applied each time you receive a user through the WebSocket
options?ObjectOptions to configure the WebSocket. - keepAlive : How long to keep connection alive (ms); - lifetime : How long to keep the WebSocket alive (ms); - connectionMaxRetry : how many time retrying to reconnect to the iCure WebSocket; - connectionRetryIntervalInMs : How long base interval will be between two retry. The retry attempt is exponential and using a random value (connectionRetryIntervalMs * (random between 1 and 2))^nbAttempts)
options.connectionMaxRetry?number-
options.connectionRetryIntervalMs?number-

Returns

Promise<Connection>

Defined in

src/apis/UserApi.ts:94