(function(){ 'use strict'; angular.module('laz.videoLibrary') .factory('videoApi', [ 'createApi', function(createApi) { var videoApi = createApi('/api/videoLibrary/'); var VIEW_TYPES = { CARD: 'card', PLAYABLE: 'playable' }; var FEATURED_SENTINEL_ID = 'featured'; return { findById: findById, findCategories: findCategories, VIEW_TYPES: VIEW_TYPES, FEATURED_SENTINEL_ID: FEATURED_SENTINEL_ID }; function findById(videoId, view){ view = view || VIEW_TYPES.PLAYABLE; if(isNaN(parseInt(videoId)) && videoId !== FEATURED_SENTINEL_ID){ throw Error('videoId must be an integer value'); } return videoApi.get('videos/' + videoId, { params: { view_type: view } }); } function findCategories(view){ view = view || VIEW_TYPES.PLAYABLE; return videoApi.get('videoCategories', { params: { view_type: view } }); } } ]); })();