setData method
Writes to the object referred to by this AlgoliaObjectReference.
If the object does not yet exist, it will be created.
Implementation
Future<AlgoliaTask> setData(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 += '/$encodedObjectID';
}
if (data['objectID'] != null && _objectId == null) {
url += "/${Uri.encodeFull(data['objectID'])}";
} else if (data['objectID'] != null) {
data.remove('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);
}