@kontent-ai/management-sdk
Version:
Official Kontent.ai management SDK
98 lines • 5.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.languageVariantMapper = exports.LanguageVariantMapper = void 0;
const models_1 = require("../models");
const responses_1 = require("../responses");
const base_mapper_1 = require("./base-mapper");
const elements_mapper_1 = require("./elements-mapper");
class LanguageVariantMapper extends base_mapper_1.BaseMapper {
mapUpsertLanguageVariantResponse(response) {
const variant = this.mapLanguageVariant(response.data);
return new responses_1.LanguageVariantResponses.UpsertLanguageVariantResponse(super.mapResponseDebug(response), response.data, variant);
}
mapViewLanguageVariantResponse(response) {
const variant = this.mapLanguageVariant(response.data);
return new responses_1.LanguageVariantResponses.ViewLanguageVariantResponse(super.mapResponseDebug(response), response.data, variant);
}
mapLanguageVariantsOfItemResponse(response) {
const variants = response.data.map((m) => this.mapLanguageVariant(m));
return new responses_1.LanguageVariantResponses.ListLanguageVariantsOfItemResponse(super.mapResponseDebug(response), response.data, {
items: variants
});
}
mapLanguageVariantsByCollectionResponse(response) {
const variants = response.data.variants.map((m) => this.mapLanguageVariant(m));
return new responses_1.LanguageVariantResponses.ListLanguageVariantsByCollectionResponse(super.mapResponseDebug(response), response.data, {
items: variants,
pagination: super.mapPagination(response.data.pagination)
});
}
mapLanguageVariantsBySpaceResponse(response) {
const variants = response.data.variants.map((m) => this.mapLanguageVariant(m));
return new responses_1.LanguageVariantResponses.ListLanguageVariantsBySpaceResponse(super.mapResponseDebug(response), response.data, {
items: variants,
pagination: super.mapPagination(response.data.pagination)
});
}
mapLanguageVariantsOfContentTypeResponse(response) {
const variants = response.data.variants.map((m) => this.mapLanguageVariant(m));
return new responses_1.LanguageVariantResponses.ListLanguageVariantsOfContentTypeResponse(super.mapResponseDebug(response), response.data, {
items: variants,
pagination: super.mapPagination(response.data.pagination)
});
}
mapLanguageVariantsOfContentTypeWithComponentsResponse(response) {
const variants = response.data.variants.map((m) => this.mapLanguageVariantWithComponents(m));
return new responses_1.LanguageVariantResponses.ListLanguageVariantsOfContentTypeWithComponentsResponse(super.mapResponseDebug(response), response.data, {
items: variants,
pagination: super.mapPagination(response.data.pagination)
});
}
mapLanguageVariantWithComponents(rawVariant) {
return new models_1.LanguageVariantModels.ContentItemLanguageWithComponentsVariant({
rawElements: rawVariant.elements,
elements: elements_mapper_1.elementsMapper.mapElements(rawVariant.elements),
item: super.mapReference(rawVariant.item),
language: super.mapReference(rawVariant.language),
lastModified: new Date(rawVariant.last_modified),
dueDate: this.mapDueDate(rawVariant.due_date),
schedule: this.mapSchedule(rawVariant.schedule),
workflow: {
workflowIdentifier: super.mapReference(rawVariant.workflow.workflow_identifier),
stepIdentifier: super.mapReference(rawVariant.workflow.step_identifier)
},
_raw: rawVariant
});
}
mapLanguageVariant(rawVariant) {
return new models_1.LanguageVariantModels.ContentItemLanguageVariant({
elements: elements_mapper_1.elementsMapper.mapElements(rawVariant.elements),
item: super.mapReference(rawVariant.item),
language: super.mapReference(rawVariant.language),
lastModified: new Date(rawVariant.last_modified),
dueDate: this.mapDueDate(rawVariant.due_date),
schedule: this.mapSchedule(rawVariant.schedule),
note: rawVariant.note,
contributors: rawVariant.contributors,
workflow: {
workflowIdentifier: super.mapReference(rawVariant.workflow.workflow_identifier),
stepIdentifier: super.mapReference(rawVariant.workflow.step_identifier)
},
_raw: rawVariant
});
}
mapDueDate(dueDateRaw) {
return dueDateRaw;
}
mapSchedule(scheduleRaw) {
return {
publishDisplayTimezone: scheduleRaw.publish_display_timezone,
publishTime: scheduleRaw.publish_time,
unpublishDisplayTimezone: scheduleRaw.unpublish_display_timezone,
unpublishTime: scheduleRaw.unpublish_time
};
}
}
exports.LanguageVariantMapper = LanguageVariantMapper;
exports.languageVariantMapper = new LanguageVariantMapper();
//# sourceMappingURL=language-variant-mapper.js.map