getProfileRecommendations method

Future<GetProfileRecommendationsResponse> getProfileRecommendations({
  1. required String domainName,
  2. required String profileId,
  3. required String recommenderName,
  4. List<String>? candidateIds,
  5. Map<String, String>? context,
  6. int? maxResults,
  7. MetadataConfig? metadataConfig,
  8. List<RecommenderFilter>? recommenderFilters,
  9. List<RecommenderPromotionalFilter>? recommenderPromotionalFilters,
})

Fetches the recommendations for a profile in the input Customer Profiles domain. Fetches all the profile recommendations

May throw AccessDeniedException. May throw BadRequestException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException.

Parameter domainName : The unique name of the domain.

Parameter profileId : The unique identifier of the profile for which to retrieve recommendations.

Parameter recommenderName : The unique name of the recommender.

Parameter candidateIds : A list of item IDs to rank for the user. Use this when you want to re-rank a specific set of items rather than getting recommendations from the full item catalog. Required for personalized-ranking use cases.

Parameter context : The contextual metadata used to provide dynamic runtime information to tailor recommendations.

Parameter maxResults : The maximum number of recommendations to return. The default value is 10.

Parameter metadataConfig : Configuration for including item metadata in the recommendation response. Use this to specify which metadata columns to return alongside recommended items.

Parameter recommenderFilters : A list of filters to apply to the returned recommendations. Filters define criteria for including or excluding items from the recommendation results.

Parameter recommenderPromotionalFilters : A list of promotional filters to apply to the recommendations. Promotional filters allow you to promote specific items within a configurable subset of recommendation results.

Implementation

Future<GetProfileRecommendationsResponse> getProfileRecommendations({
  required String domainName,
  required String profileId,
  required String recommenderName,
  List<String>? candidateIds,
  Map<String, String>? context,
  int? maxResults,
  MetadataConfig? metadataConfig,
  List<RecommenderFilter>? recommenderFilters,
  List<RecommenderPromotionalFilter>? recommenderPromotionalFilters,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    500,
  );
  final $payload = <String, dynamic>{
    'RecommenderName': recommenderName,
    if (candidateIds != null) 'CandidateIds': candidateIds,
    if (context != null) 'Context': context,
    if (maxResults != null) 'MaxResults': maxResults,
    if (metadataConfig != null) 'MetadataConfig': metadataConfig,
    if (recommenderFilters != null) 'RecommenderFilters': recommenderFilters,
    if (recommenderPromotionalFilters != null)
      'RecommenderPromotionalFilters': recommenderPromotionalFilters,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/domains/${Uri.encodeComponent(domainName)}/profiles/${Uri.encodeComponent(profileId)}/recommendations',
    exceptionFnMap: _exceptionFns,
  );
  return GetProfileRecommendationsResponse.fromJson(response);
}