api integrate cont.
parent
a103eae1c1
commit
7a5db103e0
@ -0,0 +1,157 @@
|
|||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/models/new_models/building.dart';
|
||||||
|
import 'package:test_sa/models/new_models/department.dart';
|
||||||
|
import 'package:test_sa/models/new_models/floor.dart';
|
||||||
|
import 'package:test_sa/models/new_models/site.dart';
|
||||||
|
import 'package:test_sa/modules/loan_module/models/medical_department_model.dart';
|
||||||
|
|
||||||
|
class DemoFormModel {
|
||||||
|
String? docName;
|
||||||
|
String? docNumber;
|
||||||
|
String? docEmail;
|
||||||
|
String? itemDescription;
|
||||||
|
String? requestDescription;
|
||||||
|
String? model;
|
||||||
|
String? manufacturer;
|
||||||
|
Lookup? loanProvided;
|
||||||
|
String? vendorName;
|
||||||
|
String? vendorRepresentativeName;
|
||||||
|
String? vendorNumber;
|
||||||
|
String? vendorEmail;
|
||||||
|
Site? site;
|
||||||
|
MedicalDepartmentModel? department;
|
||||||
|
List<DemoAttachments>? demoAttachment;
|
||||||
|
|
||||||
|
DemoFormModel({
|
||||||
|
this.docName,
|
||||||
|
this.docNumber,
|
||||||
|
this.docEmail,
|
||||||
|
this.itemDescription,
|
||||||
|
this.requestDescription,
|
||||||
|
this.model,
|
||||||
|
this.manufacturer,
|
||||||
|
this.loanProvided,
|
||||||
|
this.vendorName,
|
||||||
|
this.vendorRepresentativeName,
|
||||||
|
this.vendorNumber,
|
||||||
|
this.vendorEmail,
|
||||||
|
this.demoAttachment,
|
||||||
|
this.site,
|
||||||
|
this.department,
|
||||||
|
});
|
||||||
|
|
||||||
|
//{
|
||||||
|
// "id": 0,
|
||||||
|
// "employeeId": "fa29a9de-1337-4729-b823-68c6ecffdd33",
|
||||||
|
// "requestorUserID": "fa29a9de-1337-4729-b823-68c6ecffdd33",
|
||||||
|
// "employeeName": "engineer-dev",
|
||||||
|
// "employeeEmail": "Engineer_Dev@yahoo.com",
|
||||||
|
// "positionName": "High",
|
||||||
|
// "requesterExtensionNumber": "7726",
|
||||||
|
// "requesterContactNumber": "72132197",
|
||||||
|
// "siteId": 1,
|
||||||
|
// "departmentId": 5,
|
||||||
|
// "loanTypeId": 6448,
|
||||||
|
// "doctorName": "Doctor A",
|
||||||
|
// "doctorContact": "0561432451",
|
||||||
|
// "doctorEmail": "doctor@test.com",
|
||||||
|
// "itemDescription": "Test item",
|
||||||
|
// "requestDescription": "Test request",
|
||||||
|
// "loanPeriodId": 6453,
|
||||||
|
// "assetId": null,
|
||||||
|
// "assetNumber": "",
|
||||||
|
// "assetName": "",
|
||||||
|
// "assetSerialNumber": "",
|
||||||
|
// "model": "Model A",
|
||||||
|
// "manufacturer": "Siemens",
|
||||||
|
// "vendorName": "Vendor A",
|
||||||
|
// "vendorRepName": "Vendor Rep A",
|
||||||
|
// "vendorContact": "0561432455",
|
||||||
|
// "vendorEmail": "vendor@test.com",
|
||||||
|
// "loanStatusId": 1,
|
||||||
|
// "loanAttachments": [],
|
||||||
|
// "submittedAt": "2025-11-13T12:11:12.673Z",
|
||||||
|
// "updatedAt": null,
|
||||||
|
// "cMWOItemId": null
|
||||||
|
// }
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
var abc = {
|
||||||
|
"id": 0,
|
||||||
|
"siteId": 0,
|
||||||
|
"buildingId": 0,
|
||||||
|
"floorId": 0,
|
||||||
|
"departmentId": 0,
|
||||||
|
"assetName": "string",
|
||||||
|
"model": "string",
|
||||||
|
"manufacturer": "string",
|
||||||
|
"doctorName": "string",
|
||||||
|
"doctorContactNumber": "string",
|
||||||
|
"doctorContactEmail": "string",
|
||||||
|
"itemDescription": "string",
|
||||||
|
"requestDescription": "string",
|
||||||
|
"demoPeriodId": 0,
|
||||||
|
"supplierId": 0,
|
||||||
|
"suppPersonId": 0,
|
||||||
|
"isSubmit": true,
|
||||||
|
"demoAttachments": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"attachmentName": "string",
|
||||||
|
"originalName": "string",
|
||||||
|
"demoRequestId": 0,
|
||||||
|
"attachmentTypeId": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
"doctorName": docName,
|
||||||
|
"doctorContact": docNumber,
|
||||||
|
"doctorEmail": docEmail,
|
||||||
|
"itemDescription": itemDescription,
|
||||||
|
"requestDescription": requestDescription,
|
||||||
|
"model": model,
|
||||||
|
"manufacturer": manufacturer,
|
||||||
|
"demoPeriodId": loanProvided?.id,
|
||||||
|
"vendorName": vendorName,
|
||||||
|
"vendorRepresentativeName": vendorRepresentativeName,
|
||||||
|
"vendorRepName": vendorRepresentativeName,
|
||||||
|
"vendorNumber": vendorNumber,
|
||||||
|
"vendorContact": vendorNumber,
|
||||||
|
"vendorEmail": vendorEmail,
|
||||||
|
'siteId': site?.id,
|
||||||
|
'departmentId': department?.id,
|
||||||
|
"demoAttachments": demoAttachment != null ? demoAttachment!.map((v) => v.toJson()).toList() : [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DemoAttachments {
|
||||||
|
num? id;
|
||||||
|
num? demoRequestId;
|
||||||
|
num? attachmentTypeId;
|
||||||
|
String? attachmentName;
|
||||||
|
String? originalName;
|
||||||
|
|
||||||
|
DemoAttachments({this.id, this.attachmentTypeId, this.attachmentName, this.demoRequestId, this.originalName});
|
||||||
|
|
||||||
|
DemoAttachments.fromJson(dynamic json) {
|
||||||
|
id = json['id'];
|
||||||
|
attachmentTypeId = json['attachmentTypeId'];
|
||||||
|
demoRequestId = json['demoRequestId'];
|
||||||
|
attachmentName = json['attachmentName'];
|
||||||
|
originalName = json['originalName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final map = <String, dynamic>{};
|
||||||
|
map['id'] = id;
|
||||||
|
map['attachmentTypeId'] = attachmentTypeId;
|
||||||
|
map['attachmentName'] = attachmentName;
|
||||||
|
map['demoRequestId'] = demoRequestId;
|
||||||
|
map['originalName'] = originalName;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||||
|
|
||||||
|
import '../../controllers/api_routes/api_manager.dart';
|
||||||
|
import '../../controllers/api_routes/urls.dart';
|
||||||
|
import '../../models/lookup.dart';
|
||||||
|
|
||||||
|
class DemoPeriodLookupProvider extends LoadingListNotifier<Lookup> {
|
||||||
|
@override
|
||||||
|
Future getData({int? id}) async {
|
||||||
|
if (loading == true) return -2;
|
||||||
|
loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
try {
|
||||||
|
Response response = await ApiManager.instance.get(URLs.getDemoPeriodLookup);
|
||||||
|
stateCode = response.statusCode;
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||||
|
List categoriesListJson = json.decode(response.body)["data"];
|
||||||
|
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||||
|
}
|
||||||
|
loading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return response.statusCode;
|
||||||
|
} catch (error) {
|
||||||
|
loading = false;
|
||||||
|
stateCode = -1;
|
||||||
|
notifyListeners();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue