getEntitlements method

Future<GetEntitlementsResult> getEntitlements({
  1. required String productCode,
  2. Map<GetEntitlementFilterName, List<String>>? filter,
  3. int? maxResults,
  4. String? nextToken,
})

GetEntitlements retrieves entitlement values for a given product. The results can be filtered based on customer identifier or product dimensions.

May throw InvalidParameterException. May throw ThrottlingException. May throw InternalServiceErrorException.

Parameter productCode : Product code is used to uniquely identify a product in AWS Marketplace. The product code will be provided by AWS Marketplace when the product listing is created.

Parameter filter : Filter is used to return entitlements for a specific customer or for a specific dimension. Filters are described as keys mapped to a lists of values. Filtered requests are unioned for each value in the value list, and then intersected for each filter key.

Parameter maxResults : The maximum number of items to retrieve from the GetEntitlements operation. For pagination, use the NextToken field in subsequent calls to GetEntitlements.

Parameter nextToken : For paginated calls to GetEntitlements, pass the NextToken from the previous GetEntitlementsResult.

Implementation

Future<GetEntitlementsResult> getEntitlements({
  required String productCode,
  Map<GetEntitlementFilterName, List<String>>? filter,
  int? maxResults,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(productCode, 'productCode');
  _s.validateStringLength(
    'productCode',
    productCode,
    1,
    255,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSMPEntitlementService.GetEntitlements'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ProductCode': productCode,
      if (filter != null)
        'Filter': filter.map((k, e) => MapEntry(k.toValue(), e)),
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return GetEntitlementsResult.fromJson(jsonResponse.body);
}