getAutoSuggestWithHttpInfo method

Future<Response> getAutoSuggestWithHttpInfo(
  1. int accountId,
  2. String brUid2,
  3. String catalogViews,
  4. String q,
  5. String url,
  6. String refUrl, {
  7. String? authKey,
  8. String? requestId,
  9. String? requestType,
  10. String? callback,
  11. String? userAgent,
  12. String? userId,
})

Autosuggest guides site visitors by providing search term suggestions, which are sometimes called autocomplete or type-ahead, in a dropdown list as visitors type in a search box. These suggestions become increasingly refined with each character entered. When visitors see a suggested query in the dropdown list, they can stop typing and select the query.

Note: This method returns the HTTP Response.

Parameters:

  • int accountId (required): Your site's numerical Bloomreach account ID. Your Bloomreach representative gives your site's account ID to you before or during your integration kickoff meeting.

  • String brUid2 (required): A first-party cookie created by the Bloomreach tracking pixel library (BrTrk). This cookie creates a unique, anonymous identifier for every browser or device.

  • String catalogViews (required): A list of catalog views that you want to see in your suggestions. You must specify the catalog name within the catalog view. For Product catalogs, the catalog name is the same value as your domain_key.A catalog_views value contains the view_ids within a catalog separated by a colon. If you pass multiple catalogs in catalog_views, they must be pipe-separated. Attributes suggestions are enabled for the first two catalogs mentioned as part of catalog_views and only for the first view passed in each of the first two catalogs. For example \&catalog_views=product:store1,store2|recipe:premium|articles would return text and attribute suggestions for the product catalog in the store1 view, and for the recipe catalog in the premium view; only text suggestions will be displayed for the articles catalog.

  • String q (required): Your site visitor's partial search query that Autosuggest should operate on.You can percent encode spaces between terms as %20, or you can leave the spaces unencoded.

  • String url (required): The absolute URL of the page where the request is initiated. Do not use a relative URL.

  • String refUrl (required): The URL of the page or HTTP referrer where the request is started..

  • String authKey: The Bloomreach-provided authentication key for the Bloomreach account that's sending the request.

  • String requestId: An ID to track site visitor clicks. We recommend that you generate unique, random values of 13 digits to enable click-tracking.

  • String requestType: The type of API request. Value should be suggest for Autosuggest requests.

  • String callback: Indicates whether to return data wrapped in the function for cross-origin requests. For server-side requests, use the value br_server. For native-app requests, use the value br_app.

  • String userAgent: The user agent of the browser that's making the search request.Make sure that this value in your API request is the same as the value in the original request from your user. We optimize pages in part by crawling and gathering data, and the original user_agent lets us distinguish between our internal Bloomreach users who QA pages and everyone else who visits your site.

  • String userId: The universal customer ID of the user. You only need to pass this field if your particular integration tracks customers this way. The parameter captures user IDs from the customer side, and reuses the information when powering apps or enhancing cross-device linking. In this way, Bloomreach recognizes users in a way that's aligned with your system.Use an anonymous string. Don't use email or other personally identifiable information.If you do not track users this way, then omit this field.

Implementation

Future<Response> getAutoSuggestWithHttpInfo(
  int accountId,
  String brUid2,
  String catalogViews,
  String q,
  String url,
  String refUrl, {
  String? authKey,
  String? requestId,
  String? requestType,
  String? callback,
  String? userAgent,
  String? userId,
}) async {
  // ignore: prefer_const_declarations
  final path = r'/suggest/';

  // ignore: prefer_final_locals
  Object? postBody;

  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{};
  final formParams = <String, String>{};

  queryParams.addAll(_queryParams('', 'account_id', accountId));
  queryParams.addAll(_queryParams('', '_br_uid_2', brUid2));
  queryParams.addAll(_queryParams('', 'catalog_views', catalogViews));
  queryParams.addAll(_queryParams('', 'q', q));
  queryParams.addAll(_queryParams('', 'url', url));
  queryParams.addAll(_queryParams('', 'ref_url', refUrl));
  if (authKey != null) {
    queryParams.addAll(_queryParams('', 'auth_key', authKey));
  }
  if (requestId != null) {
    queryParams.addAll(_queryParams('', 'request_id', requestId));
  }
  if (requestType != null) {
    queryParams.addAll(_queryParams('', 'request_type', requestType));
  }
  if (callback != null) {
    queryParams.addAll(_queryParams('', 'callback', callback));
  }
  if (userAgent != null) {
    queryParams.addAll(_queryParams('', 'user_agent', userAgent));
  }
  if (userId != null) {
    queryParams.addAll(_queryParams('', 'user_id', userId));
  }

  const contentTypes = <String>[];

  return apiClient.invokeAPI(
    path,
    'GET',
    queryParams,
    postBody,
    headerParams,
    formParams,
    contentTypes.isEmpty ? null : contentTypes.first,
  );
}