"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShieldInformationBarriersManager = exports.CreateShieldInformationBarrierHeaders = exports.GetShieldInformationBarriersHeaders = exports.UpdateShieldInformationBarrierStatusHeaders = exports.GetShieldInformationBarrierByIdHeaders = exports.CreateShieldInformationBarrierOptionals = exports.UpdateShieldInformationBarrierStatusOptionals = exports.GetShieldInformationBarrierByIdOptionals = void 0;
exports.serializeUpdateShieldInformationBarrierStatusRequestBodyStatusField = serializeUpdateShieldInformationBarrierStatusRequestBodyStatusField;
exports.deserializeUpdateShieldInformationBarrierStatusRequestBodyStatusField = deserializeUpdateShieldInformationBarrierStatusRequestBodyStatusField;
exports.serializeUpdateShieldInformationBarrierStatusRequestBody = serializeUpdateShieldInformationBarrierStatusRequestBody;
exports.deserializeUpdateShieldInformationBarrierStatusRequestBody = deserializeUpdateShieldInformationBarrierStatusRequestBody;
exports.serializeCreateShieldInformationBarrierRequestBody = serializeCreateShieldInformationBarrierRequestBody;
exports.deserializeCreateShieldInformationBarrierRequestBody = deserializeCreateShieldInformationBarrierRequestBody;
const shieldInformationBarrier_1 = require("../schemas/shieldInformationBarrier");
const shieldInformationBarriers_1 = require("../schemas/shieldInformationBarriers");
const enterpriseBase_1 = require("../schemas/enterpriseBase");
const enterpriseBase_2 = require("../schemas/enterpriseBase");
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");
class GetShieldInformationBarrierByIdOptionals {
    headers = new GetShieldInformationBarrierByIdHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetShieldInformationBarrierByIdOptionals = GetShieldInformationBarrierByIdOptionals;
class UpdateShieldInformationBarrierStatusOptionals {
    headers = new UpdateShieldInformationBarrierStatusHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.UpdateShieldInformationBarrierStatusOptionals = UpdateShieldInformationBarrierStatusOptionals;
class CreateShieldInformationBarrierOptionals {
    headers = new CreateShieldInformationBarrierHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.CreateShieldInformationBarrierOptionals = CreateShieldInformationBarrierOptionals;
class GetShieldInformationBarrierByIdHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetShieldInformationBarrierByIdHeaders = GetShieldInformationBarrierByIdHeaders;
class UpdateShieldInformationBarrierStatusHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.UpdateShieldInformationBarrierStatusHeaders = UpdateShieldInformationBarrierStatusHeaders;
class GetShieldInformationBarriersHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetShieldInformationBarriersHeaders = GetShieldInformationBarriersHeaders;
class CreateShieldInformationBarrierHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.CreateShieldInformationBarrierHeaders = CreateShieldInformationBarrierHeaders;
class ShieldInformationBarriersManager {
    auth;
    networkSession = new network_1.NetworkSession({});
    constructor(fields) {
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
    }
    /**
       * Get shield information barrier based on provided ID.
       * @param {string} shieldInformationBarrierId The ID of the shield information barrier.
      Example: "1910967"
       * @param {GetShieldInformationBarrierByIdOptionalsInput} optionalsInput
       * @returns {Promise<ShieldInformationBarrier>}
       */
    async getShieldInformationBarrierById(shieldInformationBarrierId, optionalsInput = {}) {
        const optionals = new GetShieldInformationBarrierByIdOptionals({
            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/shield_information_barriers/', (0, utils_2.toString)(shieldInformationBarrierId)),
            method: 'GET',
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, shieldInformationBarrier_1.deserializeShieldInformationBarrier)(response.data),
            rawData: response.data,
        };
    }
    /**
     * Change status of shield information barrier with the specified ID.
     * @param {UpdateShieldInformationBarrierStatusRequestBody} requestBody Request body of updateShieldInformationBarrierStatus method
     * @param {UpdateShieldInformationBarrierStatusOptionalsInput} optionalsInput
     * @returns {Promise<ShieldInformationBarrier>}
     */
    async updateShieldInformationBarrierStatus(requestBody, optionalsInput = {}) {
        const optionals = new UpdateShieldInformationBarrierStatusOptionals({
            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/shield_information_barriers/change_status'),
            method: 'POST',
            headers: headersMap,
            data: serializeUpdateShieldInformationBarrierStatusRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, shieldInformationBarrier_1.deserializeShieldInformationBarrier)(response.data),
            rawData: response.data,
        };
    }
    /**
     * Retrieves a list of shield information barrier objects
     * for the enterprise of JWT.
     * @param {GetShieldInformationBarriersQueryParams} queryParams Query parameters of getShieldInformationBarriers method
     * @param {GetShieldInformationBarriersHeadersInput} headersInput Headers of getShieldInformationBarriers method
     * @param {CancellationToken} cancellationToken Token used for request cancellation.
     * @returns {Promise<ShieldInformationBarriers>}
     */
    async getShieldInformationBarriers(queryParams = {}, headersInput = new GetShieldInformationBarriersHeaders({}), cancellationToken) {
        const headers = new GetShieldInformationBarriersHeaders({
            extraHeaders: headersInput.extraHeaders,
        });
        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/shield_information_barriers'),
            method: 'GET',
            params: queryParamsMap,
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, shieldInformationBarriers_1.deserializeShieldInformationBarriers)(response.data),
            rawData: response.data,
        };
    }
    /**
     * Creates a shield information barrier to
     * separate individuals/groups within the same
     * firm and prevents confidential information passing between them.
     * @param {CreateShieldInformationBarrierRequestBody} requestBody Request body of createShieldInformationBarrier method
     * @param {CreateShieldInformationBarrierOptionalsInput} optionalsInput
     * @returns {Promise<ShieldInformationBarrier>}
     */
    async createShieldInformationBarrier(requestBody, optionalsInput = {}) {
        const optionals = new CreateShieldInformationBarrierOptionals({
            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/shield_information_barriers'),
            method: 'POST',
            headers: headersMap,
            data: serializeCreateShieldInformationBarrierRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, shieldInformationBarrier_1.deserializeShieldInformationBarrier)(response.data),
            rawData: response.data,
        };
    }
}
exports.ShieldInformationBarriersManager = ShieldInformationBarriersManager;
function serializeUpdateShieldInformationBarrierStatusRequestBodyStatusField(val) {
    return val;
}
function deserializeUpdateShieldInformationBarrierStatusRequestBodyStatusField(val) {
    if (val == 'pending') {
        return val;
    }
    if (val == 'disabled') {
        return val;
    }
    if ((0, json_1.sdIsString)(val)) {
        return val;
    }
    throw new errors_1.BoxSdkError({
        message: "Can't deserialize UpdateShieldInformationBarrierStatusRequestBodyStatusField",
    });
}
function serializeUpdateShieldInformationBarrierStatusRequestBody(val) {
    return {
        ['id']: val.id,
        ['status']: serializeUpdateShieldInformationBarrierStatusRequestBodyStatusField(val.status),
    };
}
function deserializeUpdateShieldInformationBarrierStatusRequestBody(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "UpdateShieldInformationBarrierStatusRequestBody"',
        });
    }
    if (val.id == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "id" of type "UpdateShieldInformationBarrierStatusRequestBody" to be defined',
        });
    }
    if (!(0, json_1.sdIsString)(val.id)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "id" of type "UpdateShieldInformationBarrierStatusRequestBody"',
        });
    }
    const id = val.id;
    if (val.status == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "status" of type "UpdateShieldInformationBarrierStatusRequestBody" to be defined',
        });
    }
    const status = deserializeUpdateShieldInformationBarrierStatusRequestBodyStatusField(val.status);
    return {
        id: id,
        status: status,
    };
}
function serializeCreateShieldInformationBarrierRequestBody(val) {
    return { ['enterprise']: (0, enterpriseBase_1.serializeEnterpriseBase)(val.enterprise) };
}
function deserializeCreateShieldInformationBarrierRequestBody(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "CreateShieldInformationBarrierRequestBody"',
        });
    }
    if (val.enterprise == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "enterprise" of type "CreateShieldInformationBarrierRequestBody" to be defined',
        });
    }
    const enterprise = (0, enterpriseBase_2.deserializeEnterpriseBase)(val.enterprise);
    return {
        enterprise: enterprise,
    };
}
//# sourceMappingURL=shieldInformationBarriers.js.map