define('application/models/production/entitlement', [
'rofl/models/api/abstract',
'rofl/lib/utils',
'antie/runtimecontext'
], function (
Abstract,
Utils,
RuntimeContext
) {
'use strict';
var deviceId = RuntimeContext.getDevice().getUdid(),
baseUrl = '101/1.2.0/A/nld/smarttv/kpn/CONTENT/USERDATA/ENTITLEMENT',
ENDPOINTS = {
'VOD': '/PROGRAM/{{contentId}}?deviceId={{deviceId}}',
'VOD_MOVIE': '/VOD/{{contentId}}?deviceId={{deviceId}}'
};
return Abstract.extend({
/**
* Resolves the endpoint.
*
* @param {Object} params - The parameters.
* @returns {string} - The endpoint.
*/
resolveEndpoint: function (params) {
var endpoint = baseUrl;
if (!params || !params.type || !params.contentId) {
throw 'Missing userdata parameters';
}
endpoint += ENDPOINTS[params.type];
params.deviceId = deviceId;
return Utils.formatTemplate(endpoint, params);
},
/**
* Validates the response.
*
* @param {Object} response - The response.
* @returns {boolean} - True if the response is valid.
*/
validateResponse: function (response) {
return !!response && response.resultCode === 'OK';
}
});
});