User

Though the SDK does not store and should not be responsible for the handling User profile data for your application, we do provide tools to make some surface-level queries and searches for existing user accounts.

A User consists of a userId, and may also contain a displayName, a list of their roles, and some metadata. The userId is immutable once the account is created, however the displayName can be updated at all times.

All User methods are contained in a UserRepository class. Before calling any User methods, you must first instantiate a repository instance.

import { UserRepository } from 'eko-sdk';
const userRepo = new UserRepository();

Get a User

The User Repository provides a method to get a single user, which will be returned as a LiveObject:

userRepo.userForId('user123')

Get All Users

The User Repository provides a method to get a list of all users, which will be returned as a LiveCollection:

userRepo.getAllUsers()

This method takes an optional sortBy parameter which must be a EkoUserSortingMethod - these include displayName, firstCreated, and lastCreated:

import { EkoUserSortingMethod } from 'eko-sdk'
‚Äč
userRepo.getAllUsers(EkoUserSortingMethod.DisplayName)

Search for Users

The User Repository provides a method to search for users by their display name. The result of this search is returned as a LiveCollection.

userRepo.searchUserByDisplayName('Test User 1')

The above example searches for all users whose display names start with "Test User 1". Note that the search is case sensitive.

Flag & Unflag Users

To flag a user, call the following method:

userRepo.flag({ userId: 'user123' })

To unflag a user, call the following method:

userRepo.unflag({ userId: 'user123' })

Both of these methods return a promise meaning they can be chained with .then and .catch handlers:

userRepo.flag({ userId: 'user123' })
.then(() => {})
.catch(() => {})