/** * @module UserNetwork */ import { Subscription } from 'rxjs'; import { ContactService } from '../../services/core/contact.service'; import { NetworkInvitation } from '../../models/invitation.model'; import { RBEvent } from '../../models/event.model'; import { Contact } from '../../models/contact.model'; import { Service } from '../../services/service'; import { User } from '../../models'; /** @internal */ export declare const USER_NETWORK_SVC = "UserNetworkService"; /** @eventProperty */ export declare enum UserNetworkServiceEvents { /** * @eventProperty * This RBEvent is send when a new network invitation is received from another Rainbow user * with data {invitation:Invitation, user:User} */ RAINBOW_ON_INVITATION_RECEIVED = "RAINBOW_ON_INVITATION_RECEIVED", /** * @eventProperty * This RBEvent is send when the invitation (from / to) contact is accepted * with data {invitation:Invitation, user:User} */ RAINBOW_ON_INVITATION_ACCEPTED = "RAINBOW_ON_INVITATION_ACCEPTED", /** * @eventProperty * This RBEvent is send when the invitation list (received/send) is updated */ RAINBOW_ON_INVITATIONS_LIST_UPDATED = "RAINBOW_ON_INVITATIONS_LIST_UPDATED" } export interface UserNetworkService { /** * Subscribe to the invitations updates; All events send to the callback are of type RB Event * Events that will be received in the subscribe : * - 'RAINBOW_ON_INVITATION_RECEIVED' with data {invitation:Invitation, contact:Contact}: A new invitation from 'contact' is received * - 'RAINBOW_ON_INVITATION_ACCEPTED' with data {invitation:Invitation, contact:Contact}: The invitation (from / to) contact is accepted * - 'RAINBOW_ON_INVITATIONS_LIST_UPDATED' with no data: The invitation list (received/send) is updated * @param handler - The callback function that will be called when events are received * @param eventNames - EventName, or list of EventName to subscribe to */ subscribe(handler: (event: RBEvent) => any, eventNames?: UserNetworkServiceEvents | UserNetworkServiceEvents[]): Subscription; /** * Returns a list of users that are in the network of the connected user * @param includePersonnalDirectoryUsers - f true, the API will return all users in the user's network including all his personnal directory contacts * @returns an array of users found or an empty array if no user has been found */ getUsers(includePersonnalDirectoryUsers?: boolean): User[]; /** * Remove given user from our network. This means that the user will no longer receive any presence updates for this user etc. * @param user - the contact to be removed from our network */ removeUser(user: User): Promise; /** * Returns the list of received invitations for this user */ getReceivedInvitations(): NetworkInvitation[]; /** * Returns the list of send invitations */ getSentInvitations(): NetworkInvitation[]; /** * API used to invite a Rainbow user to join our network. In the case of same company, the invitation will be auto-accepted by the distant; * In case of different companies, this will send an invitation and email to the distant user; * This API will send an 'update' event on the contact object * @param user - The rainbow user to invite * @param customMessage - A custom message that will be send to the distant user via email * */ sendInvitation(user: User, customMessage?: string): Promise; /** * API used to send invitation to join rainbow to an email. * @param email - The email to send the invitation * @param customMessage - A custom message that will be send to the distant user via email */ sendInvitationByEmail(email: string, customMessage?: string): Promise; /** * API used to send invitations to list of emails; Limit is 100 emails * @param emails - The list of emails to send the invitations; Limit is 100 emails */ sendBulkInvitations(emails: string[]): Promise; /** * API used to resend an invitations * @param invitation - The invitation to resend */ reSendInvitation(invitation: NetworkInvitation): Promise; /** * API used to cancel a send invitation (which is not accepted yet) * @param invitation - The invitation that we want to cancel */ cancelInvitation(invitation: NetworkInvitation): Promise; /** * API used to accept a received invitation (which is not accepted or rejected yet) * @param invitation - The received invitation that we want to accept */ acceptInvitation(invitation: NetworkInvitation): Promise; /** * API used to decline a received invitation (which is not accepted or rejected yet) * @param invitation - The received invitation that we want to decline */ declineInvitation(invitation: NetworkInvitation): Promise; } /** @internal */ export declare class UserNetworkServiceRB extends Service implements UserNetworkService { static getInstance(): UserNetworkServiceRB; static build(): UserNetworkServiceRB; private logger; private authService; private xmppService; private contactService; private settingsService; private errorHelperService; private subscription; private xmppHandler; private rxSubject; private portalURL; private receivedInvitations; private sentInvitations; private acceptedInvitationsArray; private sentInvitationsArray; private receivedInvitationsArray; private invitationsToUpdate; private constructor(); /************************************************************/ /** LIFECYCLE STUFF */ /************************************************************/ start(contactService: ContactService): void; stop(): void; reconnect(): Promise; private updateInvitationsFromServer; subscribe(handler: (event: RBEvent) => any, eventNames?: UserNetworkServiceEvents | UserNetworkServiceEvents[]): Subscription; sendEvent(name: UserNetworkServiceEvents, data?: any): void; attachHandlers(): void; private onInvitationsUpdate; private handleReceivedInvitation; private handleSentInvitation; private updateReceivedInvitationsArray; private updateSentInvitationsArray; private getServerInvitation; private updateContactInvitationStatus; private sortInvitationArray; private getAllReceivedInvitations; private getAllSentInvitations; /** * Returns a list of users that are in the network of the connected user * @param includePersonalDirectoryUsers - If true, the API will return all users in the user's network including all his personnal directory contacts * @returns an array of users found or an empty array if no user has been found */ getUsers(includePersonalDirectoryUsers?: boolean): User[]; /** * Remove given user from our network. This means that the user will no longer receive any presence updates for this user etc. * @param user - the contact to be removed from our network * @returns Resolve if success */ removeUser(user: User): Promise; getReceivedInvitations(): NetworkInvitation[]; getSentInvitations(): NetworkInvitation[]; sendInvitation(contact: Contact, customMessage?: string): Promise; sendInvitationByEmail(email: string, customMessage?: string): Promise; cancelInvitation(invitation: NetworkInvitation): Promise; sendBulkInvitations(emails: any[]): Promise; acceptInvitation(invitation: NetworkInvitation): Promise; declineInvitation(invitation: NetworkInvitation): Promise; /** * API used to resend an invitations * @param invitation - The invitation to resend */ reSendInvitation(invitation: NetworkInvitation): Promise; } //# sourceMappingURL=userNetwork.service.d.ts.map