batchReplaceBlogPostSegments method
Batch replaces all blog post segments with the list of segments
Implementation
Future<void> batchReplaceBlogPostSegments(int postId, Iterable<BlogPostSegment> segments) async {
final postData = {
'segments': segments.map((e) {
final data = <String, dynamic>{
'position': e.position,
'blogPostId': postId,
};
if (e.file != null) {
data['file'] = e.file!.id;
data['link'] = e.link;
} else if (e.gallery != null) {
data['gallery '] = e.gallery!.id;
} else {
data['html'] = e.html ?? '';
}
return data;
}).toList(),
};
await _put('/api/blog/post/$postId/segment', data: postData);
}