123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- // @flow
-
- import { doGetJSON } from '../base/util';
- import { isInBreakoutRoom } from '../breakout-rooms/functions';
-
- /**
- * Determines whether Salesforce is enabled for the current conference.
- *
- * @param {Function|Object} state - The redux store, the redux
- * {@code getState} function, or the redux state itself.
- * @returns {boolean}
- */
- export const isSalesforceEnabled = (state: Function | Object) => {
- const { salesforceUrl } = state['features/base/config'];
- const isBreakoutRoom = isInBreakoutRoom(state);
-
- return Boolean(salesforceUrl) && !isBreakoutRoom;
- };
-
- /**
- * Fetches the Salesforce records that were most recently interacted with.
- *
- * @param {string} url - The endpoint for the session records.
- * @param {string} jwt - The JWT needed for authentication.
- * @returns {Promise<any>}
- */
- export async function getRecentSessionRecords(
- url: string,
- jwt: string
- ) {
- return doGetJSON(`${url}/records/recents`, true, {
- headers: {
- 'Authorization': `Bearer ${jwt}`
- }
- });
- }
-
- /**
- * Fetches the Salesforce records that match the search criteria.
- *
- * @param {string} url - The endpoint for the session records.
- * @param {string} jwt - The JWT needed for authentication.
- * @param {string} text - The search term for the session record to find.
- * @returns {Promise<any>}
- */
- export async function searchSessionRecords(
- url: string,
- jwt: string,
- text: string
- ) {
- return doGetJSON(`${url}/records?text=${text}`, true, {
- headers: {
- 'Authorization': `Bearer ${jwt}`
- }
- });
- }
-
- /**
- * Fetches the Salesforce record details from the server.
- *
- * @param {string} url - The endpoint for the record details.
- * @param {string} jwt - The JWT needed for authentication.
- * @param {Object} item - The item for which details are being retrieved.
- * @returns {Promise<any>}
- */
- export async function getSessionRecordDetails(
- url: string,
- jwt: string,
- item: Object
- ) {
- const fullUrl = `${url}/records/${item.id}?type=${item.type}`;
-
- return doGetJSON(fullUrl, true, {
- headers: {
- 'Authorization': `Bearer ${jwt}`
- }
- });
- }
-
- /**
- * Executes the meeting linking.
- *
- * @param {string} url - The endpoint for meeting linking.
- * @param {string} jwt - The JWT needed for authentication.
- * @param {string} sessionId - The ID of the meeting session.
- * @param {Object} body - The body of the request.
- * @returns {Object}
- */
- export async function executeLinkMeetingRequest(
- url: string,
- jwt: string,
- sessionId: String,
- body: Object
- ) {
- const fullUrl = `${url}/sessions/${sessionId}/records/${body.id}`;
- const res = await fetch(fullUrl, {
- method: 'PUT',
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': `Bearer ${jwt}`
- },
- body: JSON.stringify(body)
- });
-
- const json = await res.json();
-
- return res.ok ? json : Promise.reject(json);
- }
|