"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FolderWatermarksManager = exports.DeleteFolderWatermarkHeaders = exports.UpdateFolderWatermarkHeaders = exports.UpdateFolderWatermarkRequestBodyWatermarkField = exports.GetFolderWatermarkHeaders = exports.DeleteFolderWatermarkOptionals = exports.UpdateFolderWatermarkOptionals = exports.GetFolderWatermarkOptionals = void 0;
exports.serializeUpdateFolderWatermarkRequestBodyWatermarkImprintField = serializeUpdateFolderWatermarkRequestBodyWatermarkImprintField;
exports.deserializeUpdateFolderWatermarkRequestBodyWatermarkImprintField = deserializeUpdateFolderWatermarkRequestBodyWatermarkImprintField;
exports.serializeUpdateFolderWatermarkRequestBodyWatermarkField = serializeUpdateFolderWatermarkRequestBodyWatermarkField;
exports.deserializeUpdateFolderWatermarkRequestBodyWatermarkField = deserializeUpdateFolderWatermarkRequestBodyWatermarkField;
exports.serializeUpdateFolderWatermarkRequestBodyWatermarkFieldInput = serializeUpdateFolderWatermarkRequestBodyWatermarkFieldInput;
exports.deserializeUpdateFolderWatermarkRequestBodyWatermarkFieldInput = deserializeUpdateFolderWatermarkRequestBodyWatermarkFieldInput;
exports.serializeUpdateFolderWatermarkRequestBody = serializeUpdateFolderWatermarkRequestBody;
exports.deserializeUpdateFolderWatermarkRequestBody = deserializeUpdateFolderWatermarkRequestBody;
const watermark_1 = require("../schemas/watermark");
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 GetFolderWatermarkOptionals {
    headers = new GetFolderWatermarkHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetFolderWatermarkOptionals = GetFolderWatermarkOptionals;
class UpdateFolderWatermarkOptionals {
    headers = new UpdateFolderWatermarkHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.UpdateFolderWatermarkOptionals = UpdateFolderWatermarkOptionals;
class DeleteFolderWatermarkOptionals {
    headers = new DeleteFolderWatermarkHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.DeleteFolderWatermarkOptionals = DeleteFolderWatermarkOptionals;
class GetFolderWatermarkHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetFolderWatermarkHeaders = GetFolderWatermarkHeaders;
class UpdateFolderWatermarkRequestBodyWatermarkField {
    /**
     * The type of watermark to apply.
     *
     * Currently only supports one option. */
    imprint = 'default';
    rawData;
    constructor(fields) {
        if (fields.imprint !== undefined) {
            this.imprint = fields.imprint;
        }
        if (fields.rawData !== undefined) {
            this.rawData = fields.rawData;
        }
    }
}
exports.UpdateFolderWatermarkRequestBodyWatermarkField = UpdateFolderWatermarkRequestBodyWatermarkField;
class UpdateFolderWatermarkHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.UpdateFolderWatermarkHeaders = UpdateFolderWatermarkHeaders;
class DeleteFolderWatermarkHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.DeleteFolderWatermarkHeaders = DeleteFolderWatermarkHeaders;
class FolderWatermarksManager {
    auth;
    networkSession = new network_1.NetworkSession({});
    constructor(fields) {
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
    }
    /**
       * Retrieve the watermark for a folder.
       * @param {string} folderId The unique identifier that represent a folder.
      
      The ID for any folder can be determined
      by visiting this folder in the web application
      and copying the ID from the URL. For example,
      for the URL `https://*.app.box.com/folder/123`
      the `folder_id` is `123`.
      
      The root folder of a Box account is
      always represented by the ID `0`.
      Example: "12345"
       * @param {GetFolderWatermarkOptionalsInput} optionalsInput
       * @returns {Promise<Watermark>}
       */
    async getFolderWatermark(folderId, optionalsInput = {}) {
        const optionals = new GetFolderWatermarkOptionals({
            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/folders/', (0, utils_2.toString)(folderId), '/watermark'),
            method: 'GET',
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, watermark_1.deserializeWatermark)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Applies or update a watermark on a folder.
       * @param {string} folderId The unique identifier that represent a folder.
      
      The ID for any folder can be determined
      by visiting this folder in the web application
      and copying the ID from the URL. For example,
      for the URL `https://*.app.box.com/folder/123`
      the `folder_id` is `123`.
      
      The root folder of a Box account is
      always represented by the ID `0`.
      Example: "12345"
       * @param {UpdateFolderWatermarkRequestBody} requestBody Request body of updateFolderWatermark method
       * @param {UpdateFolderWatermarkOptionalsInput} optionalsInput
       * @returns {Promise<Watermark>}
       */
    async updateFolderWatermark(folderId, requestBody, optionalsInput = {}) {
        const optionals = new UpdateFolderWatermarkOptionals({
            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/folders/', (0, utils_2.toString)(folderId), '/watermark'),
            method: 'PUT',
            headers: headersMap,
            data: serializeUpdateFolderWatermarkRequestBody(requestBody),
            contentType: 'application/json',
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, watermark_1.deserializeWatermark)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Removes the watermark from a folder.
       * @param {string} folderId The unique identifier that represent a folder.
      
      The ID for any folder can be determined
      by visiting this folder in the web application
      and copying the ID from the URL. For example,
      for the URL `https://*.app.box.com/folder/123`
      the `folder_id` is `123`.
      
      The root folder of a Box account is
      always represented by the ID `0`.
      Example: "12345"
       * @param {DeleteFolderWatermarkOptionalsInput} optionalsInput
       * @returns {Promise<undefined>}
       */
    async deleteFolderWatermark(folderId, optionalsInput = {}) {
        const optionals = new DeleteFolderWatermarkOptionals({
            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/folders/', (0, utils_2.toString)(folderId), '/watermark'),
            method: 'DELETE',
            headers: headersMap,
            responseFormat: 'no_content',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return void 0;
    }
}
exports.FolderWatermarksManager = FolderWatermarksManager;
function serializeUpdateFolderWatermarkRequestBodyWatermarkImprintField(val) {
    return val;
}
function deserializeUpdateFolderWatermarkRequestBodyWatermarkImprintField(val) {
    if (val == 'default') {
        return val;
    }
    if ((0, json_1.sdIsString)(val)) {
        return val;
    }
    throw new errors_1.BoxSdkError({
        message: "Can't deserialize UpdateFolderWatermarkRequestBodyWatermarkImprintField",
    });
}
function serializeUpdateFolderWatermarkRequestBodyWatermarkField(val) {
    return {
        ['imprint']: serializeUpdateFolderWatermarkRequestBodyWatermarkImprintField(val.imprint),
    };
}
function deserializeUpdateFolderWatermarkRequestBodyWatermarkField(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "UpdateFolderWatermarkRequestBodyWatermarkField"',
        });
    }
    if (val.imprint == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "imprint" of type "UpdateFolderWatermarkRequestBodyWatermarkField" to be defined',
        });
    }
    const imprint = deserializeUpdateFolderWatermarkRequestBodyWatermarkImprintField(val.imprint);
    return {
        imprint: imprint,
    };
}
function serializeUpdateFolderWatermarkRequestBodyWatermarkFieldInput(val) {
    return {
        ['imprint']: val.imprint == void 0
            ? val.imprint
            : serializeUpdateFolderWatermarkRequestBodyWatermarkImprintField(val.imprint),
    };
}
function deserializeUpdateFolderWatermarkRequestBodyWatermarkFieldInput(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "UpdateFolderWatermarkRequestBodyWatermarkFieldInput"',
        });
    }
    const imprint = val.imprint == void 0
        ? void 0
        : deserializeUpdateFolderWatermarkRequestBodyWatermarkImprintField(val.imprint);
    return {
        imprint: imprint,
    };
}
function serializeUpdateFolderWatermarkRequestBody(val) {
    return {
        ['watermark']: serializeUpdateFolderWatermarkRequestBodyWatermarkField(val.watermark),
    };
}
function deserializeUpdateFolderWatermarkRequestBody(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "UpdateFolderWatermarkRequestBody"',
        });
    }
    if (val.watermark == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "watermark" of type "UpdateFolderWatermarkRequestBody" to be defined',
        });
    }
    const watermark = deserializeUpdateFolderWatermarkRequestBodyWatermarkField(val.watermark);
    return { watermark: watermark };
}
//# sourceMappingURL=folderWatermarks.js.map