lavva.exalushome
Version:
Library implementing communication and abstraction layers for ExalusHome system
88 lines (87 loc) • 3.51 kB
TypeScript
import { Status } from "../../DataFrame";
import { IDIService } from "../../IDIService";
import { ResponseResult } from "../FieldChangeResult";
import { IPicture } from "../Pictures/IPicture";
import { AccessLevel, IUser } from "./IUser";
export interface IUsersService extends IDIService {
GetUsersAsync(): Promise<IUser[]>;
CanEditUser(user: IUser): boolean;
CanEditUsersOfAccessLevel(level: AccessLevel): boolean;
/**
* Returns user by ID, or the currently logged user when the 'id' parameter is not present.
* @param id GUID of user
* @returns 'null' when user not exists or other error ocurs, 'IUser' when request finished successful.
*/
GetUserAsync(id?: string): Promise<IUser | null>;
/**
* Function creates user with given data
* @param user user to add
* @returns ResponseResult<Status> with relevant status, as ResponseResult data we can get
* - EmailIsAlreadyUsed
* - EmailIsInIncorrectFormat
* - EmailIsToShort
* - PasswordMustBeDifferentThanEmail
* - PasswordIsToShort
* - UserWithGivenEmailAlreadyExists
* - GuidMustBeEmpty
* - UnknownError
* - (empty string)
*/
CreateUserAsync(user: IUser, password: string): Promise<ResponseResult<Status>>;
/**
* Function to change user password
* @param user
* @param password
* @returns ResponseResult<Status> with relevant status, as ResponseResult data we can get
* - PasswordMustBeDifferentThanEmail
* - PasswordIsToShort
* - CannotGetUser
* - GuidCannotBeEmpty
* - UnknownError
* - (empty string)
*/
ChangePasswordAsync(user: IUser, password: string): Promise<ResponseResult<Status>>;
/**
* Function to edit given user
* @param user updated user data
* @returns ResponseResult<Status> with relevant status, as ResponseResult data we can get
* - EmailIsAlreadyUsed
* - EmailIsInIncorrectFormat
* - EmailIsToShort
* - GuidCannotBeEmpty
* - UnknownError
* - (empty string)
*/
UpdateUserAsync(user: IUser): Promise<ResponseResult<Status>>;
/**
* Function to remove user by given ID
* @param id the identifier of the user to be deleted, if ID is empty - the current user will be deleted.
* @returns relevant status
*/
DeleteUserAsync(id?: string): Promise<Status>;
/**
* Function to get user profile picture
* @param pictureGuid
* @returns
* - Picture when request finished with success
* - ResponseResult<Status> with relevant message when error occurs, below described statuses with assigned messages:
* - WrongData | GuidCannotBeEmpty
* - UnknownError | NoDataInResult
* - ResourceDoesNotExists | PictureNotFound
* - FatalError | ExceptionOccurred
* - other status | UnknownReason
*/
GetUserProfilePictureAsync(user: IUser): Promise<IPicture | ResponseResult<Status>>;
/**
* Function to set profile picture. Picture coud be edited (if exists) or added.
* @param user
* @param base64PictureString
* ResponseResult<Status> with relevant message:
* - OK | PictureSet
* - WrongData | GuidCannotBeEmpty
* - Error | ErrorWhenTryingToCheckIfCurrentProfilePictureExists
* - all statuses form AddPictureAsync | PictureServiceError
* - all statuses from EditPictureAsync | PictureServiceError
*/
SetUserProfilePictureAsync(user: IUser, base64PictureString: string): Promise<ResponseResult<Status>>;
}