encodeRequest static method
Uint8List
encodeRequest({
- required String operation,
- required PeerId ownerPeerId,
- String? path,
- String? key,
- Map<
String, String> ? headers, - Uint8List? body,
- String? name,
- Map<
String, dynamic> ? filter, - String? sortField,
- bool? sortAsc,
- int? limit,
- int? offset,
- String? cursor,
- bool wantTotal = false,
- String? visibility,
- String? accessAction,
- String? readerPeerId,
Encode collection request
Implementation
static Uint8List encodeRequest({
required String operation,
required PeerId ownerPeerId,
String? path,
String? key,
Map<String, String>? headers,
Uint8List? body,
String? name,
Map<String, dynamic>? filter,
String? sortField,
bool? sortAsc,
int? limit,
int? offset,
String? cursor,
bool wantTotal = false,
String? visibility,
String? accessAction,
String? readerPeerId,
}) {
final data = <String, dynamic>{
'operation': operation,
'ownerPeerId': ownerPeerId.toString(),
};
if (path != null) data['path'] = path;
if (key != null) data['key'] = key;
if (headers != null && headers.isNotEmpty) data['headers'] = headers;
if (body != null) data['body'] = base64Encode(body);
if (name != null) data['name'] = name;
if (filter != null) data['filter'] = filter;
if (sortField != null) data['sortField'] = sortField;
if (sortAsc != null) data['sortAsc'] = sortAsc;
if (limit != null) data['limit'] = limit;
if (offset != null) data['offset'] = offset;
if (cursor != null) data['cursor'] = cursor;
if (wantTotal) data['wantTotal'] = true;
if (visibility != null) data['visibility'] = visibility;
if (accessAction != null) data['accessAction'] = accessAction;
if (readerPeerId != null) data['readerPeerId'] = readerPeerId;
final json = jsonEncode(data);
return Uint8List.fromList(utf8.encode(json));
}