import { BoxSdkError } from '../box/errors.js';
import { sdIsString } from '../serialization/json.js';
import { sdIsMap } from '../serialization/json.js';
export function serializeAiTaxonomyReferenceTypeField(val) {
    return val;
}
export function deserializeAiTaxonomyReferenceTypeField(val) {
    if (val == 'taxonomy') {
        return val;
    }
    throw new BoxSdkError({
        message: "Can't deserialize AiTaxonomyReferenceTypeField",
    });
}
export function serializeAiTaxonomyReference(val) {
    return {
        ['type']: val.type == void 0
            ? val.type
            : serializeAiTaxonomyReferenceTypeField(val.type),
        ['taxonomy_key']: val.taxonomyKey,
        ['namespace']: val.namespace,
    };
}
export function deserializeAiTaxonomyReference(val) {
    if (!sdIsMap(val)) {
        throw new BoxSdkError({
            message: 'Expecting a map for "AiTaxonomyReference"',
        });
    }
    const type = val.type == void 0
        ? void 0
        : deserializeAiTaxonomyReferenceTypeField(val.type);
    if (!(val.taxonomy_key == void 0) && !sdIsString(val.taxonomy_key)) {
        throw new BoxSdkError({
            message: 'Expecting string for "taxonomy_key" of type "AiTaxonomyReference"',
        });
    }
    const taxonomyKey = val.taxonomy_key == void 0 ? void 0 : val.taxonomy_key;
    if (!(val.namespace == void 0) && !sdIsString(val.namespace)) {
        throw new BoxSdkError({
            message: 'Expecting string for "namespace" of type "AiTaxonomyReference"',
        });
    }
    const namespace = val.namespace == void 0 ? void 0 : val.namespace;
    return {
        type: type,
        taxonomyKey: taxonomyKey,
        namespace: namespace,
    };
}
//# sourceMappingURL=aiTaxonomyReference.js.map