"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DevicePinnersManager = exports.GetEnterpriseDevicePinnersHeaders = exports.DeleteDevicePinnerByIdHeaders = exports.GetDevicePinnerByIdHeaders = exports.GetEnterpriseDevicePinnersOptionals = exports.DeleteDevicePinnerByIdOptionals = exports.GetDevicePinnerByIdOptionals = void 0;
exports.serializeGetEnterpriseDevicePinnersQueryParamsDirectionField = serializeGetEnterpriseDevicePinnersQueryParamsDirectionField;
exports.deserializeGetEnterpriseDevicePinnersQueryParamsDirectionField = deserializeGetEnterpriseDevicePinnersQueryParamsDirectionField;
const devicePinner_1 = require("../schemas/devicePinner");
const devicePinners_1 = require("../schemas/devicePinners");
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");
class GetDevicePinnerByIdOptionals {
    headers = new GetDevicePinnerByIdHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetDevicePinnerByIdOptionals = GetDevicePinnerByIdOptionals;
class DeleteDevicePinnerByIdOptionals {
    headers = new DeleteDevicePinnerByIdHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.DeleteDevicePinnerByIdOptionals = DeleteDevicePinnerByIdOptionals;
class GetEnterpriseDevicePinnersOptionals {
    queryParams = {};
    headers = new GetEnterpriseDevicePinnersHeaders({});
    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.GetEnterpriseDevicePinnersOptionals = GetEnterpriseDevicePinnersOptionals;
class GetDevicePinnerByIdHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetDevicePinnerByIdHeaders = GetDevicePinnerByIdHeaders;
class DeleteDevicePinnerByIdHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.DeleteDevicePinnerByIdHeaders = DeleteDevicePinnerByIdHeaders;
class GetEnterpriseDevicePinnersHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetEnterpriseDevicePinnersHeaders = GetEnterpriseDevicePinnersHeaders;
class DevicePinnersManager {
    auth;
    networkSession = new network_1.NetworkSession({});
    constructor(fields) {
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
    }
    /**
       * Retrieves information about an individual device pin.
       * @param {string} devicePinnerId The ID of the device pin.
      Example: "2324234"
       * @param {GetDevicePinnerByIdOptionalsInput} optionalsInput
       * @returns {Promise<DevicePinner>}
       */
    async getDevicePinnerById(devicePinnerId, optionalsInput = {}) {
        const optionals = new GetDevicePinnerByIdOptionals({
            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/device_pinners/', (0, utils_2.toString)(devicePinnerId)),
            method: 'GET',
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, devicePinner_1.deserializeDevicePinner)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Deletes an individual device pin.
       * @param {string} devicePinnerId The ID of the device pin.
      Example: "2324234"
       * @param {DeleteDevicePinnerByIdOptionalsInput} optionalsInput
       * @returns {Promise<undefined>}
       */
    async deleteDevicePinnerById(devicePinnerId, optionalsInput = {}) {
        const optionals = new DeleteDevicePinnerByIdOptionals({
            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/device_pinners/', (0, utils_2.toString)(devicePinnerId)),
            method: 'DELETE',
            headers: headersMap,
            responseFormat: 'no_content',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return void 0;
    }
    /**
       * Retrieves all the device pins within an enterprise.
       *
       * The user must have admin privileges, and the application
       * needs the "manage enterprise" scope to make this call.
       * @param {string} enterpriseId The ID of the enterprise.
      Example: "3442311"
       * @param {GetEnterpriseDevicePinnersOptionalsInput} optionalsInput
       * @returns {Promise<DevicePinners>}
       */
    async getEnterpriseDevicePinners(enterpriseId, optionalsInput = {}) {
        const optionals = new GetEnterpriseDevicePinnersOptionals({
            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),
            ['direction']: (0, utils_2.toString)(queryParams.direction),
        });
        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/enterprises/', (0, utils_2.toString)(enterpriseId), '/device_pinners'),
            method: 'GET',
            params: queryParamsMap,
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, devicePinners_1.deserializeDevicePinners)(response.data),
            rawData: response.data,
        };
    }
}
exports.DevicePinnersManager = DevicePinnersManager;
function serializeGetEnterpriseDevicePinnersQueryParamsDirectionField(val) {
    return val;
}
function deserializeGetEnterpriseDevicePinnersQueryParamsDirectionField(val) {
    if (val == 'ASC') {
        return val;
    }
    if (val == 'DESC') {
        return val;
    }
    if ((0, json_1.sdIsString)(val)) {
        return val;
    }
    throw new errors_1.BoxSdkError({
        message: "Can't deserialize GetEnterpriseDevicePinnersQueryParamsDirectionField",
    });
}
//# sourceMappingURL=devicePinners.js.map