box-node-sdk
Version:
Official SDK for Box Platform APIs
87 lines • 3.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeAiExtractSubField = serializeAiExtractSubField;
exports.deserializeAiExtractSubField = deserializeAiExtractSubField;
const aiExtractFieldOption_1 = require("./aiExtractFieldOption.js");
const aiExtractFieldOption_2 = require("./aiExtractFieldOption.js");
const errors_1 = require("../box/errors.js");
const json_1 = require("../serialization/json.js");
const json_2 = require("../serialization/json.js");
const json_3 = require("../serialization/json.js");
function serializeAiExtractSubField(val) {
return {
['key']: val.key,
['description']: val.description,
['displayName']: val.displayName,
['prompt']: val.prompt,
['type']: val.type,
['options']: val.options == void 0
? val.options
: val.options.map(function (item) {
return (0, aiExtractFieldOption_1.serializeAiExtractFieldOption)(item);
}),
};
}
function deserializeAiExtractSubField(val) {
if (!(0, json_3.sdIsMap)(val)) {
throw new errors_1.BoxSdkError({
message: 'Expecting a map for "AiExtractSubField"',
});
}
if (val.key == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "key" of type "AiExtractSubField" to be defined',
});
}
if (!(0, json_1.sdIsString)(val.key)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "key" of type "AiExtractSubField"',
});
}
const key = val.key;
if (!(val.description == void 0) && !(0, json_1.sdIsString)(val.description)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "description" of type "AiExtractSubField"',
});
}
const description = val.description == void 0 ? void 0 : val.description;
if (!(val.displayName == void 0) && !(0, json_1.sdIsString)(val.displayName)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "displayName" of type "AiExtractSubField"',
});
}
const displayName = val.displayName == void 0 ? void 0 : val.displayName;
if (!(val.prompt == void 0) && !(0, json_1.sdIsString)(val.prompt)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "prompt" of type "AiExtractSubField"',
});
}
const prompt = val.prompt == void 0 ? void 0 : val.prompt;
if (!(val.type == void 0) && !(0, json_1.sdIsString)(val.type)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "type" of type "AiExtractSubField"',
});
}
const type = val.type == void 0 ? void 0 : val.type;
if (!(val.options == void 0) && !(0, json_2.sdIsList)(val.options)) {
throw new errors_1.BoxSdkError({
message: 'Expecting array for "options" of type "AiExtractSubField"',
});
}
const options = val.options == void 0
? void 0
: (0, json_2.sdIsList)(val.options)
? val.options.map(function (itm) {
return (0, aiExtractFieldOption_2.deserializeAiExtractFieldOption)(itm);
})
: [];
return {
key: key,
description: description,
displayName: displayName,
prompt: prompt,
type: type,
options: options,
};
}
//# sourceMappingURL=aiExtractSubField.js.map