conversion method

Future conversion (
  1. List<String> objects,
  2. {String queryId}
)
inherited

use this methods to record a search conversion

Implementation

Future conversion(List<String> objects, {String queryId}) async {
  String queryID = queryId;
  if (queryId == null || queryId == "") {
    queryID = this.queryId;
  }
  if (this.appbaseConfig != null &&
      this.appbaseConfig.recordAnalytics == true &&
      queryID != null &&
      queryID != "") {
    try {
      final Map requestBody = {
        'conversion_on': objects,
        'query_id': queryID,
      };
      final String url = "${this.url}/${this..index}/_analytics/conversion";
      final res = await http.put(
        url,
        headers: this.headers,
        body: jsonEncode(requestBody),
      );
      return Future.value(res);
    } catch (e) {
      return Future.error(e);
    }
  }
  return Future.error("Query ID not found. Make sure analytics is enabled");
}