define('application/models/production/recordings/series', [
'rofl/models/api/abstract',
'rofl/lib/utils',
'application/models/configuration',
'application/managers/channel'
], function (
Abstract,
Utils,
KPNConfig,
ChannelManager
) {
'use strict';
var channelManager = ChannelManager.getInstance(),
channels = channelManager.getChannelMap();
return Abstract.extend({
/**
* Resolves the endpoint.
*
* @returns {string} - Endpoint.
*/
resolveEndpoint: function () {
return '101/1.2.0/A/nld/smarttv/kpn/TRAY/USER/RECORDING/SERIES'
+ '?sortOrder=desc&orderBy=StartTime&maxResults=9999&from=0&to=9999'
+ '&filter_channelIds=' + channelManager.getChannelMap();
},
/**
* Transforms the response.
*
* @param {Object} response - The response.
* @returns {Object} Result.
*/
transformFrom: function (response) {
var data = Utils.getNested(response, 'resultObj', 'containers'),
result = {
items: []
};
Utils.each(data, function (item) {
if (channels.indexOf(item.metadata.channelId) >= 0) {
result.items.push(item);
}
});
return result;
},
/**
* Validates the response.
*
* @param {Object} response - The response.
* @returns {boolean} - True if valid.
*/
validateResponse: function (response) {
return Utils.getNested(response, 'resultCode') === KPNConfig.RESPONSE_CODES.OK;
}
});
});