// Define VimeoAjaxRequest
var VimeoAjaxRequest = (function () {
  var fetchVideoData = function(vimeo_id, callback) {
    Zepto.ajax(
        {
          url: VimeoAjaxRequest.vimeoVideoAPIUrl(vimeo_id),
          dataType: 'jsonp',
          type: 'GET',
          cache: false,
          success: function (result) {
            callback(result[0]);
          }
        }
    );
  }

  return {
    fetchVideoData : fetchVideoData,

    vimeoVideoAPIUrl: function(vimeo_id) {
      return 'http://vimeo.com/api/v2/video/' + vimeo_id + '.json';
    },

    getThumbnail: function(vimeo_id) {
      VimeoAjaxRequest.fetchVideoData(vimeo_id, function(response) {
        return response.thumbnail_medium;
      });
    }
  }
})();
// Define VimeoRequest
var VimeoRequest = (function () {
  var getData = function(type, id, callback) {
    Zepto.ajax(
        {
          url: vimeoAPIRequestURL(type, id),
          dataType: 'jsonp',
          type: 'GET',
          cache: false,
          success: function (result) {
            callback(result);
          }
        }
    );
  }

  var vimeoAPIRequestURL = function(type, id) {
    switch (type) {
      case 'user':
        return 'http://vimeo.com/api/v2/' + id + '/videos.json';
        break;
      case 'album':
        return 'http://vimeo.com/api/v2/album/' + id + '/videos.json';
        break;
      default:
        break;
    }
  }

  return {
    getData : getData
  }
})();
Simplify the request to Vimeo. We can either make a user request or album request.
Simplify the request to Vimeo. We can either make a user request or album request.
