UNPKG

testrail-modern-client

Version:
66 lines (65 loc) 2.99 kB
import { AddUser, User } from '../models/users'; import { BaseService } from './base'; /** * Service for interacting with TestRail users. */ export declare class UserService extends BaseService { /** * Returns a list of users. * @param projectId - Optional project ID to filter users (Required for non-administrators) * @returns List of users * @throws {Error} - If the project is invalid (400) * @throws {Error} - If there are insufficient permissions (403) * @throws {Error} - If too many requests are made (429) - TestRail Cloud only * @note As of TestRail 6.6, only administrators can use this without a projectId parameter. * @note When projectId is provided, only returns users with explicit project access and their project-level roles. * @since TestRail 6.6 */ list(projectId?: number): Promise<User[]>; /** * Returns an existing user. * @param userId - The ID of the user * @returns The requested user * @throws {Error} - If the user is invalid or unknown (400) * @throws {Error} - If too many requests are made (429) - TestRail Cloud only * @note Any user can retrieve their own account information. Retrieving other users requires administrator access. */ get(userId: number): Promise<User>; /** * Returns an existing user by email address. * @param email - The email address to get the user for * @returns The requested user * @throws {Error} - If the email address is invalid or unknown (400/404) * @throws {Error} - If too many requests are made (429) - TestRail Cloud only * @note Any user can retrieve their own account information. Retrieving other users requires administrator access. */ getByEmail(email: string): Promise<User>; /** * Creates a new user. * @param user - The user to create * @returns The created user * @throws {Error} - If the field value is invalid (400) * @throws {Error} - If there is no permission to create users (403) * @throws {Error} - If too many requests are made (429) - TestRail Cloud only * @since TestRail 7.3 */ add(user: AddUser): Promise<User>; /** * Updates an existing user. * @param userId - The ID of the user to update * @param user - The user fields to update * @returns The updated user * @throws {Error} - If the field value is invalid (400) * @throws {Error} - If there is no permission to update users (403) * @throws {Error} - If too many requests are made (429) - TestRail Cloud only */ update(userId: number, user: Partial<AddUser>): Promise<User>; /** * Returns the user for the current authentication credentials. * @returns The current user * @throws {Error} - If the user is invalid or unknown (400) * @throws {Error} - If too many requests are made (429) - TestRail Cloud only * @since TestRail 6.6 */ getCurrentUser(): Promise<User>; }