lavva.exalushome
Version:
Library implementing communication and abstraction layers for ExalusHome system
101 lines (100 loc) • 5.26 kB
TypeScript
import { Status } from "../../DataFrame";
import { IDIService } from "../../IDIService";
import { ResponseResult } from "../FieldChangeResult";
export interface IControllerNotificationsService extends IDIService {
/**
* Register new notifications client in controller database and cloud.
* @param registration - registration object with device token and client data.
* @returns guid of device token of registered client or error code.
*/
RegisterNotificationsClientAsync(registration: NotificationClientRegistration): Promise<string | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Updates current notifications client data in controller database and cloud, coud be used for update device token, client name or lavva user name.
* Attention - device token and client name must be unique in controller database! In other case it returns error.
* @param tokenGuid guid of current token
* @param registration new token data
*/
UpdateNotificationsClientAsync(tokenGuid: string, registration: NotificationClientRegistration): Promise<Status.OK | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Get metadata of registered notifications clients from controller database.
* It not checks in cloud if tokens are valid, or if notifications are enabled.
* Method coud be used to get list of registered clients and then based on metadata (client name, lavva user name, token guid), update notifications clients with new device tokens, or disable or enable notifications for given clients.
* @param lavvaUserName - lavva user name, if not present then all registered tokens will be returned.
* @returns list of registered clients metadata or error code.
*/
GetRegisteredNotificationsClientsMetadataAsync(lavvaUserName?: string): Promise<DeviceTokenMetadata[] | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Returns status of notifications for given client.
* @param tokenIdentity - device token guid, device token or client id.
*/
IsNotificationsEnabledAsync(tokenIdentity: string): Promise<boolean | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Enable notifications for given client, or for all clients if tokenIdentity is not present.
* @param tokenIdentity - device token guid, device token or client id. If parameter not present then notifications for all clients in controller will be enabled.
*/
EnableNotificationsAsync(tokenIdentity?: string): Promise<Status.OK | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Disable notifications for given client, or for all clients if tokenIdentity is not present.
* @param tokenIdentity - device token guid, device token or client id. If parameter not present then notifications for all clients in controller will be disabled.
*/
DisableNotificationsAsync(tokenIdentity?: string): Promise<Status.OK | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Enable notifications for all tokens assigned for given user in controller.
* @param lavvaUserName - lavva user name.
*/
EnableNotificationsForAllUserTokensAsync(lavvaUserName: string): Promise<Status.OK | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Disable notifications for all tokens assigned for given user in controller.
* @param lavvaUserName - lavva user name.
*/
DisableNotificationsForAllUserTokensAsync(lavvaUserName: string): Promise<Status.OK | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Checks if notifications are enabled for all tokens assigned for given user in controller.
* If at least one token is disabled then it returns false.
* @param lavvaUserName
*/
IsNotificationsEnabledForAllUserTokensAsync(lavvaUserName: string): Promise<boolean | ResponseResult<NotificationsServiceErrorCode>>;
/**
* Delete device token from controller database, only for SUPPORT.
* @param tokenGuid - guid of device token.
*/
DeleteNotificationsTokenAsync(tokenGuid: string): Promise<Status.OK | ResponseResult<NotificationsServiceErrorCode>>;
}
export declare class NotificationClientRegistration {
/**
* Device token generated by Firebase API
*/
DeviceToken: string;
/**
* Unique client name (id of browser, mobile app or other client)
*/
ClientName: string;
LavvaUserName: string;
EnableNotifications: boolean;
}
export declare enum NotificationClientType {
Unknown = -1,
Web = 0,
Android = 1,
iOS = 2
}
export declare class DeviceTokenMetadata {
ClientName: string;
LavvaUserName: string;
ClientType: NotificationClientType;
TokenGuid: string;
Token: string;
RegistrationDate: Date;
}
export declare enum NotificationsServiceErrorCode {
FeatureUnsupported = "FeatureUnsupported",
UnknownError = "UnknownError",
NoData = "NoData",
IncorrectGuid = "IncorrectGuid",
IdentityIsEmpty = "IdentityIsEmpty",
DeviceTokenIsEmpty = "DeviceTokenIsEmpty",
ClientNameIsEmpty = "ClientNameIsEmpty",
LavvaUserNameIsEmpty = "LavvaUserNameIsEmpty",
TokenNotFound = "TokenNotFound",
TokensNotFoundForLavvaUser = "TokensNotFoundForLavvaUser"
}