"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BoxClient = void 0;
const authorization_1 = require("./managers/authorization");
const files_1 = require("./managers/files");
const trashedFiles_1 = require("./managers/trashedFiles");
const appItemAssociations_1 = require("./managers/appItemAssociations");
const downloads_1 = require("./managers/downloads");
const uploads_1 = require("./managers/uploads");
const chunkedUploads_1 = require("./managers/chunkedUploads");
const listCollaborations_1 = require("./managers/listCollaborations");
const comments_1 = require("./managers/comments");
const tasks_1 = require("./managers/tasks");
const fileVersions_1 = require("./managers/fileVersions");
const fileMetadata_1 = require("./managers/fileMetadata");
const fileClassifications_1 = require("./managers/fileClassifications");
const skills_1 = require("./managers/skills");
const fileWatermarks_1 = require("./managers/fileWatermarks");
const fileRequests_1 = require("./managers/fileRequests");
const folders_1 = require("./managers/folders");
const trashedFolders_1 = require("./managers/trashedFolders");
const folderMetadata_1 = require("./managers/folderMetadata");
const folderClassifications_1 = require("./managers/folderClassifications");
const trashedItems_1 = require("./managers/trashedItems");
const folderWatermarks_1 = require("./managers/folderWatermarks");
const folderLocks_1 = require("./managers/folderLocks");
const metadataTemplates_1 = require("./managers/metadataTemplates");
const classifications_1 = require("./managers/classifications");
const metadataCascadePolicies_1 = require("./managers/metadataCascadePolicies");
const search_1 = require("./managers/search");
const userCollaborations_1 = require("./managers/userCollaborations");
const taskAssignments_1 = require("./managers/taskAssignments");
const sharedLinksFiles_1 = require("./managers/sharedLinksFiles");
const sharedLinksFolders_1 = require("./managers/sharedLinksFolders");
const webLinks_1 = require("./managers/webLinks");
const trashedWebLinks_1 = require("./managers/trashedWebLinks");
const sharedLinksWebLinks_1 = require("./managers/sharedLinksWebLinks");
const sharedLinksAppItems_1 = require("./managers/sharedLinksAppItems");
const users_1 = require("./managers/users");
const sessionTermination_1 = require("./managers/sessionTermination");
const avatars_1 = require("./managers/avatars");
const transfer_1 = require("./managers/transfer");
const emailAliases_1 = require("./managers/emailAliases");
const memberships_1 = require("./managers/memberships");
const invites_1 = require("./managers/invites");
const groups_1 = require("./managers/groups");
const webhooks_1 = require("./managers/webhooks");
const events_1 = require("./managers/events");
const collections_1 = require("./managers/collections");
const recentItems_1 = require("./managers/recentItems");
const retentionPolicies_1 = require("./managers/retentionPolicies");
const retentionPolicyAssignments_1 = require("./managers/retentionPolicyAssignments");
const legalHoldPolicies_1 = require("./managers/legalHoldPolicies");
const legalHoldPolicyAssignments_1 = require("./managers/legalHoldPolicyAssignments");
const fileVersionRetentions_1 = require("./managers/fileVersionRetentions");
const fileVersionLegalHolds_1 = require("./managers/fileVersionLegalHolds");
const shieldInformationBarriers_1 = require("./managers/shieldInformationBarriers");
const shieldInformationBarrierReports_1 = require("./managers/shieldInformationBarrierReports");
const shieldInformationBarrierSegments_1 = require("./managers/shieldInformationBarrierSegments");
const shieldInformationBarrierSegmentMembers_1 = require("./managers/shieldInformationBarrierSegmentMembers");
const shieldInformationBarrierSegmentRestrictions_1 = require("./managers/shieldInformationBarrierSegmentRestrictions");
const devicePinners_1 = require("./managers/devicePinners");
const termsOfServices_1 = require("./managers/termsOfServices");
const termsOfServiceUserStatuses_1 = require("./managers/termsOfServiceUserStatuses");
const collaborationAllowlistEntries_1 = require("./managers/collaborationAllowlistEntries");
const collaborationAllowlistExemptTargets_1 = require("./managers/collaborationAllowlistExemptTargets");
const storagePolicies_1 = require("./managers/storagePolicies");
const storagePolicyAssignments_1 = require("./managers/storagePolicyAssignments");
const zipDownloads_1 = require("./managers/zipDownloads");
const signRequests_1 = require("./managers/signRequests");
const workflows_1 = require("./managers/workflows");
const signTemplates_1 = require("./managers/signTemplates");
const integrationMappings_1 = require("./managers/integrationMappings");
const ai_1 = require("./managers/ai");
const aiStudio_1 = require("./managers/aiStudio");
const metadataTaxonomies_1 = require("./managers/metadataTaxonomies");
const docgenTemplate_1 = require("./managers/docgenTemplate");
const docgen_1 = require("./managers/docgen");
const enterpriseConfigurations_1 = require("./managers/enterpriseConfigurations");
const hubs_1 = require("./managers/hubs");
const hubCollaborations_1 = require("./managers/hubCollaborations");
const hubItems_1 = require("./managers/hubItems");
const shieldLists_1 = require("./managers/shieldLists");
const archives_1 = require("./managers/archives");
const externalUsers_1 = require("./managers/externalUsers");
const network_1 = require("./networking/network");
const fetchOptions_1 = require("./networking/fetchOptions");
const baseUrls_1 = require("./networking/baseUrls");
class BoxClient {
    constructor(fields) {
        this.networkSession = new network_1.NetworkSession({
            baseUrls: new baseUrls_1.BaseUrls({}),
        });
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
        this.authorization = new authorization_1.AuthorizationManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.files = new files_1.FilesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.trashedFiles = new trashedFiles_1.TrashedFilesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.appItemAssociations = new appItemAssociations_1.AppItemAssociationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.downloads = new downloads_1.DownloadsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.uploads = new uploads_1.UploadsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.chunkedUploads = new chunkedUploads_1.ChunkedUploadsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.listCollaborations = new listCollaborations_1.ListCollaborationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.comments = new comments_1.CommentsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.tasks = new tasks_1.TasksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.fileVersions = new fileVersions_1.FileVersionsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.fileMetadata = new fileMetadata_1.FileMetadataManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.fileClassifications = new fileClassifications_1.FileClassificationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.skills = new skills_1.SkillsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.fileWatermarks = new fileWatermarks_1.FileWatermarksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.fileRequests = new fileRequests_1.FileRequestsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.folders = new folders_1.FoldersManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.trashedFolders = new trashedFolders_1.TrashedFoldersManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.folderMetadata = new folderMetadata_1.FolderMetadataManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.folderClassifications = new folderClassifications_1.FolderClassificationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.trashedItems = new trashedItems_1.TrashedItemsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.folderWatermarks = new folderWatermarks_1.FolderWatermarksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.folderLocks = new folderLocks_1.FolderLocksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.metadataTemplates = new metadataTemplates_1.MetadataTemplatesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.classifications = new classifications_1.ClassificationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.metadataCascadePolicies = new metadataCascadePolicies_1.MetadataCascadePoliciesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.search = new search_1.SearchManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.userCollaborations = new userCollaborations_1.UserCollaborationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.taskAssignments = new taskAssignments_1.TaskAssignmentsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.sharedLinksFiles = new sharedLinksFiles_1.SharedLinksFilesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.sharedLinksFolders = new sharedLinksFolders_1.SharedLinksFoldersManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.webLinks = new webLinks_1.WebLinksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.trashedWebLinks = new trashedWebLinks_1.TrashedWebLinksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.sharedLinksWebLinks = new sharedLinksWebLinks_1.SharedLinksWebLinksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.sharedLinksAppItems = new sharedLinksAppItems_1.SharedLinksAppItemsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.users = new users_1.UsersManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.sessionTermination = new sessionTermination_1.SessionTerminationManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.avatars = new avatars_1.AvatarsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.transfer = new transfer_1.TransferManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.emailAliases = new emailAliases_1.EmailAliasesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.memberships = new memberships_1.MembershipsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.invites = new invites_1.InvitesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.groups = new groups_1.GroupsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.webhooks = new webhooks_1.WebhooksManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.events = new events_1.EventsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.collections = new collections_1.CollectionsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.recentItems = new recentItems_1.RecentItemsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.retentionPolicies = new retentionPolicies_1.RetentionPoliciesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.retentionPolicyAssignments = new retentionPolicyAssignments_1.RetentionPolicyAssignmentsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.legalHoldPolicies = new legalHoldPolicies_1.LegalHoldPoliciesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.legalHoldPolicyAssignments = new legalHoldPolicyAssignments_1.LegalHoldPolicyAssignmentsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.fileVersionRetentions = new fileVersionRetentions_1.FileVersionRetentionsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.fileVersionLegalHolds = new fileVersionLegalHolds_1.FileVersionLegalHoldsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.shieldInformationBarriers = new shieldInformationBarriers_1.ShieldInformationBarriersManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.shieldInformationBarrierReports =
            new shieldInformationBarrierReports_1.ShieldInformationBarrierReportsManager({
                auth: this.auth,
                networkSession: this.networkSession,
            });
        this.shieldInformationBarrierSegments =
            new shieldInformationBarrierSegments_1.ShieldInformationBarrierSegmentsManager({
                auth: this.auth,
                networkSession: this.networkSession,
            });
        this.shieldInformationBarrierSegmentMembers =
            new shieldInformationBarrierSegmentMembers_1.ShieldInformationBarrierSegmentMembersManager({
                auth: this.auth,
                networkSession: this.networkSession,
            });
        this.shieldInformationBarrierSegmentRestrictions =
            new shieldInformationBarrierSegmentRestrictions_1.ShieldInformationBarrierSegmentRestrictionsManager({
                auth: this.auth,
                networkSession: this.networkSession,
            });
        this.devicePinners = new devicePinners_1.DevicePinnersManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.termsOfServices = new termsOfServices_1.TermsOfServicesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.termsOfServiceUserStatuses = new termsOfServiceUserStatuses_1.TermsOfServiceUserStatusesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.collaborationAllowlistEntries =
            new collaborationAllowlistEntries_1.CollaborationAllowlistEntriesManager({
                auth: this.auth,
                networkSession: this.networkSession,
            });
        this.collaborationAllowlistExemptTargets =
            new collaborationAllowlistExemptTargets_1.CollaborationAllowlistExemptTargetsManager({
                auth: this.auth,
                networkSession: this.networkSession,
            });
        this.storagePolicies = new storagePolicies_1.StoragePoliciesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.storagePolicyAssignments = new storagePolicyAssignments_1.StoragePolicyAssignmentsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.zipDownloads = new zipDownloads_1.ZipDownloadsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.signRequests = new signRequests_1.SignRequestsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.workflows = new workflows_1.WorkflowsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.signTemplates = new signTemplates_1.SignTemplatesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.integrationMappings = new integrationMappings_1.IntegrationMappingsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.ai = new ai_1.AiManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.aiStudio = new aiStudio_1.AiStudioManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.metadataTaxonomies = new metadataTaxonomies_1.MetadataTaxonomiesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.docgenTemplate = new docgenTemplate_1.DocgenTemplateManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.docgen = new docgen_1.DocgenManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.enterpriseConfigurations = new enterpriseConfigurations_1.EnterpriseConfigurationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.hubs = new hubs_1.HubsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.hubCollaborations = new hubCollaborations_1.HubCollaborationsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.hubItems = new hubItems_1.HubItemsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.shieldLists = new shieldLists_1.ShieldListsManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.archives = new archives_1.ArchivesManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
        this.externalUsers = new externalUsers_1.ExternalUsersManager({
            auth: this.auth,
            networkSession: this.networkSession,
        });
    }
    /**
     * Make a custom http request using the client authentication and network session.
     * @param {FetchOptionsInput} fetchOptionsInput Options to be passed to the fetch call
     * @returns {Promise<FetchResponse>}
     */
    makeRequest(fetchOptionsInput) {
        return __awaiter(this, void 0, void 0, function* () {
            const fetchOptions = new fetchOptions_1.FetchOptions({
                url: fetchOptionsInput.url,
                method: fetchOptionsInput.method,
                params: fetchOptionsInput.params,
                headers: fetchOptionsInput.headers,
                data: fetchOptionsInput.data,
                fileStream: fetchOptionsInput.fileStream,
                multipartData: fetchOptionsInput.multipartData,
                contentType: fetchOptionsInput.contentType,
                responseFormat: fetchOptionsInput.responseFormat,
                auth: fetchOptionsInput.auth,
                networkSession: fetchOptionsInput.networkSession,
                cancellationToken: fetchOptionsInput.cancellationToken,
                followRedirects: fetchOptionsInput.followRedirects,
            });
            const auth = fetchOptions.auth == void 0 ? this.auth : fetchOptions.auth;
            const networkSession = fetchOptions.networkSession == void 0
                ? this.networkSession
                : fetchOptions.networkSession;
            const enrichedFetchOptions = new fetchOptions_1.FetchOptions({
                auth: auth,
                networkSession: networkSession,
                url: fetchOptions.url,
                method: fetchOptions.method,
                params: fetchOptions.params,
                headers: fetchOptions.headers,
                data: fetchOptions.data,
                fileStream: fetchOptions.fileStream,
                multipartData: fetchOptions.multipartData,
                contentType: fetchOptions.contentType,
                responseFormat: fetchOptions.responseFormat,
                followRedirects: fetchOptions.followRedirects,
            });
            return yield networkSession.networkClient.fetch(enrichedFetchOptions);
        });
    }
    /**
     * Create a new client to impersonate user with the provided ID. All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified.
     * @param {string} userId ID of an user to impersonate
     * @returns {BoxClient}
     */
    withAsUserHeader(userId) {
        return new BoxClient({
            auth: this.auth,
            networkSession: this.networkSession.withAdditionalHeaders({
                ['As-User']: userId,
            }),
        });
    }
    /**
     * Create a new client with suppressed notifications. Calls made with the new client will not trigger email or webhook notifications
     * @returns {BoxClient}
     */
    withSuppressedNotifications() {
        return new BoxClient({
            auth: this.auth,
            networkSession: this.networkSession.withAdditionalHeaders({
                ['Box-Notifications']: 'off',
            }),
        });
    }
    /**
       * Create a new client with a custom set of headers that will be included in every API call
       * @param {{
          readonly [key: string]: string;
      }} extraHeaders Custom set of headers that will be included in every API call
       * @returns {BoxClient}
       */
    withExtraHeaders(extraHeaders = {}) {
        return new BoxClient({
            auth: this.auth,
            networkSession: this.networkSession.withAdditionalHeaders(extraHeaders),
        });
    }
    /**
     * Create a new client with a custom set of base urls that will be used for every API call
     * @param {BaseUrlsInput} baseUrlsInput Custom set of base urls that will be used for every API call
     * @returns {BoxClient}
     */
    withCustomBaseUrls(baseUrlsInput) {
        const baseUrls = new baseUrls_1.BaseUrls({
            baseUrl: baseUrlsInput.baseUrl,
            uploadUrl: baseUrlsInput.uploadUrl,
            oauth2Url: baseUrlsInput.oauth2Url,
        });
        return new BoxClient({
            auth: this.auth,
            networkSession: this.networkSession.withCustomBaseUrls(baseUrls),
        });
    }
    /**
     * Create a new client with a custom proxy that will be used for every API call
     * @param {ProxyConfig} config
     * @returns {BoxClient}
     */
    withProxy(config) {
        return new BoxClient({
            auth: this.auth,
            networkSession: this.networkSession.withProxy(config),
        });
    }
    /**
     * Create a new client with a custom set of agent options that will be used for every API call
     * @param {AgentOptions} agentOptions Custom set of agent options that will be used for every API call
     * @returns {BoxClient}
     */
    withCustomAgentOptions(agentOptions) {
        return new BoxClient({
            auth: this.auth,
            networkSession: this.networkSession.withCustomAgentOptions(agentOptions),
        });
    }
    /**
     * Create a new client with a custom set of interceptors that will be used for every API call
     * @param {readonly Interceptor[]} interceptors Custom set of interceptors that will be used for every API call
     * @returns {BoxClient}
     */
    withInterceptors(interceptors) {
        return new BoxClient({
            auth: this.auth,
            networkSession: this.networkSession.withInterceptors(interceptors),
        });
    }
}
exports.BoxClient = BoxClient;
//# sourceMappingURL=client.js.map