box-node-sdk
Version:
Official SDK for Box Platform APIs
122 lines • 4.35 kB
JavaScript
import { serializeDateTime } from '../../internal/utils.js';
import { deserializeDateTime } from '../../internal/utils.js';
import { BoxSdkError } from '../../box/errors.js';
import { sdIsString } from '../../serialization/json.js';
import { sdIsMap } from '../../serialization/json.js';
export function serializeShieldRuleItemV2025R0TypeField(val) {
return val;
}
export function deserializeShieldRuleItemV2025R0TypeField(val) {
if (val == 'shield_rule') {
return val;
}
throw new BoxSdkError({
message: "Can't deserialize ShieldRuleItemV2025R0TypeField",
});
}
export function serializeShieldRuleItemV2025R0PriorityField(val) {
return val;
}
export function deserializeShieldRuleItemV2025R0PriorityField(val) {
if (val == 'informational') {
return val;
}
if (val == 'low') {
return val;
}
if (val == 'medium') {
return val;
}
if (val == 'high') {
return val;
}
if (val == 'critical') {
return val;
}
if (sdIsString(val)) {
return val;
}
throw new BoxSdkError({
message: "Can't deserialize ShieldRuleItemV2025R0PriorityField",
});
}
export function serializeShieldRuleItemV2025R0(val) {
return {
['id']: val.id,
['type']: val.type == void 0
? val.type
: serializeShieldRuleItemV2025R0TypeField(val.type),
['rule_category']: val.ruleCategory,
['name']: val.name,
['description']: val.description,
['priority']: val.priority == void 0
? val.priority
: serializeShieldRuleItemV2025R0PriorityField(val.priority),
['created_at']: val.createdAt == void 0
? val.createdAt
: serializeDateTime(val.createdAt),
['modified_at']: val.modifiedAt == void 0
? val.modifiedAt
: serializeDateTime(val.modifiedAt),
};
}
export function deserializeShieldRuleItemV2025R0(val) {
if (!sdIsMap(val)) {
throw new BoxSdkError({
message: 'Expecting a map for "ShieldRuleItemV2025R0"',
});
}
if (!(val.id == void 0) && !sdIsString(val.id)) {
throw new BoxSdkError({
message: 'Expecting string for "id" of type "ShieldRuleItemV2025R0"',
});
}
const id = val.id == void 0 ? void 0 : val.id;
const type = val.type == void 0
? void 0
: deserializeShieldRuleItemV2025R0TypeField(val.type);
if (!(val.rule_category == void 0) && !sdIsString(val.rule_category)) {
throw new BoxSdkError({
message: 'Expecting string for "rule_category" of type "ShieldRuleItemV2025R0"',
});
}
const ruleCategory = val.rule_category == void 0 ? void 0 : val.rule_category;
if (!(val.name == void 0) && !sdIsString(val.name)) {
throw new BoxSdkError({
message: 'Expecting string for "name" of type "ShieldRuleItemV2025R0"',
});
}
const name = val.name == void 0 ? void 0 : val.name;
if (!(val.description == void 0) && !sdIsString(val.description)) {
throw new BoxSdkError({
message: 'Expecting string for "description" of type "ShieldRuleItemV2025R0"',
});
}
const description = val.description == void 0 ? void 0 : val.description;
const priority = val.priority == void 0
? void 0
: deserializeShieldRuleItemV2025R0PriorityField(val.priority);
if (!(val.created_at == void 0) && !sdIsString(val.created_at)) {
throw new BoxSdkError({
message: 'Expecting string for "created_at" of type "ShieldRuleItemV2025R0"',
});
}
const createdAt = val.created_at == void 0 ? void 0 : deserializeDateTime(val.created_at);
if (!(val.modified_at == void 0) && !sdIsString(val.modified_at)) {
throw new BoxSdkError({
message: 'Expecting string for "modified_at" of type "ShieldRuleItemV2025R0"',
});
}
const modifiedAt = val.modified_at == void 0 ? void 0 : deserializeDateTime(val.modified_at);
return {
id: id,
type: type,
ruleCategory: ruleCategory,
name: name,
description: description,
priority: priority,
createdAt: createdAt,
modifiedAt: modifiedAt,
};
}
//# sourceMappingURL=shieldRuleItemV2025R0.js.map