public async Task <EngageResponse> Engage(string where = "", string sessionId = "", int page = 0)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotIsNullOrWhiteSpace("where", where);
            parameters.AddIfNotIsNullOrWhiteSpace("session_id", sessionId);
            parameters.AddIfNotIsNullOrWhiteSpace("page", page.ToString());

            var endpoint = new Endpoint().Create(this.ApiKey, this.ApiSecret)
                           .ForMethod(MethodEnum.Engage)
                           .WithParameters(parameters)
                           .Build();

            var response = await this.httpClient.GetAsync(endpoint);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsAsync <EngageResponse>());
            }

            return(null);
        }
        public async Task <SegmentationResponse> Segmentation(string eventName, DateTime from, DateTime to)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotIsNullOrWhiteSpace("event", eventName);
            parameters.AddIfNotIsNullOrWhiteSpace("from_date", from.ToString("yyyy-MM-dd"));
            parameters.AddIfNotIsNullOrWhiteSpace("to_date", to.ToString("yyyy-MM-dd"));

            var endpoint = new Endpoint().Create(this.ApiKey, this.ApiSecret)
                           .ForMethod(MethodEnum.Segmentation)
                           .WithParameters(parameters)
                           .Build();

            var response = await this.httpClient.GetAsync(endpoint);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsAsync <SegmentationResponse>());
            }

            return(null);
        }
        public async Task <Stream> ExportStream(DateTime from, DateTime to, ICollection <string> events = null, string where = "", string bucket = "")
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotIsNullOrWhiteSpace("from_date", from.ToString("yyyy-MM-dd"));
            parameters.AddIfNotIsNullOrWhiteSpace("to_date", to.ToString("yyyy-MM-dd"));
            parameters.AddIfNotIsNullOrWhiteSpace("where", where);

            var endpoint = new Endpoint().Create(this.ApiKey, this.ApiSecret)
                           .ForMethod(MethodEnum.Export)
                           .WithParameters(parameters)
                           .Build();

            this.httpClient.TimeOut = TimeSpan.FromHours(1);

            var response = await this.httpClient.GetAsync(endpoint, HttpCompletionOption.ResponseHeadersRead);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsStreamAsync());
            }

            return(null);
        }