Source: models/production/userdata.js

define('application/models/production/userdata', [
    'rofl/models/api/abstract',
    'rofl/lib/utils',
    'application/constants'
], function (
    Abstract,
    Utils,
    Constants
) {
    'use strict';

    var baseUrl = '101/1.2.0/A/nld/smarttv/kpn/CONTENT/USERDATA',
        ENDPOINTS = {
        '_VOD': '/PROGRAM/{{contentId}}',
        'PROGRAM': '/PROGRAM/{{contentId}}',
        'VOD': '/VOD/{{contentId}}',
        'VOD_MOVIE': '/VOD/{{contentId}}',
        'LIVE': '/LIVE/{{contentId}}',
        'RESTART': '/LIVE/{{contentId}}',
        'RECORDING': '/RECORDING/{{contentId}}',
        'MOVIE': '/VOD/{{contentId}}'
    };

    return Abstract.extend({

        /**
         * Resolves the endpoint.
         *
         * @param {Object} params - The parameters.
         * @returns {string} - The endpoint.
         */
        resolveEndpoint: function (params) {
            var endpoint = baseUrl,
                contentData = params && params.data,
                type = contentData && contentData.getContentType() || params.contentType,
                contentId = contentData && contentData.getId() || params.contentId;

            if (type === Constants.RECORDING_EPISODE_VIDEO_TYPE) {
                contentId = contentData && contentData.getRecordingId() || contentId;
            }

            if (!type || !contentId) {
                throw 'Missing userdata parameters';
            }

            endpoint += ENDPOINTS[type];

            return Utils.formatTemplate(endpoint, {
                contentId: contentId
            });
        },

        /**
         * Validates the response.
         *
         * @param {Object} response - The response.
         * @returns {boolean} - True if the response is valid.
         */
        validateResponse: function (response) {
            return !!response && response.resultCode === 'OK';
        }
    });
});