UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

36 lines 1.54 kB
import { FieldMapper } from '../mappers'; var ItemMapper = /** @class */ (function () { function ItemMapper(config, richTextHtmlParser) { this.config = config; this.richTextHtmlParser = richTextHtmlParser; this.fieldMapper = new 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; }()); export { ItemMapper }; //# sourceMappingURL=item.mapper.js.map