create submission
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
/// Project Submission Request Model
|
||||
///
|
||||
/// Request model for creating/updating project submissions via API.
|
||||
/// Based on API: building_material.building_material.api.project.save
|
||||
library;
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
/// Project Submission Request
|
||||
///
|
||||
/// Used to create or update project submissions.
|
||||
class ProjectSubmissionRequest {
|
||||
/// Project ID (optional for new, required for update)
|
||||
final String? name;
|
||||
|
||||
/// Project name/title (API: designed_area)
|
||||
final String designedArea;
|
||||
|
||||
/// Project address (API: address_of_project)
|
||||
final String addressOfProject;
|
||||
|
||||
/// Project owner name (API: project_owner)
|
||||
final String projectOwner;
|
||||
|
||||
/// Design firm name (API: design_firm)
|
||||
final String? designFirm;
|
||||
|
||||
/// Construction contractor name (API: contruction_contractor)
|
||||
final String? contractionContractor;
|
||||
|
||||
/// Design area in m² (API: design_area)
|
||||
final double designArea;
|
||||
|
||||
/// Products included in the design (API: products_included_in_the_design)
|
||||
final String productsIncludedInTheDesign;
|
||||
|
||||
/// Project progress ID from ProjectProgress.id (API: project_progress)
|
||||
final String projectProgress;
|
||||
|
||||
/// Expected commencement date (API: expected_commencement_date)
|
||||
final DateTime? expectedCommencementDate;
|
||||
|
||||
/// Project description (API: description)
|
||||
final String? description;
|
||||
|
||||
/// Request date (API: request_date)
|
||||
final DateTime? requestDate;
|
||||
|
||||
const ProjectSubmissionRequest({
|
||||
this.name,
|
||||
required this.designedArea,
|
||||
required this.addressOfProject,
|
||||
required this.projectOwner,
|
||||
this.designFirm,
|
||||
this.contractionContractor,
|
||||
required this.designArea,
|
||||
required this.productsIncludedInTheDesign,
|
||||
required this.projectProgress,
|
||||
this.expectedCommencementDate,
|
||||
this.description,
|
||||
this.requestDate,
|
||||
});
|
||||
|
||||
/// Convert to JSON for API request
|
||||
Map<String, dynamic> toJson() {
|
||||
final dateFormat = DateFormat('yyyy-MM-dd');
|
||||
final dateTimeFormat = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||
|
||||
return {
|
||||
if (name != null) 'name': name,
|
||||
'designed_area': designedArea,
|
||||
'address_of_project': addressOfProject,
|
||||
'project_owner': projectOwner,
|
||||
if (designFirm != null) 'design_firm': designFirm,
|
||||
if (contractionContractor != null)
|
||||
'contruction_contractor': contractionContractor,
|
||||
'design_area': designArea,
|
||||
'products_included_in_the_design': productsIncludedInTheDesign,
|
||||
'project_progress': projectProgress,
|
||||
if (expectedCommencementDate != null)
|
||||
'expected_commencement_date': dateFormat.format(expectedCommencementDate!),
|
||||
if (description != null) 'description': description,
|
||||
'request_date': dateTimeFormat.format(requestDate ?? DateTime.now()),
|
||||
};
|
||||
}
|
||||
|
||||
/// Create a copy with updated fields
|
||||
ProjectSubmissionRequest copyWith({
|
||||
String? name,
|
||||
String? designedArea,
|
||||
String? addressOfProject,
|
||||
String? projectOwner,
|
||||
String? designFirm,
|
||||
String? contractionContractor,
|
||||
double? designArea,
|
||||
String? productsIncludedInTheDesign,
|
||||
String? projectProgress,
|
||||
DateTime? expectedCommencementDate,
|
||||
String? description,
|
||||
DateTime? requestDate,
|
||||
}) {
|
||||
return ProjectSubmissionRequest(
|
||||
name: name ?? this.name,
|
||||
designedArea: designedArea ?? this.designedArea,
|
||||
addressOfProject: addressOfProject ?? this.addressOfProject,
|
||||
projectOwner: projectOwner ?? this.projectOwner,
|
||||
designFirm: designFirm ?? this.designFirm,
|
||||
contractionContractor: contractionContractor ?? this.contractionContractor,
|
||||
designArea: designArea ?? this.designArea,
|
||||
productsIncludedInTheDesign:
|
||||
productsIncludedInTheDesign ?? this.productsIncludedInTheDesign,
|
||||
projectProgress: projectProgress ?? this.projectProgress,
|
||||
expectedCommencementDate:
|
||||
expectedCommencementDate ?? this.expectedCommencementDate,
|
||||
description: description ?? this.description,
|
||||
requestDate: requestDate ?? this.requestDate,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user