var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// <reference path="WidgetDetails.ts" /> /// <reference path="../Request.ts" /> /// <reference path="../../base/BaseClass.ts" /> var econda; (function (econda) { var recengine; (function (recengine) { var response; (function (response) { var WidgetDetails = econda.recengine.response.WidgetDetails; /** * Recommendations response. Contains recommendet products and optional widget details. Available product fields can be configured in cross sell user interface. * * var recommendations = response.getProducts(); * for(var i=0; i<response.length; i++) { * console.log(recommendations[i].id); * } * * @class econda.recengine.response.Response * @extends econda.base.BaseClass */ var Response = (function (_super) { __extends(Response, _super); function Response(cfg) { _super.call(this); /** * True if there was an error and this response contains no data * @cfg {Boolean} isError * @accessor */ this._isError = false; /** * Reference to request * @cfg {econda.recengine.Request} request * @accessor */ this._request = null; /** * Index of first result item. Starts with 0 * @cfg {Number} [startIndex=0] * @accessor */ this._startIndex = 0; /** * Index of last product in result list. * @cfg {Number} endIndex; * @accessor */ this._endIndex = null; /** * List of recommendations * @cfg {Object[]} products * @accessor */ this.products = []; /** * Widget meta data like title, ... * @cfg {econda.recengine.response.WidgetDetails} widgetDetails * @accessor */ this.widgetDetails = null; if (cfg instanceof Response) { return cfg; } this.initConfig(cfg); } Response.prototype.getIsError = function () { return this._isError; }; Response.prototype.setIsError = function (isError) { this._isError = isError; return this; }; Response.prototype.getRequest = function () { return this._request; }; Response.prototype.setRequest = function (request) { this._request = request; return this; }; Response.prototype.getStartIndex = function () { return this._startIndex; }; Response.prototype.setStartIndex = function (index) { this._startIndex = index; return this; }; Response.prototype.getEndIndex = function () { return this._endIndex; }; Response.prototype.setEndIndex = function (index) { this._endIndex = index; return this; }; Response.prototype.getProducts = function () { return this.products; }; Response.prototype.setProducts = function (products) { this.products = products; return this; }; Response.prototype.setWidgetDetails = function (widgetDetails) { this.widgetDetails = new WidgetDetails(widgetDetails); }; Response.prototype.getWidgetDetails = function (returnEmptyObject) { if (returnEmptyObject === void 0) { returnEmptyObject = false; } if (returnEmptyObject && this.widgetDetails === null) { return new WidgetDetails(); } return this.widgetDetails; }; return Response; }(econda.base.BaseClass)); response.Response = Response; // end of class })(response = recengine.response || (recengine.response = {})); })(recengine = econda.recengine || (econda.recengine = {})); })(econda || (econda = {})); // end of module