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 / deleteAccount.js
Size: Mime:
var fetch = require('fetch-everywhere');
var responseHelpers = require('./helpers/fetch');
var buildUrl = require('./helpers/buildUrl');

/**
 * Delete a Zoom Account from the Doodle user.
 *
 * @param {Number} accountId - The zoom account id
 * @param {String} token - The user's access-token
 * @param {String} baseUrl
 * @returns {*} Promise
 */
function deleteAccount(accountId, token, baseUrl) {
  var url;
  var fetchOptions;

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

  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/accounts/' + accountId);

  fetchOptions = {
    method: 'DELETE',
    mode: 'cors',
    credentials: 'include',
    headers: {
      Accept: 'application/json',
      'Access-Token': token,
    },
  };

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

module.exports = deleteAccount;