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.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. declare var $: Function;
  2. /**
  3. * Sends an ajax request to a directory service.
  4. *
  5. * @param {string} serviceUrl - The service to query.
  6. * @param {string} jwt - The jwt token to pass to the search service.
  7. * @param {string} text - Text to search.
  8. * @returns {Promise} - The promise created by the request.
  9. */
  10. export function searchPeople(serviceUrl, jwt, text) {
  11. const queryTypes = '["conferenceRooms","user","room"]';
  12. return new Promise((resolve, reject) => {
  13. $.getJSON(`${serviceUrl}?query=${encodeURIComponent(text)}
  14. &queryTypes=${queryTypes}&jwt=${jwt}`,
  15. response => resolve(response)
  16. ).fail((jqxhr, textStatus, error) =>
  17. reject(error)
  18. );
  19. });
  20. }
  21. /**
  22. * Sends a post request to an invite service.
  23. *
  24. * @param {string} inviteServiceUrl - The invite service that generates the
  25. * invitation.
  26. * @param {string} inviteUrl - The url to the conference.
  27. * @param {string} jwt - The jwt token to pass to the search service.
  28. * @param {Immutable.List} inviteItems - The list of items to invite.
  29. * @returns {Promise} - The promise created by the request.
  30. */
  31. export function invitePeople(inviteServiceUrl, inviteUrl, jwt, inviteItems) { // eslint-disable-line max-params, max-len
  32. return new Promise((resolve, reject) => {
  33. $.post(`${inviteServiceUrl}?token=${jwt}`,
  34. JSON.stringify({
  35. 'invited': inviteItems,
  36. 'url': inviteUrl }),
  37. response => resolve(response),
  38. 'json')
  39. .fail((jqxhr, textStatus, error) =>
  40. reject(error)
  41. );
  42. });
  43. }