encodeRequest static method
Encode document request (GET, PUT, HEAD)
Implementation
static Uint8List encodeRequest({
required String operation,
required PeerId ownerPeerId,
required String path,
Map<String, String>? headers,
Uint8List? body,
String? visibility,
String? accessAction,
int? history,
int? versionNumber,
int? maxVersions,
}) {
final data = <String, dynamic>{
'operation': operation,
'ownerPeerId': ownerPeerId.toString(),
'path': path,
};
if (maxVersions != null) {
data['maxVersions'] = maxVersions;
}
if (versionNumber != null) {
data['versionNumber'] = versionNumber;
}
if (history != null) {
data['history'] = history;
}
if (visibility != null) {
data['visibility'] = visibility;
}
if (accessAction != null) {
data['accessAction'] = accessAction;
}
if (headers != null && headers.isNotEmpty) {
data['headers'] = headers;
}
if (body != null) {
data['body'] = base64Encode(body);
}
final json = jsonEncode(data);
return Uint8List.fromList(utf8.encode(json));
}