Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/zoom-client / src / setGlobalZoom.js
Size: Mime:
var fetch = require('fetch-everywhere');
var responseHelpers = require('./helpers/fetch');
var buildUrl = require('./helpers/buildUrl');

/**
 * Set the global toggle to enable or disable a connected Zoom account.
 *
 * `PUT` /api/v2.0/users/me
 *
 * @param {Boolean} zoomIntegrationEnabled - the value you want to toggle to
 * @param {String} token - the user's access-token
 * @param {String} baseUrl
 * @returns {*} Promise
 */
function setGlobalZoom(zoomIntegrationEnabled, token, baseUrl) {
  var fetchOptions;
  var url;

  if (typeof zoomIntegrationEnabled !== 'boolean') {
    throw new TypeError('zoomIntegrationEnabled param must be a boolean, got ' + typeof token);
  }

  if (typeof token !== 'string') {
    throw new TypeError('token param must be a string, got ' + typeof token);
  }

  if (typeof baseUrl !== 'string') {
    throw new TypeError('baseUrl param must be a string, got ' + typeof baseUrl);
  }

  url = buildUrl(baseUrl, '/api/svc-zoom-integration/v1.0/me');

  fetchOptions = {
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
      'Access-Token': token,
    },
    method: 'PATCH',
    mode: 'cors',
    credentials: 'include',
    body: JSON.stringify({
      zoomIntegrationEnabled: zoomIntegrationEnabled,
    }),
  };

  return fetch(url, fetchOptions)
    .then(responseHelpers.responseHandler)
    .catch(responseHelpers.errorHandler);
}

module.exports = setGlobalZoom;