UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

38 lines 1.6 kB
"use strict"; exports.__esModule = true; var mappers_1 = require("../mappers"); var ItemMapper = /** @class */ (function () { function ItemMapper(config, richTextHtmlParser) { this.config = config; this.richTextHtmlParser = richTextHtmlParser; this.fieldMapper = new mappers_1.FieldMapper(config, richTextHtmlParser); } /** * Maps single item to its proper strongly typed model from the given Cloud response * @param response Cloud response used to map the item * @param queryConfig Query configuration */ ItemMapper.prototype.mapSingleItem = function (response, queryConfig) { return this.mapItem(response.item, response.modular_content, queryConfig); }; /** * Maps multiple items to their strongly typed model from the given Cloud response * @param response Cloud response used to map the item * @param queryConfig Query configuration */ ItemMapper.prototype.mapMultipleItems = function (response, queryConfig) { var that = this; return response.items.map(function (item) { return that.mapItem(item, response.modular_content, queryConfig); }); }; ItemMapper.prototype.mapItem = function (item, modularContent, queryConfig) { if (item == null) { throw Error("Could not map item because its undefined"); } return this.fieldMapper.mapFields(item, modularContent, queryConfig, []); }; return ItemMapper; }()); exports.ItemMapper = ItemMapper; //# sourceMappingURL=item.mapper.js.map