import Common from '../../common/Common.js';

export default {

  /**
     * 是否有权限接收呼叫
     */
  canReceiveCall: function(){
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL('ChatVideoResource/canReceiveCall'),
        type: 'get',
        contentType: 'application/json',
        dataType: 'json',
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

    
  /**
     * 查询所有的连接
     */
  listConnection: function(){
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL('ChatVideoResource/listConnection'),
        type: 'get',
        contentType: 'application/json',
        dataType: 'json',
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },
};