Options
All
  • Public
  • Public/Protected
  • All
Menu

Class users

User Service

Hierarchy

  • users

Index

Constructors

constructor

Methods

Static addRole

  • addRole(user: IdOrObject<User>, role: UserRole): Promise<{ success: true }>
  • Adds a new role to the user. Roles are the method by which Qminder controls who can access which location, at what access level. For example, a User who has administrator privileges can access and modify all location settings, for all locations. However, a User who has clerk privileges can log in and serve visitors, but not modify any location settings nor see service statistics.

    Parameters

    • user: IdOrObject<User>

      the User that you want to add roles to

    • role: UserRole

      the UserRole you want to add for the user.

    Returns Promise<{ success: true }>

    a Promise that resolves when the role adding succeeded, and rejects when something went wrong.

Static create

  • create(user: Pick<User, "firstName" | "lastName" | "email" | "roles">): Promise<User>
  • Create a new User.

    To create a new User, the user's email address, first and last name, and at least one UserRole are needed.

    After creating the User, the person will receive an email asking them to reset their password. When they reset their password, they can access Qminder based on their UserRoles.

    Calls the HTTP API POST /v1/users/

    throws

    Error when the user's first name, last name, email or roles are missing, or invalid.

    see

    UserRole

    Parameters

    • user: Pick<User, "firstName" | "lastName" | "email" | "roles">

      an object filled with user details: the first/last name, email and an array of UserRoles are mandatory.

    Returns Promise<User>

    a Promise that resolves with the new created User, or rejects if something went wrong.

Static details

  • details(userIdOrEmail: IdOrObject<User>): Promise<User>
  • Fetch the user's details.

    This method allows searching by both user ID and exact email address. When searching by email address, only exact matches are considered.

    Calls the HTTP API GET /v1/users/<user>

    For example:

    import * as Qminder from 'qminder-api';
    Qminder.setKey('API_KEY_HERE');
    
    // Example 1. Get user details by their email address
    const user = await Qminder.users.details("john@example.com");
    
    // Example 2. Get user details by user ID
    const user = await Qminder.users.details(14152);
    
    // Example 3. Get user details by User object
    const usersList: Array<User> = Qminder.users.list(1234);
    let firstUser = usersList[0];
    firstUser = await Qminder.users.details(firstUser);
    
    throws

    Error when the user argument was invalid (not a string, not a number, or not a User)

    Parameters

    • userIdOrEmail: IdOrObject<User>

    Returns Promise<User>

    a Promise that resolves to the user's details, and rejects when something goes wrong.

Static list

  • List all Users in a Location.

    Returns an Array of all users that have access to a Location. (Owner, Administrators, Location Managers, and Clerks)

    Calls this HTTP API: GET /v1/locations/<ID>/users

    For example:

    // Fetch the user list for location ID 1234
    const locationId = 1234;
    const users = await Qminder.users.list(locationId);
    

    Parameters

    • location: IdOrObject<Location>

      the Location to find all users for.

    Returns Promise<User[]>

    a Promise that resolves to a list of Users who have access to the location, or rejects when something went wrong.

Static removeDesk

  • removeDesk(user: IdOrObject<User>): Promise<SuccessResponse>
  • Unset the user's currently selected Desk.

    After this API call, the user will have no desk selected.

    Calls the HTTP API DELETE /v1/users/<ID>/desk.

    Parameters

    • user: IdOrObject<User>

      The user to modify

    Returns Promise<SuccessResponse>

    A promise that resolves when setting the desk works, and rejects if it failed.

Static selectDesk

  • selectDesk(user: IdOrObject<User>, desk: IdOrObject<Desk>): Promise<{}>
  • Set the user's currently selected Desk.

    Calls the HTTP API POST /v1/users/<ID>/desk

    For example:

    import * as Qminder from 'qminder-api';
    Qminder.setKey('API_KEY_HERE');
    // Example. Set the user 14152's desk to Desk 4
    await Qminder.users.selectDesk(14152, 4);
    

    Parameters

    • user: IdOrObject<User>

      The user to modify.

    • desk: IdOrObject<Desk>

      The desired desk.

    Returns Promise<{}>

    A promise that resolves when setting the desk works, and rejects if it failed.

Static setLines

  • setLines(user: IdOrObject<User>, lines: IdOrObject<Line>[]): Promise<SuccessResponse>
  • Set the lines selected by current user. All other lines that aren't specified are set to unselected.

    Calls the HTTP API POST /v1/users/<ID>/lines

    For example:

    import * as Qminder from 'qminder-api';
    Qminder.setKey('API_KEY_HERE');
    // Example. Set user 5342's selected lines to 12345, 54321, 98765
    await Qminder.users.setLines(5342, [12345, 54321, 98765])
    

    Parameters

    • user: IdOrObject<User>

      The user whose lines to set.

    • lines: IdOrObject<Line>[]

      array of Line, or array of line IDs

    Returns Promise<SuccessResponse>

    A promise that resolves when setting the lines works, and rejects if it failed.

Generated using TypeDoc