/*! * Copyright 2022, Staffbase GmbH and contributors. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { BranchInformation, ColorTheme, IntegrationInformation, IntegrationType, SBUserProfile, UserListRequestQuery, UserListResponse } from './widget-api-types'; /** * Widget API class. * * A class providing access to additional information about the Staffbase ecosystem for widgets. */ export interface WidgetApi { /** * Call to retrieve the color theme of the app. Since this theme definitions * are currently redesigned, this method is called legacy. * * @returns An object containing the color theme data is returned. */ getLegacyAppTheme(): ColorTheme; /** * Call to retrieve the user profile of the current or a specific user. * * @param userId User ID to lookup for; leave blank to retrieve current user * @returns A promise containing the SBUserProfile is returned. In case of an error, * the promise is rejected. */ getUserInformation(userId?: string): Promise; /** * Call to retrieve a user profile by its external ID. * * @param externalId An external ID of the user that shall be returned * @returns A promise containing the SBUserProfile is returned. In case of an error, * the promise is rejected. */ getUserInformationByExternalId(externalId: string): Promise; /** * Call to retrieve a list of users determined by the query object. * * @param query Adjust limit, offset, filter, and sorting for the request * @returns A promise containing the UserListResponse is returned. In case of an error, * the promise is rejected. */ getUserList(query: UserListRequestQuery): Promise; /** * Call to retrieve a valid token to access the Microsoft API. Includes a time value to * refresh the token. * * @param type The name of the integration. ("ms365") * * @returns A promise containing the IntegrationInformation is returned. If the user session is * not existing, the status is set to 'loggedOut' and the token is null. Additionally if the * integration is not configured the status returns 'unavailable'. * * In case of an error, the promise is rejected. */ getIntegration(type: IntegrationType): Promise; /** * Call to retrieve information about the current branch. * * @returns An object containing the branch information. */ getBranchInformation(): BranchInformation; }