"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetadataTaxonomiesManager = exports.GetMetadataTemplateFieldOptionsHeaders = exports.DeleteMetadataTaxonomyNodeHeaders = exports.UpdateMetadataTaxonomyNodeHeaders = exports.GetMetadataTaxonomyNodeByIdHeaders = exports.CreateMetadataTaxonomyNodeHeaders = exports.GetMetadataTaxonomyNodesHeaders = exports.DeleteMetadataTaxonomyLevelHeaders = exports.AddMetadataTaxonomyLevelHeaders = exports.UpdateMetadataTaxonomyLevelByIdHeaders = exports.CreateMetadataTaxonomyLevelHeaders = exports.DeleteMetadataTaxonomyHeaders = exports.UpdateMetadataTaxonomyHeaders = exports.GetMetadataTaxonomyByKeyHeaders = exports.GetMetadataTaxonomiesHeaders = exports.CreateMetadataTaxonomyHeaders = exports.GetMetadataTemplateFieldOptionsOptionals = exports.DeleteMetadataTaxonomyNodeOptionals = exports.UpdateMetadataTaxonomyNodeOptionals = exports.GetMetadataTaxonomyNodeByIdOptionals = exports.CreateMetadataTaxonomyNodeOptionals = exports.GetMetadataTaxonomyNodesOptionals = exports.DeleteMetadataTaxonomyLevelOptionals = exports.AddMetadataTaxonomyLevelOptionals = exports.UpdateMetadataTaxonomyLevelByIdOptionals = exports.CreateMetadataTaxonomyLevelOptionals = exports.DeleteMetadataTaxonomyOptionals = exports.UpdateMetadataTaxonomyOptionals = exports.GetMetadataTaxonomyByKeyOptionals = exports.GetMetadataTaxonomiesOptionals = exports.CreateMetadataTaxonomyOptionals = void 0;
exports.serializeCreateMetadataTaxonomyRequestBody = serializeCreateMetadataTaxonomyRequestBody;
exports.deserializeCreateMetadataTaxonomyRequestBody = deserializeCreateMetadataTaxonomyRequestBody;
exports.serializeUpdateMetadataTaxonomyRequestBody = serializeUpdateMetadataTaxonomyRequestBody;
exports.deserializeUpdateMetadataTaxonomyRequestBody = deserializeUpdateMetadataTaxonomyRequestBody;
exports.serializeUpdateMetadataTaxonomyLevelByIdRequestBody = serializeUpdateMetadataTaxonomyLevelByIdRequestBody;
exports.deserializeUpdateMetadataTaxonomyLevelByIdRequestBody = deserializeUpdateMetadataTaxonomyLevelByIdRequestBody;
exports.serializeAddMetadataTaxonomyLevelRequestBody = serializeAddMetadataTaxonomyLevelRequestBody;
exports.deserializeAddMetadataTaxonomyLevelRequestBody = deserializeAddMetadataTaxonomyLevelRequestBody;
exports.serializeCreateMetadataTaxonomyNodeRequestBody = serializeCreateMetadataTaxonomyNodeRequestBody;
exports.deserializeCreateMetadataTaxonomyNodeRequestBody = deserializeCreateMetadataTaxonomyNodeRequestBody;
exports.serializeUpdateMetadataTaxonomyNodeRequestBody = serializeUpdateMetadataTaxonomyNodeRequestBody;
exports.deserializeUpdateMetadataTaxonomyNodeRequestBody = deserializeUpdateMetadataTaxonomyNodeRequestBody;
const metadataTaxonomy_1 = require("../schemas/metadataTaxonomy");
const metadataTaxonomies_1 = require("../schemas/metadataTaxonomies");
const metadataTaxonomyLevels_1 = require("../schemas/metadataTaxonomyLevels");
const metadataTaxonomyLevel_1 = require("../schemas/metadataTaxonomyLevel");
const metadataTaxonomyLevel_2 = require("../schemas/metadataTaxonomyLevel");
const metadataTaxonomyNodes_1 = require("../schemas/metadataTaxonomyNodes");
const metadataTaxonomyNode_1 = require("../schemas/metadataTaxonomyNode");
const errors_1 = require("../box/errors");
const network_1 = require("../networking/network");
const fetchOptions_1 = require("../networking/fetchOptions");
const utils_1 = require("../internal/utils");
const utils_2 = require("../internal/utils");
const json_1 = require("../serialization/json");
const json_2 = require("../serialization/json");
const json_3 = require("../serialization/json");
class CreateMetadataTaxonomyOptionals {
    headers = new CreateMetadataTaxonomyHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.CreateMetadataTaxonomyOptionals = CreateMetadataTaxonomyOptionals;
class GetMetadataTaxonomiesOptionals {
    queryParams = {};
    headers = new GetMetadataTaxonomiesHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.queryParams !== undefined) {
            this.queryParams = fields.queryParams;
        }
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetMetadataTaxonomiesOptionals = GetMetadataTaxonomiesOptionals;
class GetMetadataTaxonomyByKeyOptionals {
    headers = new GetMetadataTaxonomyByKeyHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetMetadataTaxonomyByKeyOptionals = GetMetadataTaxonomyByKeyOptionals;
class UpdateMetadataTaxonomyOptionals {
    headers = new UpdateMetadataTaxonomyHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.UpdateMetadataTaxonomyOptionals = UpdateMetadataTaxonomyOptionals;
class DeleteMetadataTaxonomyOptionals {
    headers = new DeleteMetadataTaxonomyHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.DeleteMetadataTaxonomyOptionals = DeleteMetadataTaxonomyOptionals;
class CreateMetadataTaxonomyLevelOptionals {
    headers = new CreateMetadataTaxonomyLevelHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.CreateMetadataTaxonomyLevelOptionals = CreateMetadataTaxonomyLevelOptionals;
class UpdateMetadataTaxonomyLevelByIdOptionals {
    headers = new UpdateMetadataTaxonomyLevelByIdHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.UpdateMetadataTaxonomyLevelByIdOptionals = UpdateMetadataTaxonomyLevelByIdOptionals;
class AddMetadataTaxonomyLevelOptionals {
    headers = new AddMetadataTaxonomyLevelHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.AddMetadataTaxonomyLevelOptionals = AddMetadataTaxonomyLevelOptionals;
class DeleteMetadataTaxonomyLevelOptionals {
    headers = new DeleteMetadataTaxonomyLevelHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.DeleteMetadataTaxonomyLevelOptionals = DeleteMetadataTaxonomyLevelOptionals;
class GetMetadataTaxonomyNodesOptionals {
    queryParams = {};
    headers = new GetMetadataTaxonomyNodesHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.queryParams !== undefined) {
            this.queryParams = fields.queryParams;
        }
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetMetadataTaxonomyNodesOptionals = GetMetadataTaxonomyNodesOptionals;
class CreateMetadataTaxonomyNodeOptionals {
    headers = new CreateMetadataTaxonomyNodeHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.CreateMetadataTaxonomyNodeOptionals = CreateMetadataTaxonomyNodeOptionals;
class GetMetadataTaxonomyNodeByIdOptionals {
    headers = new GetMetadataTaxonomyNodeByIdHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetMetadataTaxonomyNodeByIdOptionals = GetMetadataTaxonomyNodeByIdOptionals;
class UpdateMetadataTaxonomyNodeOptionals {
    requestBody = {};
    headers = new UpdateMetadataTaxonomyNodeHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.requestBody !== undefined) {
            this.requestBody = fields.requestBody;
        }
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.UpdateMetadataTaxonomyNodeOptionals = UpdateMetadataTaxonomyNodeOptionals;
class DeleteMetadataTaxonomyNodeOptionals {
    headers = new DeleteMetadataTaxonomyNodeHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.DeleteMetadataTaxonomyNodeOptionals = DeleteMetadataTaxonomyNodeOptionals;
class GetMetadataTemplateFieldOptionsOptionals {
    queryParams = {};
    headers = new GetMetadataTemplateFieldOptionsHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.queryParams !== undefined) {
            this.queryParams = fields.queryParams;
        }
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetMetadataTemplateFieldOptionsOptionals = GetMetadataTemplateFieldOptionsOptionals;
class CreateMetadataTaxonomyHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.CreateMetadataTaxonomyHeaders = CreateMetadataTaxonomyHeaders;
class GetMetadataTaxonomiesHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetMetadataTaxonomiesHeaders = GetMetadataTaxonomiesHeaders;
class GetMetadataTaxonomyByKeyHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetMetadataTaxonomyByKeyHeaders = GetMetadataTaxonomyByKeyHeaders;
class UpdateMetadataTaxonomyHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.UpdateMetadataTaxonomyHeaders = UpdateMetadataTaxonomyHeaders;
class DeleteMetadataTaxonomyHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.DeleteMetadataTaxonomyHeaders = DeleteMetadataTaxonomyHeaders;
class CreateMetadataTaxonomyLevelHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.CreateMetadataTaxonomyLevelHeaders = CreateMetadataTaxonomyLevelHeaders;
class UpdateMetadataTaxonomyLevelByIdHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.UpdateMetadataTaxonomyLevelByIdHeaders = UpdateMetadataTaxonomyLevelByIdHeaders;
class AddMetadataTaxonomyLevelHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.AddMetadataTaxonomyLevelHeaders = AddMetadataTaxonomyLevelHeaders;
class DeleteMetadataTaxonomyLevelHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.DeleteMetadataTaxonomyLevelHeaders = DeleteMetadataTaxonomyLevelHeaders;
class GetMetadataTaxonomyNodesHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetMetadataTaxonomyNodesHeaders = GetMetadataTaxonomyNodesHeaders;
class CreateMetadataTaxonomyNodeHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.CreateMetadataTaxonomyNodeHeaders = CreateMetadataTaxonomyNodeHeaders;
class GetMetadataTaxonomyNodeByIdHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetMetadataTaxonomyNodeByIdHeaders = GetMetadataTaxonomyNodeByIdHeaders;
class UpdateMetadataTaxonomyNodeHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.UpdateMetadataTaxonomyNodeHeaders = UpdateMetadataTaxonomyNodeHeaders;
class DeleteMetadataTaxonomyNodeHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.DeleteMetadataTaxonomyNodeHeaders = DeleteMetadataTaxonomyNodeHeaders;
class GetMetadataTemplateFieldOptionsHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetMetadataTemplateFieldOptionsHeaders = GetMetadataTemplateFieldOptionsHeaders;
class MetadataTaxonomiesManager {
    auth;
    networkSession = new network_1.NetworkSession({});
    constructor(fields) {
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
    }
    /**
     * Creates a new metadata taxonomy that can be used in
     * metadata templates.
     * @param {CreateMetadataTaxonomyRequestBody} requestBody Request body of createMetadataTaxonomy method
     * @param {CreateMetadataTaxonomyOptionalsInput} optionalsInput
     * @returns {Promise<MetadataTaxonomy>}
     */
    async createMetadataTaxonomy(requestBody, optionalsInput = {}) {
        const optionals = new CreateMetadataTaxonomyOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies'),
            method: 'POST',
            headers: headersMap,
            data: serializeCreateMetadataTaxonomyRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomy_1.deserializeMetadataTaxonomy)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Used to retrieve all metadata taxonomies in a namespace.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {GetMetadataTaxonomiesOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomies>}
       */
    async getMetadataTaxonomies(namespace, optionalsInput = {}) {
        const optionals = new GetMetadataTaxonomiesOptionals({
            queryParams: optionalsInput.queryParams,
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const queryParams = optionals.queryParams;
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const queryParamsMap = (0, utils_1.prepareParams)({
            ['marker']: (0, utils_2.toString)(queryParams.marker),
            ['limit']: (0, utils_2.toString)(queryParams.limit),
        });
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace)),
            method: 'GET',
            params: queryParamsMap,
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomies_1.deserializeMetadataTaxonomies)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Used to retrieve a metadata taxonomy by taxonomy key.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {GetMetadataTaxonomyByKeyOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomy>}
       */
    async getMetadataTaxonomyByKey(namespace, taxonomyKey, optionalsInput = {}) {
        const optionals = new GetMetadataTaxonomyByKeyOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey)),
            method: 'GET',
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomy_1.deserializeMetadataTaxonomy)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Updates an existing metadata taxonomy.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {UpdateMetadataTaxonomyRequestBody} requestBody Request body of updateMetadataTaxonomy method
       * @param {UpdateMetadataTaxonomyOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomy>}
       */
    async updateMetadataTaxonomy(namespace, taxonomyKey, requestBody, optionalsInput = {}) {
        const optionals = new UpdateMetadataTaxonomyOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey)),
            method: 'PATCH',
            headers: headersMap,
            data: serializeUpdateMetadataTaxonomyRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomy_1.deserializeMetadataTaxonomy)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Delete a metadata taxonomy.
       * This deletion is permanent and cannot be reverted.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {DeleteMetadataTaxonomyOptionalsInput} optionalsInput
       * @returns {Promise<undefined>}
       */
    async deleteMetadataTaxonomy(namespace, taxonomyKey, optionalsInput = {}) {
        const optionals = new DeleteMetadataTaxonomyOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey)),
            method: 'DELETE',
            headers: headersMap,
            responseFormat: 'no_content',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return void 0;
    }
    /**
       * Creates new metadata taxonomy levels.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {readonly MetadataTaxonomyLevel[]} requestBody Request body of createMetadataTaxonomyLevel method
       * @param {CreateMetadataTaxonomyLevelOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyLevels>}
       */
    async createMetadataTaxonomyLevel(namespace, taxonomyKey, requestBody, optionalsInput = {}) {
        const optionals = new CreateMetadataTaxonomyLevelOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/levels'),
            method: 'POST',
            headers: headersMap,
            data: requestBody.map(metadataTaxonomyLevel_1.serializeMetadataTaxonomyLevel),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyLevels_1.deserializeMetadataTaxonomyLevels)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Updates an existing metadata taxonomy level.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {number} levelIndex The index of the metadata taxonomy level.
      Example: 1
       * @param {UpdateMetadataTaxonomyLevelByIdRequestBody} requestBody Request body of updateMetadataTaxonomyLevelById method
       * @param {UpdateMetadataTaxonomyLevelByIdOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyLevel>}
       */
    async updateMetadataTaxonomyLevelById(namespace, taxonomyKey, levelIndex, requestBody, optionalsInput = {}) {
        const optionals = new UpdateMetadataTaxonomyLevelByIdOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/levels/', (0, utils_2.toString)(levelIndex)),
            method: 'PATCH',
            headers: headersMap,
            data: serializeUpdateMetadataTaxonomyLevelByIdRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyLevel_2.deserializeMetadataTaxonomyLevel)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Creates a new metadata taxonomy level and appends it to the existing levels.
       * If there are no levels defined yet, this will create the first level.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {AddMetadataTaxonomyLevelRequestBody} requestBody Request body of addMetadataTaxonomyLevel method
       * @param {AddMetadataTaxonomyLevelOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyLevels>}
       */
    async addMetadataTaxonomyLevel(namespace, taxonomyKey, requestBody, optionalsInput = {}) {
        const optionals = new AddMetadataTaxonomyLevelOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/levels:append'),
            method: 'POST',
            headers: headersMap,
            data: serializeAddMetadataTaxonomyLevelRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyLevels_1.deserializeMetadataTaxonomyLevels)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Deletes the last level of the metadata taxonomy.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {DeleteMetadataTaxonomyLevelOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyLevels>}
       */
    async deleteMetadataTaxonomyLevel(namespace, taxonomyKey, optionalsInput = {}) {
        const optionals = new DeleteMetadataTaxonomyLevelOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/levels:trim'),
            method: 'POST',
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyLevels_1.deserializeMetadataTaxonomyLevels)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Used to retrieve metadata taxonomy nodes based on the parameters specified.
       * Results are sorted in lexicographic order unless a `query` parameter is passed.
       * With a `query` parameter specified, results are sorted in order of relevance.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {GetMetadataTaxonomyNodesOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyNodes>}
       */
    async getMetadataTaxonomyNodes(namespace, taxonomyKey, optionalsInput = {}) {
        const optionals = new GetMetadataTaxonomyNodesOptionals({
            queryParams: optionalsInput.queryParams,
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const queryParams = optionals.queryParams;
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const queryParamsMap = (0, utils_1.prepareParams)({
            ['level']: queryParams.level
                ? queryParams.level.map(utils_2.toString).join(',')
                : undefined,
            ['parent']: queryParams.parent
                ? queryParams.parent.map(utils_2.toString).join(',')
                : undefined,
            ['ancestor']: queryParams.ancestor
                ? queryParams.ancestor.map(utils_2.toString).join(',')
                : undefined,
            ['query']: (0, utils_2.toString)(queryParams.query),
            ['include-total-result-count']: (0, utils_2.toString)(queryParams.includeTotalResultCount),
            ['marker']: (0, utils_2.toString)(queryParams.marker),
            ['limit']: (0, utils_2.toString)(queryParams.limit),
        });
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/nodes'),
            method: 'GET',
            params: queryParamsMap,
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyNodes_1.deserializeMetadataTaxonomyNodes)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Creates a new metadata taxonomy node.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {CreateMetadataTaxonomyNodeRequestBody} requestBody Request body of createMetadataTaxonomyNode method
       * @param {CreateMetadataTaxonomyNodeOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyNode>}
       */
    async createMetadataTaxonomyNode(namespace, taxonomyKey, requestBody, optionalsInput = {}) {
        const optionals = new CreateMetadataTaxonomyNodeOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/nodes'),
            method: 'POST',
            headers: headersMap,
            data: serializeCreateMetadataTaxonomyNodeRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyNode_1.deserializeMetadataTaxonomyNode)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Retrieves a metadata taxonomy node by its identifier.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {string} nodeId The identifier of the metadata taxonomy node.
      Example: "14d3d433-c77f-49c5-b146-9dea370f6e32"
       * @param {GetMetadataTaxonomyNodeByIdOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyNode>}
       */
    async getMetadataTaxonomyNodeById(namespace, taxonomyKey, nodeId, optionalsInput = {}) {
        const optionals = new GetMetadataTaxonomyNodeByIdOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/nodes/', (0, utils_2.toString)(nodeId)),
            method: 'GET',
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyNode_1.deserializeMetadataTaxonomyNode)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Updates an existing metadata taxonomy node.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {string} nodeId The identifier of the metadata taxonomy node.
      Example: "14d3d433-c77f-49c5-b146-9dea370f6e32"
       * @param {UpdateMetadataTaxonomyNodeOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyNode>}
       */
    async updateMetadataTaxonomyNode(namespace, taxonomyKey, nodeId, optionalsInput = {}) {
        const optionals = new UpdateMetadataTaxonomyNodeOptionals({
            requestBody: optionalsInput.requestBody,
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const requestBody = optionals.requestBody;
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/nodes/', (0, utils_2.toString)(nodeId)),
            method: 'PATCH',
            headers: headersMap,
            data: serializeUpdateMetadataTaxonomyNodeRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyNode_1.deserializeMetadataTaxonomyNode)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Delete a metadata taxonomy node.
       * This deletion is permanent and cannot be reverted.
       * Only metadata taxonomy nodes without any children can be deleted.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} taxonomyKey The key of the metadata taxonomy.
      Example: "geography"
       * @param {string} nodeId The identifier of the metadata taxonomy node.
      Example: "14d3d433-c77f-49c5-b146-9dea370f6e32"
       * @param {DeleteMetadataTaxonomyNodeOptionalsInput} optionalsInput
       * @returns {Promise<undefined>}
       */
    async deleteMetadataTaxonomyNode(namespace, taxonomyKey, nodeId, optionalsInput = {}) {
        const optionals = new DeleteMetadataTaxonomyNodeOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_taxonomies/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(taxonomyKey), '/nodes/', (0, utils_2.toString)(nodeId)),
            method: 'DELETE',
            headers: headersMap,
            responseFormat: 'no_content',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return void 0;
    }
    /**
       * Used to retrieve metadata taxonomy nodes which are available for the taxonomy field based
       * on its configuration and the parameters specified.
       * Results are sorted in lexicographic order unless a `query` parameter is passed.
       * With a `query` parameter specified, results are sorted in order of relevance.
       * @param {string} namespace The namespace of the metadata taxonomy.
      Example: "enterprise_123456"
       * @param {string} templateKey The name of the metadata template.
      Example: "properties"
       * @param {string} fieldKey The key of the metadata taxonomy field in the template.
      Example: "geography"
       * @param {GetMetadataTemplateFieldOptionsOptionalsInput} optionalsInput
       * @returns {Promise<MetadataTaxonomyNodes>}
       */
    async getMetadataTemplateFieldOptions(namespace, templateKey, fieldKey, optionalsInput = {}) {
        const optionals = new GetMetadataTemplateFieldOptionsOptionals({
            queryParams: optionalsInput.queryParams,
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const queryParams = optionals.queryParams;
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const queryParamsMap = (0, utils_1.prepareParams)({
            ['level']: queryParams.level
                ? queryParams.level.map(utils_2.toString).join(',')
                : undefined,
            ['parent']: queryParams.parent
                ? queryParams.parent.map(utils_2.toString).join(',')
                : undefined,
            ['ancestor']: queryParams.ancestor
                ? queryParams.ancestor.map(utils_2.toString).join(',')
                : undefined,
            ['query']: (0, utils_2.toString)(queryParams.query),
            ['include-total-result-count']: (0, utils_2.toString)(queryParams.includeTotalResultCount),
            ['only-selectable-options']: (0, utils_2.toString)(queryParams.onlySelectableOptions),
            ['marker']: (0, utils_2.toString)(queryParams.marker),
            ['limit']: (0, utils_2.toString)(queryParams.limit),
        });
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/metadata_templates/', (0, utils_2.toString)(namespace), '/', (0, utils_2.toString)(templateKey), '/fields/', (0, utils_2.toString)(fieldKey), '/options'),
            method: 'GET',
            params: queryParamsMap,
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, metadataTaxonomyNodes_1.deserializeMetadataTaxonomyNodes)(response.data),
            rawData: response.data,
        };
    }
}
exports.MetadataTaxonomiesManager = MetadataTaxonomiesManager;
function serializeCreateMetadataTaxonomyRequestBody(val) {
    return {
        ['key']: val.key,
        ['displayName']: val.displayName,
        ['namespace']: val.namespace,
    };
}
function deserializeCreateMetadataTaxonomyRequestBody(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "CreateMetadataTaxonomyRequestBody"',
        });
    }
    if (!(val.key == void 0) && !(0, json_2.sdIsString)(val.key)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "key" of type "CreateMetadataTaxonomyRequestBody"',
        });
    }
    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 "CreateMetadataTaxonomyRequestBody" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.displayName)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "displayName" of type "CreateMetadataTaxonomyRequestBody"',
        });
    }
    const displayName = val.displayName;
    if (val.namespace == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "namespace" of type "CreateMetadataTaxonomyRequestBody" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.namespace)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "namespace" of type "CreateMetadataTaxonomyRequestBody"',
        });
    }
    const namespace = val.namespace;
    return {
        key: key,
        displayName: displayName,
        namespace: namespace,
    };
}
function serializeUpdateMetadataTaxonomyRequestBody(val) {
    return { ['displayName']: val.displayName };
}
function deserializeUpdateMetadataTaxonomyRequestBody(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "UpdateMetadataTaxonomyRequestBody"',
        });
    }
    if (val.displayName == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "displayName" of type "UpdateMetadataTaxonomyRequestBody" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.displayName)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "displayName" of type "UpdateMetadataTaxonomyRequestBody"',
        });
    }
    const displayName = val.displayName;
    return {
        displayName: displayName,
    };
}
function serializeUpdateMetadataTaxonomyLevelByIdRequestBody(val) {
    return { ['displayName']: val.displayName, ['description']: val.description };
}
function deserializeUpdateMetadataTaxonomyLevelByIdRequestBody(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "UpdateMetadataTaxonomyLevelByIdRequestBody"',
        });
    }
    if (val.displayName == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "displayName" of type "UpdateMetadataTaxonomyLevelByIdRequestBody" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.displayName)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "displayName" of type "UpdateMetadataTaxonomyLevelByIdRequestBody"',
        });
    }
    const displayName = val.displayName;
    if (!(val.description == void 0) && !(0, json_2.sdIsString)(val.description)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "description" of type "UpdateMetadataTaxonomyLevelByIdRequestBody"',
        });
    }
    const description = val.description == void 0 ? void 0 : val.description;
    return {
        displayName: displayName,
        description: description,
    };
}
function serializeAddMetadataTaxonomyLevelRequestBody(val) {
    return { ['displayName']: val.displayName, ['description']: val.description };
}
function deserializeAddMetadataTaxonomyLevelRequestBody(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "AddMetadataTaxonomyLevelRequestBody"',
        });
    }
    if (val.displayName == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "displayName" of type "AddMetadataTaxonomyLevelRequestBody" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.displayName)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "displayName" of type "AddMetadataTaxonomyLevelRequestBody"',
        });
    }
    const displayName = val.displayName;
    if (!(val.description == void 0) && !(0, json_2.sdIsString)(val.description)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "description" of type "AddMetadataTaxonomyLevelRequestBody"',
        });
    }
    const description = val.description == void 0 ? void 0 : val.description;
    return {
        displayName: displayName,
        description: description,
    };
}
function serializeCreateMetadataTaxonomyNodeRequestBody(val) {
    return {
        ['displayName']: val.displayName,
        ['level']: val.level,
        ['parentId']: val.parentId,
    };
}
function deserializeCreateMetadataTaxonomyNodeRequestBody(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "CreateMetadataTaxonomyNodeRequestBody"',
        });
    }
    if (val.displayName == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "displayName" of type "CreateMetadataTaxonomyNodeRequestBody" to be defined',
        });
    }
    if (!(0, json_2.sdIsString)(val.displayName)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "displayName" of type "CreateMetadataTaxonomyNodeRequestBody"',
        });
    }
    const displayName = val.displayName;
    if (val.level == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "level" of type "CreateMetadataTaxonomyNodeRequestBody" to be defined',
        });
    }
    if (!(0, json_1.sdIsNumber)(val.level)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting number for "level" of type "CreateMetadataTaxonomyNodeRequestBody"',
        });
    }
    const level = val.level;
    if (!(val.parentId == void 0) && !(0, json_2.sdIsString)(val.parentId)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "parentId" of type "CreateMetadataTaxonomyNodeRequestBody"',
        });
    }
    const parentId = val.parentId == void 0 ? void 0 : val.parentId;
    return {
        displayName: displayName,
        level: level,
        parentId: parentId,
    };
}
function serializeUpdateMetadataTaxonomyNodeRequestBody(val) {
    return { ['displayName']: val.displayName };
}
function deserializeUpdateMetadataTaxonomyNodeRequestBody(val) {
    if (!(0, json_3.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "UpdateMetadataTaxonomyNodeRequestBody"',
        });
    }
    if (!(val.displayName == void 0) && !(0, json_2.sdIsString)(val.displayName)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "displayName" of type "UpdateMetadataTaxonomyNodeRequestBody"',
        });
    }
    const displayName = val.displayName == void 0 ? void 0 : val.displayName;
    return {
        displayName: displayName,
    };
}
//# sourceMappingURL=metadataTaxonomies.js.map