box-node-sdk
Version:
Official SDK for Box Platform APIs
89 lines • 3.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeMetadataTaxonomy = serializeMetadataTaxonomy;
exports.deserializeMetadataTaxonomy = deserializeMetadataTaxonomy;
const metadataTaxonomyLevel_1 = require("./metadataTaxonomyLevel");
const metadataTaxonomyLevel_2 = require("./metadataTaxonomyLevel");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
const json_2 = require("../serialization/json");
const json_3 = require("../serialization/json");
function serializeMetadataTaxonomy(val) {
return {
['id']: val.id,
['key']: val.key,
['displayName']: val.displayName,
['namespace']: val.namespace,
['levels']: val.levels == void 0
? val.levels
: val.levels.map(function (item) {
return (0, metadataTaxonomyLevel_1.serializeMetadataTaxonomyLevel)(item);
}),
};
}
function deserializeMetadataTaxonomy(val) {
if (!(0, json_3.sdIsMap)(val)) {
throw new errors_1.BoxSdkError({
message: 'Expecting a map for "MetadataTaxonomy"',
});
}
if (val.id == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "id" of type "MetadataTaxonomy" to be defined',
});
}
if (!(0, json_1.sdIsString)(val.id)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "id" of type "MetadataTaxonomy"',
});
}
const id = val.id;
if (!(val.key == void 0) && !(0, json_1.sdIsString)(val.key)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "key" of type "MetadataTaxonomy"',
});
}
const key = val.key == void 0 ? void 0 : val.key;
if (val.displayName == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "displayName" of type "MetadataTaxonomy" to be defined',
});
}
if (!(0, json_1.sdIsString)(val.displayName)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "displayName" of type "MetadataTaxonomy"',
});
}
const displayName = val.displayName;
if (val.namespace == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "namespace" of type "MetadataTaxonomy" to be defined',
});
}
if (!(0, json_1.sdIsString)(val.namespace)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "namespace" of type "MetadataTaxonomy"',
});
}
const namespace = val.namespace;
if (!(val.levels == void 0) && !(0, json_2.sdIsList)(val.levels)) {
throw new errors_1.BoxSdkError({
message: 'Expecting array for "levels" of type "MetadataTaxonomy"',
});
}
const levels = val.levels == void 0
? void 0
: (0, json_2.sdIsList)(val.levels)
? val.levels.map(function (itm) {
return (0, metadataTaxonomyLevel_2.deserializeMetadataTaxonomyLevel)(itm);
})
: [];
return {
id: id,
key: key,
displayName: displayName,
namespace: namespace,
levels: levels,
};
}
//# sourceMappingURL=metadataTaxonomy.js.map