getRevenueStatistics method

Future<GetRevenueStatisticsResponse> getRevenueStatistics({
  1. required Currency currency,
  2. required Scope scope,
  3. required RankingStatisticType statisticType,
  4. required TimeWindow timeWindow,
  5. List<MonetizationFilter>? filters,
  6. GroupByType? groupBy,
  7. int? limit,
  8. String? nextMarker,
  9. RankingSortBy? sortBy,
  10. SortOrder? sortOrder,
})

Retrieves ranked monetization statistics. Use the StatisticType parameter to specify the ranking: TOP_SOURCES_BY_REVENUE for top sources by revenue, or TOP_PATHS_BY_REVENUE for top content paths by revenue. This operation is only available for CLOUDFRONT scope. The maximum supported time window is 90 days. When no CurrencyMode filter is provided, results default to REAL. To retrieve test data, include a CurrencyMode filter with the value TEST.

May throw WAFInternalErrorException. May throw WAFInvalidOperationException. May throw WAFInvalidParameterException. May throw WAFNonexistentItemException.

Parameter currency : The currency for the revenue amounts in the response.

Parameter scope : Specifies whether this is for a Amazon CloudFront distribution (CLOUDFRONT) or for a regional application (REGIONAL).

Parameter statisticType : TOP_SOURCES_BY_REVENUE ranks revenue from AI bot traffic, grouped by the dimension you specify in the GroupBy parameter (NAME, CATEGORY, INTENT, ORGANIZATION, or WEBACL); GroupBy is required for this statistic type. TOP_PATHS_BY_REVENUE ranks revenue by path.

Parameter timeWindow : The time range for the query. Specify start and end timestamps.

Parameter filters : Optional filters to narrow the results.

Parameter groupBy : The dimension to group results by: NAME, CATEGORY, INTENT, ORGANIZATION, or WEBACL. Required when StatisticType is TOP_SOURCES_BY_REVENUE. Not required for TOP_PATHS_BY_REVENUE, where results are grouped by content path. If StatisticType is TOP_SOURCES_BY_REVENUE and GroupBy is omitted, the request is rejected with a WAFInvalidParameterException.

Parameter limit : The maximum number of results to return.

Parameter nextMarker : When you get a paginated response, this marker indicates that additional results are available. Use it in a subsequent request to retrieve the next page of results.

Parameter sortBy : The field to sort results by: REVENUE, PERCENTAGE, or NAME.

Parameter sortOrder : The sort order: ASC for ascending or DESC for descending.

Implementation

Future<GetRevenueStatisticsResponse> getRevenueStatistics({
  required Currency currency,
  required Scope scope,
  required RankingStatisticType statisticType,
  required TimeWindow timeWindow,
  List<MonetizationFilter>? filters,
  GroupByType? groupBy,
  int? limit,
  String? nextMarker,
  RankingSortBy? sortBy,
  SortOrder? sortOrder,
}) async {
  _s.validateNumRange(
    'limit',
    limit,
    1,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSWAF_20190729.GetRevenueStatistics'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Currency': currency.value,
      'Scope': scope.value,
      'StatisticType': statisticType.value,
      'TimeWindow': timeWindow,
      if (filters != null) 'Filters': filters,
      if (groupBy != null) 'GroupBy': groupBy.value,
      if (limit != null) 'Limit': limit,
      if (nextMarker != null) 'NextMarker': nextMarker,
      if (sortBy != null) 'SortBy': sortBy.value,
      if (sortOrder != null) 'SortOrder': sortOrder.value,
    },
  );

  return GetRevenueStatisticsResponse.fromJson(jsonResponse.body);
}