You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // @flow
  2. /**
  3. * Sends a request for retrieving jaas customer details.
  4. *
  5. * @param {Object} reqData - The request info.
  6. * @param {string} reqData.appId - The client appId.
  7. * @param {string} reqData.baseUrl - The base url for the request.
  8. * @param {string} reqData.jwt - The JWT token.
  9. * @returns {void}
  10. */
  11. export async function sendGetDetailsRequest({ appId, baseUrl, jwt }: {
  12. appId: string,
  13. baseUrl: string,
  14. jwt: string,
  15. }) {
  16. const fullUrl = `${baseUrl}/v1/customers/${encodeURIComponent(appId)}`;
  17. const headers = {
  18. 'Authorization': `Bearer ${jwt}`
  19. };
  20. try {
  21. const res = await fetch(fullUrl, {
  22. method: 'GET',
  23. headers
  24. });
  25. if (res.ok) {
  26. return res.json();
  27. }
  28. throw new Error('Request not successful');
  29. } catch (err) {
  30. throw new Error(err);
  31. }
  32. }
  33. /**
  34. * Returns the billing id for vpaas meetings.
  35. *
  36. * @param {Object} state - The state of the app.
  37. * @param {string} feature - Feature to be looked up for disable state.
  38. * @returns {boolean}
  39. */
  40. export function isFeatureDisabled(state: Object, feature: string) {
  41. return state['features/jaas'].disabledFeatures.includes(feature);
  42. }