define('application/models/production/detail', [
'application/models/broadcast',
'rofl/models/api/abstract',
'application/models/configuration',
'rofl/lib/utils',
'application/models/production/uibuilder/series'
], function (
Broadcast,
Abstract,
Configuration,
Utils,
Series
) {
'use strict';
return Abstract.extend({
/**
* Resolves the endpoint.
*
* @param {Object} [params] - Parameters. Optional.
* @param {Array} [params.channels] - Channel identifiers. Optional.
* @returns {string} -
*/
resolveEndpoint: function (params) {
var endpoint = '101/1.2.0/A/nld/smarttv/kpn';
if (params && params.endpoint) {
endpoint += params.endpoint;
}
return endpoint;
},
/**
* Transforms API data into the abstract model data.
*
* @param {Object} response - The data object gotten from the API.
* @returns {Object} - The filled model instance.
*/
transformFrom: function (response) {
var data = Utils.getNested(response, 'resultObj', 'containers', '0');
if (data.layout === 'BUNDLE_ITEM') {
return new Series(data);
}
return new Broadcast(data);
},
/**
* Validates the read response.
*
* @param {Object} response - The read response.
* @returns {boolean} - True if valid.
*/
validateReadResponse: function (response) {
return response.resultCode === Configuration.RESPONSE_CODES.OK;
}
});
});