getDocumentRevision method
Gets a documents current revision, returns null if the document does not exist.
Implementation
Future<dynamic> getDocumentRevision(String? id) {
if (id == null) {
return _raiseException(WiltException.getDocRevNoId);
}
final completer = Completer<dynamic>();
head(id).then((dynamic res) {
final dynamic headers = WiltUserUtils.mapToJson(res.allResponseHeaders);
if (headers != null) {
final dynamic jsonHeaders =
jsonobject.JsonObjectLite<dynamic>.fromJsonString(headers);
if (jsonHeaders.containsKey(Wilt.etag)) {
String ver = jsonHeaders[Wilt.etag];
ver = ver.substring(1, ver.length - 1);
completer.complete(ver);
} else {
completer.complete(null);
}
} else {
completer.complete(null);
}
});
return completer.future;
}