getObjects method

GetObjects

This will execute the query and retrieve data from Algolia with AlgoliaQuerySnapshot response.

Implementation

Future<AlgoliaQuerySnapshot> getObjects() async {
  if (_parameters.containsKey('minimumAroundRadius')) {
    assert(
        (_parameters.containsKey('aroundLatLng') ||
            _parameters.containsKey('aroundLatLngViaIP')),
        'This setting only works within the context of a circular geo search, enabled by `aroundLatLng` or `aroundLatLngViaIP`.');
  }
  if (_parameters['attributesToRetrieve'] == null) {
    _copyWithParameters(<String, dynamic>{
      'attributesToRetrieve': const ['*']
    });
  }
  var response = await algolia._apiCall(
    ApiRequestType.post,
    'indexes/$encodedIndex/query',
    data: _parameters,
  );
  Map<String, dynamic> body = json.decode(response.body);
  if (!(response.statusCode >= 200 && response.statusCode < 300)) {
    throw AlgoliaError._(body, response.statusCode);
  }

  return AlgoliaQuerySnapshot._(algolia, _index, body);
}