UNPKG

@kontent-ai/management-sdk

Version:
44 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.contentItemsMapper = exports.ContentItemsMapper = void 0; const models_1 = require("../models"); const responses_1 = require("../responses"); const base_mapper_1 = require("./base-mapper"); class ContentItemsMapper extends base_mapper_1.BaseMapper { mapListingItemsResponse(response) { const pagination = super.mapPagination(response.data.pagination); const items = response.data.items.map((m) => this.mapContentItem(m)); return new responses_1.ContentItemResponses.ContentItemsResponse(super.mapResponseDebug(response), response.data, { pagination: pagination, items: items }); } mapViewContentItemResponse(response) { return new responses_1.ContentItemResponses.ViewContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data)); } mapAddContentItemResponse(response) { return new responses_1.ContentItemResponses.AddContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data)); } mapUpdateContentItemResponse(response) { return new responses_1.ContentItemResponses.UpdateContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data)); } mapUpsertContentItemResponse(response) { return new responses_1.ContentItemResponses.UpsertContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data)); } mapContentItem(rawItem) { return new models_1.ContentItemModels.ContentItem({ codename: rawItem.codename, externalId: rawItem.external_id, id: rawItem.id, lastModified: new Date(rawItem.last_modified), name: rawItem.name, type: rawItem.type, collection: super.mapReference(rawItem.collection), spaces: rawItem.spaces.map((m) => super.mapIdReference(m)), _raw: rawItem }); } } exports.ContentItemsMapper = ContentItemsMapper; exports.contentItemsMapper = new ContentItemsMapper(); //# sourceMappingURL=content-items-mapper.js.map