Refactor file retrieval and annotation methods to simplify path generation and improve error handling
This commit is contained in:
@@ -213,11 +213,14 @@ class FileService {
|
||||
String orgId,
|
||||
String fileId,
|
||||
) async {
|
||||
if (orgId.isEmpty || fileId.isEmpty) {
|
||||
throw Exception('OrgId and fileId cannot be empty');
|
||||
if (fileId.isEmpty) {
|
||||
throw Exception('fileId cannot be empty');
|
||||
}
|
||||
final path = orgId.isEmpty
|
||||
? '/user/files/$fileId/edit'
|
||||
: '/orgs/$orgId/files/$fileId/edit';
|
||||
return await _apiClient.get(
|
||||
'/orgs/$orgId/files/$fileId/edit',
|
||||
path,
|
||||
fromJson: (data) => EditorSession.fromJson(data),
|
||||
);
|
||||
}
|
||||
@@ -227,11 +230,14 @@ class FileService {
|
||||
String fileId,
|
||||
List<Annotation> annotations,
|
||||
) async {
|
||||
if (orgId.isEmpty || fileId.isEmpty) {
|
||||
throw Exception('OrgId and fileId cannot be empty');
|
||||
if (fileId.isEmpty) {
|
||||
throw Exception('fileId cannot be empty');
|
||||
}
|
||||
final path = orgId.isEmpty
|
||||
? '/user/files/$fileId/annotations'
|
||||
: '/orgs/$orgId/files/$fileId/annotations';
|
||||
await _apiClient.post(
|
||||
'/orgs/$orgId/files/$fileId/annotations',
|
||||
path,
|
||||
data: {
|
||||
'annotations': annotations.map((a) => a.toJson()).toList(),
|
||||
'baseVersionId': '1', // mock
|
||||
|
||||
Reference in New Issue
Block a user