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="./AbstractEvent.ts" /> /// <reference path="./IProductEvent.ts" /> /// <reference path="../context/ProductReference.ts" /> /// <reference path="../context/IProductReferenceConfigOptions.ts" /> /// <reference path="../../serialization/ISerializable.ts" /> var econda; (function (econda) { var recengine; (function (recengine) { var event; (function (event) { var AbstractEvent = econda.recengine.event.AbstractEvent; var ProductReference = econda.recengine.context.ProductReference; /** * Event when visitor adds a product to cart. * @class econda.recengine.event.ProductViewEvent */ var ProductAddToCartEvent = (function (_super) { __extends(ProductAddToCartEvent, _super); function ProductAddToCartEvent(cfg) { _super.call(this); /** * Number of units of referenced product added to cart * @cfg {Number} count * @accessor */ this._count = 1; /** * Reference to product viewed * @cfg {econda.recengine.context.ProductReference} product * @accessor */ this._product = null; if (cfg instanceof ProductAddToCartEvent) { return cfg; } this.initConfig(cfg); } ProductAddToCartEvent.prototype.getCount = function () { return this._count; }; ProductAddToCartEvent.prototype.setCount = function (count) { this._count = +count; }; ProductAddToCartEvent.prototype.getProduct = function () { return this._product; }; ProductAddToCartEvent.prototype.setProduct = function (productReference) { this._product = new ProductReference(productReference); }; ProductAddToCartEvent.prototype.getObjectData = function () { return { className: 'econda.recengine.event.ProductAddToCartEvent', data: { timestamp: this.getTimestamp(), count: this._count, product: this._product } }; }; ProductAddToCartEvent.prototype.setObjectData = function (data) { if (typeof data === 'object' && data !== null) { this.setTimestamp(data.timestamp); this._count = data.count || 1; this._product = data.product || null; } }; ProductAddToCartEvent.TYPE = 'product:add'; return ProductAddToCartEvent; }(AbstractEvent)); event.ProductAddToCartEvent = ProductAddToCartEvent; })(event = recengine.event || (recengine.event = {})); })(recengine = econda.recengine || (econda.recengine = {})); })(econda || (econda = {}));