import IOrg from '../../Interfaces/Org'; import ISpace from '../../Interfaces/Space'; import User from '../User'; import Space from '../Space'; import IUser from '../../Interfaces/User/IUser'; import { IRefObject } from '../../services/database/DatabaseService'; /** * Class Org - Organization * Represent an organization created by a user. An organization can have multiple space. */ export default class Org { private _org; private _org_ref; private _user?; /** * Organization constructor * @param org Organization to construct * @param org_ref Reference to the organization * @param user Authfificated user */ constructor(org: IOrg, org_ref: IRefObject, user: IUser); /** * Update org data. Called on new space/org initialisation. * @param data Partial org data object * @param saveToDatabase Optionnal, defaults to true. */ updateOrgData: (data: Partial, saveToDatabase?: boolean) => Promise; /** * Get a Space : Space by ID * @param space_id Firestore ID of the space to get */ space: (space_id?: string) => Promise; /** * Access authentificated user */ user: () => User; /** * Gets the most up to date user data from db * Sets this._user's value * @return the updated user */ getUpdatedUser: () => Promise; /** * Get the organization properties */ getData: () => IOrg; /** * Get the organization slug - Name without spaces if slug is not set */ getSlug: () => string; /** * Fetch all spaces or the organization. * No query options, query must be done browser side. */ spaces: () => Promise; /** * Create a new space under this organization * @param space Space : Space to create */ addSpace: (space: ISpace) => Promise; getAllReps: () => Promise<{ name: string; rep_id: string; }[]>; getAllUsers: () => Promise; private _fetchDefaultSpace; private _fetchSpace; }