updateData method
UpdateData
Updates fields in the object referred to by this AlgoliaObjectReference.
Values in data
may be of any supported Algolia type.
If no object exists yet, the update will fail.
Implementation
Future<AlgoliaTask> updateData(Map<String, dynamic> data) async {
assert(_index != null && _index != '*' && _index != '',
'IndexName is required, but it has `*` multiple flag or `null`.');
var url = 'indexes/$encodedIndex';
if (_objectId != null) {
url = '$url/$encodedObjectID';
}
data['objectID'] = _objectId;
var response = await algolia._apiCall(
ApiRequestType.put,
url,
data: data,
);
Map<String, dynamic> body = json.decode(response.body);
if (!(response.statusCode >= 200 && response.statusCode < 300)) {
throw AlgoliaError._(body, response.statusCode);
}
return AlgoliaTask._(algolia, _index, body);
}