Interface UserAPI

User API methods

interface UserAPI {
    details: {
        (userLookupValue: string, options?: DetailsOptions): Promise<User>;
        (
            userLookupValue: string,
            type: "username" | "email" | "userId",
        ): Promise<User>;
    };
    get roles(): (cache?: {}) => Promise<Role.Details[]>;
    get uploadProfileImage(): (
        userId: string,
        file: FileUploadType,
        options?: ImageOptions,
    ) => Promise<void>;
    addToGroup(userId: string, groupId: string): Promise<void>;
    create(user: User.Request): Promise<string>;
    delete(userId: string): Promise<void>;
    deleteProfileImage(userId: string): Promise<void>;
    exists(
        userLookupValue: string,
        type?: DetailsLookup,
    ): Promise<false | User>;
    getByEmail(email: string): Promise<User>;
    getByUsername(username: string): Promise<User>;
    getNotifications(
        unread?: boolean,
    ): Promise<{ count: number; notifications: Notification[] }>;
    listSubscriptions(): Promise<{ categories: string[]; channels: string[] }>;
    loginReport(
        sortField?: LoginReportSort,
        sortOrder?: SortDirection,
    ): Promise<LoginReportEntry[]>;
    markNotificationRead(notificationId?: string): Promise<void>;
    profile(requestOptions?: RequestOptions): Promise<User>;
    removeFromGroup(userId: string, groupId: string): Promise<void>;
    search(
        searchText?: string,
        options?: AccessEntitySearchOptions<User.SearchHit>,
    ): ISearchRequest<User.SearchHit>;
    subscribe(
        id: string,
        type: LiteralString<"Channel" | "Category">,
    ): Promise<void>;
    suspend(userId: string): Promise<void>;
    unsubscribe(
        id: string,
        type: LiteralString<"Channel" | "Category">,
    ): Promise<void>;
    unsuspend(userId: string): Promise<void>;
}

Hierarchy

  • API
    • UserAPI

Properties

details: {
    (userLookupValue: string, options?: DetailsOptions): Promise<User>;
    (
        userLookupValue: string,
        type: "username" | "email" | "userId",
    ): Promise<User>;
}

Type declaration

    • (userLookupValue: string, options?: DetailsOptions): Promise<User>
    • Get details about a specific user By default it will lookup users by userId. To lookup by username or email pass in the second parameter {lookupType}. Specify the special value 'me' to get details of the authenticated user

      Parameters

      • userLookupValue: string

        userId, username or email

      • Optionaloptions: DetailsOptions

        the lookup type {lookupType: 'username'} as well as any additional request options

      Returns Promise<User>

      const rev = new RevClient(...config...);
      await rev.connect();

      // get details of the current user
      let user = await rev.user.details('me');
      // { userId: '<guid>', username: 'string', email: 'string', ... }

      // now get the same user record, just change the lookup criteria
      console.log('looking up by id', user.userId);
      user = await rev.user.details(user.userId);

      console.log('looking up by username', user.username);
      user = await rev.user.details(user.username, { lookupType: 'username' });

      console.log('looking up by email', user.email);
      user = await rev.user.details(user.email, { lookupType: 'email' });
    • (userLookupValue: string, type: "username" | "email" | "userId"): Promise<User>
    • Parameters

      • userLookupValue: string
      • type: "username" | "email" | "userId"

      Returns Promise<User>

      use updated signature details(userLookupValue, {lookupType: 'userId' | 'username' | 'email'}) instead

Accessors

  • get roles(): (cache?: {}) => Promise<Role.Details[]>
  • get the list of roles available in the system (with role name and id)

    Returns (cache?: {}) => Promise<Role.Details[]>

      • (cache?: {}): Promise<Role.Details[]>
      • get mapping of role names to role IDs

        Parameters

        • cache: {} = true

          if true allow storing/retrieving from cached values. 'Force' means refresh value saved in cache

        Returns Promise<Role.Details[]>

Methods

  • Create a new User in Rev

    Parameters

    Returns Promise<string>

    the User ID of the created user

  • Parameters

    • userId: string

    Returns Promise<void>

  • Parameters

    • userId: string

    Returns Promise<void>

  • Check if user exists in the system. Instead of throwing on a 401/403 error if user does not exist it returns false. Returns user details if does exist, instead of just true

    Parameters

    • userLookupValue: string

      userId, username, or email

    • Optionaltype: DetailsLookup

    Returns Promise<false | User>

    User if exists, otherwise false

  • get user details by email address

    Parameters

    • email: string

    Returns Promise<User>

    use user.details() with {lookupType: 'email'}

  • get user details by username

    Parameters

    • username: string

    Returns Promise<User>

    use user.details() with {lookupType: 'username'}

  • Parameters

    • unread: boolean = false

    Returns Promise<{ count: number; notifications: Notification[] }>

  • Returns the channel and category subscriptions for the user making the API call.

    Returns Promise<{ categories: string[]; channels: string[] }>

  • Parameters

    • OptionalnotificationId: string

      If notificationId not provided, then all notifications for the user are marked as read.

    Returns Promise<void>

  • Parameters

    • id: string
    • type: LiteralString<"Channel" | "Category">

    Returns Promise<void>

  • Parameters

    • userId: string

    Returns Promise<void>

  • Unsubscribe from specific channel or category.

    Parameters

    • id: string
    • type: LiteralString<"Channel" | "Category">

    Returns Promise<void>

  • Parameters

    • userId: string

    Returns Promise<void>