getCredits method
Returns the list of Amazon Web Services account credits for the specified account. Each credit includes its identifier, type, monetary amounts, applicable products, expiration, sharing configuration, and current enabled status.
When the caller is the management account of a consolidated billing family
and payerAccountFlag is true, the response
aggregates credits across the entire family. Otherwise, the response
includes only credits owned by the account specified in
accountId.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ThrottlingException.
May throw ValidationException.
Parameter accountId :
The Amazon Web Services account ID. Must be a 12-digit numeric string.
Parameter startDate :
The start date for the credit period as Unix epoch seconds. Must be a past
date that is not more than one year before the current date.
Parameter endDate :
The end date for the credit period as Unix epoch seconds. Must not be a
future date and must be on or after startDate. Defaults to
the current date when omitted.
Parameter payerAccountFlag :
When true and the caller is the management account, the
response aggregates credits across the entire consolidated billing family.
When false or omitted, returns only credits for the specified
accountId.
Implementation
Future<GetCreditsResponse> getCredits({
required String accountId,
required DateTime startDate,
DateTime? endDate,
bool? payerAccountFlag,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'AWSBilling.GetCredits'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'accountId': accountId,
'startDate': unixTimestampToJson(startDate),
if (endDate != null) 'endDate': unixTimestampToJson(endDate),
if (payerAccountFlag != null) 'payerAccountFlag': payerAccountFlag,
},
);
return GetCreditsResponse.fromJson(jsonResponse.body);
}