getCreditAllocationHistory method

Future<GetCreditAllocationHistoryResponse> getCreditAllocationHistory({
  1. required String accountId,
  2. required DateTime endDate,
  3. required DateTime startDate,
  4. int? creditId,
  5. int? maxResults,
  6. String? nextToken,
})

Returns the per-billing-month allocation history for credits applied to an Amazon Web Services account's bills. Traverses the consolidated billing family to capture cross-account credit applications. Supports pagination and optional filtering to a single credit.

May throw AccessDeniedException. May throw InternalServerException. May throw ThrottlingException. May throw ValidationException.

Parameter accountId : The Amazon Web Services account ID whose allocation history to retrieve. Must be a 12-digit numeric string.

Parameter endDate : Inclusive end date as Unix epoch seconds.

Parameter startDate : Inclusive start date as Unix epoch seconds. Must be on or before endDate. The range from startDate to endDate cannot exceed 24 billing months.

Parameter creditId : Filters the result to a single credit. When omitted, returns allocation entries for all credits.

Parameter maxResults : The maximum number of records to return per page. Range: 1 to 1000. Default: 100.

Parameter nextToken : Pagination token from a previous response. Pass the value returned in nextToken to retrieve the next page of results.

Implementation

Future<GetCreditAllocationHistoryResponse> getCreditAllocationHistory({
  required String accountId,
  required DateTime endDate,
  required DateTime startDate,
  int? creditId,
  int? maxResults,
  String? nextToken,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSBilling.GetCreditAllocationHistory'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'accountId': accountId,
      'endDate': unixTimestampToJson(endDate),
      'startDate': unixTimestampToJson(startDate),
      if (creditId != null) 'creditId': creditId,
      if (maxResults != null) 'maxResults': maxResults,
      if (nextToken != null) 'nextToken': nextToken,
    },
  );

  return GetCreditAllocationHistoryResponse.fromJson(jsonResponse.body);
}