<commit_before>﻿using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.Converter;
using Box.V2.Models;
using Box.V2.Extensions;
using Box.V2.Services;
using Box.V2.Utility;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
using System.Net;

namespace Box.V2.Managers
{
    /// <summary>
    /// The manager that represents the events endpoint
    /// </summary>
    public class BoxEventsManager : BoxResourceManager
    {
        public const string ENTERPRISE_EVENTS_STREAM_TYPE = "admin_logs";
        public readonly LRUCache<string,bool> USER_EVENTS_DEDUPE_CACHE = new LRUCache<string, bool>(1000);

        public BoxEventsManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool? suppressNotifications = null)
            : base(config, service, converter, auth, asUser, suppressNotifications) { }

        /// <summary>
        /// Retrieve a chunk of Enterprise Events.  You must be using a token that is scoped to admin level in order to use this endpoint.
        /// </summary>
        /// <param name="limit">Limits the number of events returned (defaults to 500).</param>
        /// <param name="streamPosition">The starting position for fetching the events. This is used in combination with the limit to determine which events to return to the caller. Use the results from the next_stream_position of your last call to get the next set of events.</param>
        /// <param name="eventTypes">Events to filter by.</param>
        /// <param name="createdAfter">A lower bound on the timestamp of the events returned.</param>
        /// <param name="createdBefore">An upper bound on the timestamp of the events returned.</param>
        /// <returns></returns>
        public async Task<BoxEventCollection<BoxEnterpriseEvent>> EnterpriseEventsAsync(int limit = 500,
                                                                        string streamPosition = null,
                                                                        IEnumerable<string> eventTypes = null,
                                                                        DateTime? createdAfter = null,
                                                                        DateTime? createdBefore = null)
        {
            var createdAfterString =  createdAfter.Value.ToString(Constants.RFC3339DateFormat);
            var createdBeforeString = createdBefore.Value.ToString(Constants.RFC3339DateFormat);

            BoxRequest request = new BoxRequest(_config.EventsUri)<commit_msg>fixed changes to events manager<commit_after>﻿using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.Converter;
using Box.V2.Models;
using Box.V2.Extensions;
using Box.V2.Services;
using Box.V2.Utility;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
using System.Net;

namespace Box.V2.Managers
{
    /// <summary>
    /// The manager that represents the events endpoint
    /// </summary>
    public class BoxEventsManager : BoxResourceManager
    {
        public const string ENTERPRISE_EVENTS_STREAM_TYPE = "admin_logs";
        public readonly LRUCache<string,bool> USER_EVENTS_DEDUPE_CACHE = new LRUCache<string, bool>(1000);

        public BoxEventsManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool? suppressNotifications = null)
            : base(config, service, converter, auth, asUser, suppressNotifications) { }

        /// <summary>
        /// Retrieve a chunk of Enterprise Events.  You must be using a token that is scoped to admin level in order to use this endpoint.
        /// </summary>
        /// <param name="limit">Limits the number of events returned (defaults to 500).</param>
        /// <param name="streamPosition">The starting position for fetching the events. This is used in combination with the limit to determine which events to return to the caller. Use the results from the next_stream_position of your last call to get the next set of events.</param>
        /// <param name="eventTypes">Events to filter by.</param>
        /// <param name="createdAfter">A lower bound on the timestamp of the events returned.</param>
        /// <param name="createdBefore">An upper bound on the timestamp of the events returned.</param>
        /// <returns></returns>
        public async Task<BoxEventCollection<BoxEnterpriseEvent>> EnterpriseEventsAsync(int limit = 500,
                                                                        string streamPosition = null,
                                                                        IEnumerable<string> eventTypes = null,
                                                                        DateTime? createdAfter = null,
                                                                        DateTime? createdBefore = null)
        {

            var createdAfterString = createdAfter.HasValue ? createdAfter.Value.ToString(Constants.RFC3339DateFormat) : null;
            var createdBeforeString = createdBefore.HasValue ? createdBefore.Value.ToString(Constants.RFC3339DateFormat) : null;

            // url encode 
            if (!string.IsNullOrEmpty(createdAfterString))
            {
                createdAfterString = WebUtility.UrlEncode(createdAfterString);
            }

            if (!string.IsNullOrEmpty(createdBeforeString))
            {
                createdBeforeString = WebUtility.UrlEncode(createdBeforeString);
            }

            BoxRequest request = new BoxRequest(_config.EventsUri)
{'fraction_non_alphanumeric': 0.08225491934054245, 'fraction_numerical': 0.009218223719198724, 'mean_word_length': 2.2406662837449742, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2472836', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1297, 'n_words': 429}