Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

Properties

cache: Dict<number, User>
client: PteroApp

Accessors

  • get FILTERS(): readonly string[]
  • Allowed filter arguments for users:

    • email
    • uuid
    • username
    • externalId

    Returns readonly string[]

  • get INCLUDES(): readonly string[]
  • get SORTS(): readonly string[]

Methods

  • _patch(data: any): any
  • Transforms the raw user object(s) into class objects.

    Parameters

    • data: any

      The resolvable user object(s).

    Returns any

    The resolved user object(s).

  • adminURLFor(id: number): string
  • Creates a user account.

    see

    CreateUserOptions.

    example
    app.users.create({
    email: 'user@example.com',
    username: 'example-user',
    firstname: 'example',
    lastname: 'user',
    externalId: 'example1'
    })
    .then(console.log)
    .catch(console.error);

    Parameters

    Returns Promise<User>

    The new user.

  • delete(id: number): Promise<void>
  • Deletes a user account.

    example
    app.users.delete(8).catch(console.error);
    

    Parameters

    • id: number

      The ID of the user.

    Returns Promise<void>

  • Fetches a user from the API by its ID. This will check the cache first unless the force option is specified.

    example
    app.users.fetch(5).then(console.log).catch(console.error);
    

    Parameters

    Returns Promise<User>

    The fetched user.

  • Fetches a user from the API by its external ID. This will check the cache first unless the force option is specified.

    example
    app.users.fetch('admin').then(console.log).catch(console.error);
    

    Parameters

    Returns Promise<User>

    The fetched user.

  • Fetches a list of users from the API with the given options (default is undefined).

    see

    Include and FetchOptions.

    example
    app.users.fetch({ perPage: 20 }).then(console.log).catch(console.error);
    

    Parameters

    Returns Promise<Dict<number, User>>

    The fetched users.

  • getFetchAll<T, K>(...options: unknown[]): Promise<Dict<T, K>>
  • getQueryOptions(): { filters: readonly string[]; includes: readonly string[]; sorts: readonly string[] }
  • Gets the allowed query options from the inherited manager.

    internal

    Returns { filters: readonly string[]; includes: readonly string[]; sorts: readonly string[] }

    The query options.

    • filters: readonly string[]
    • includes: readonly string[]
    • sorts: readonly string[]
  • query(entity: string, options: Filter<{ sort?: string }>): Promise<Dict<number, User>>
  • Queries the API for users that match the specified query filters. This fetches from the API directly and does not check the cache. Use cache methods for filtering and sorting.

    Available query filters:

    • email
    • uuid
    • username
    • externalId

    Available sort options:

    • id
    • -id
    • uuid
    • -uuid
    example
    app.users.query('d5f506c9', { filter: 'uuid' })
    .then(console.log)
    .catch(console.error);

    Parameters

    • entity: string

      The entity to query.

    • options: Filter<{ sort?: string }>

      The query options to filter by.

    Returns Promise<Dict<number, User>>

    The queried users.

  • Updates the user account with the specified options.

    see

    UpdateUserOptions.

    example
    app.users.update(7, { externalId: 'admin2', isAdmin: true })
    .then(console.log)
    .catch(console.error);

    Parameters

    • id: number

      The ID of the user.

    • options: Partial<UpdateUserOptions>

      Update user options.

    Returns Promise<User>

    The updated user.

Generated using TypeDoc