submission
This commit is contained in:
@@ -27,6 +27,10 @@ abstract class SubmissionsRemoteDataSource {
|
||||
int limitPageLength = 0,
|
||||
});
|
||||
|
||||
/// Fetch project detail by name
|
||||
/// Returns the full project detail as a model
|
||||
Future<ProjectSubmissionModel> getSubmissionDetail(String name);
|
||||
|
||||
/// Create or update a project submission
|
||||
/// Returns the project name (ID) from the API response
|
||||
Future<String> saveSubmission(ProjectSubmissionRequest request);
|
||||
@@ -170,6 +174,42 @@ class SubmissionsRemoteDataSourceImpl implements SubmissionsRemoteDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get project detail by name
|
||||
///
|
||||
/// Calls: POST /api/method/building_material.building_material.api.project.get_detail
|
||||
/// Body: { "name": "#DA00011" }
|
||||
/// Response: { "message": { "success": true, "data": {...} } }
|
||||
/// Returns: Full project detail as model
|
||||
@override
|
||||
Future<ProjectSubmissionModel> getSubmissionDetail(String name) async {
|
||||
try {
|
||||
final response = await _dioClient.post<Map<String, dynamic>>(
|
||||
'${ApiConstants.frappeApiMethod}${ApiConstants.getProjectDetail}',
|
||||
data: {'name': name},
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
throw Exception('No data received from getProjectDetail API');
|
||||
}
|
||||
|
||||
// API returns: { "message": { "success": true, "data": {...} } }
|
||||
final message = data['message'] as Map<String, dynamic>?;
|
||||
if (message == null) {
|
||||
throw Exception('No message field in getProjectDetail response');
|
||||
}
|
||||
|
||||
final detailData = message['data'] as Map<String, dynamic>?;
|
||||
if (detailData == null) {
|
||||
throw Exception('No data field in getProjectDetail response');
|
||||
}
|
||||
|
||||
return ProjectSubmissionModel.fromJson(detailData);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get project detail: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// Save (create/update) a project submission
|
||||
///
|
||||
/// Calls: POST /api/method/building_material.building_material.api.project.save
|
||||
@@ -227,7 +267,7 @@ class SubmissionsRemoteDataSourceImpl implements SubmissionsRemoteDataSource {
|
||||
final fileName = filePath.split('/').last;
|
||||
final formData = FormData.fromMap({
|
||||
'file': await MultipartFile.fromFile(filePath, filename: fileName),
|
||||
'is_private': '1',
|
||||
'is_private': '0',
|
||||
'folder': 'Home/Attachments',
|
||||
'doctype': 'Architectural Project',
|
||||
'docname': projectName,
|
||||
|
||||
Reference in New Issue
Block a user