JProperty Build(AggregationCriteria criteria)
        {
            JObject aggregateObject = new JObject
            {
                { "field", criteria.Field }
            };

            if (connection.Options.SearchSizeDefaultForAggregation.HasValue)
            {
                aggregateObject.Add("size", connection.Options.SearchSizeDefaultForAggregation);
            }

            return(new JProperty(criteria.Name, new JObject(
                                     new JProperty(criteria.Field, new JObject(
                                                       new JProperty("terms", aggregateObject))))));
        }
 public async Task <FlightCancellationStatisticsResponse> FlightCancellationStatistics(string timePeriod,
                                                                                       AggregationCriteria typeMatching,
                                                                                       string identFilter = null,
                                                                                       int howMany        = 15,
                                                                                       int offset         = 0)
 {
     return(await client.HttpRequest <FlightCancellationStatisticsResponse>("FlightCancellationStatistics", new {
         time_period = timePeriod,
         type_matching = Enum.GetName(typeof(AggregationCriteria), typeMatching).ToLower(),
         ident_filter = identFilter,
         howMany = howMany,
         offset = offset
     }));
 }
        public async Task FlightCancellationStatistics_Should_Return_Response(string timePeriod, AggregationCriteria typeMatching)
        {
            var response = await _flightAwareService.FlightCancellationStatistics(timePeriod, typeMatching);

            Assert.NotNull(response);
            Assert.NotNull(response.Results);
        }