first commit
This commit is contained in:
336
lib/modules/authentication/auth.dart
Normal file
336
lib/modules/authentication/auth.dart
Normal file
@@ -0,0 +1,336 @@
|
||||
class Authentication {
|
||||
final String? customerid;
|
||||
final String? firstname;
|
||||
final String? lastname;
|
||||
final String? profileimage;
|
||||
final String? gender;
|
||||
final String? dob;
|
||||
final String? dialcode;
|
||||
final String? contactno;
|
||||
final String? email;
|
||||
final String? deviceid;
|
||||
final String? devicetype;
|
||||
final int? authmode;
|
||||
final int? configid;
|
||||
final String? customertoken;
|
||||
final String? address;
|
||||
final String? suburb;
|
||||
final String? city;
|
||||
final String? state;
|
||||
final String? landmark;
|
||||
final String? doorno;
|
||||
final String? postcode;
|
||||
final String? latitude;
|
||||
final String? longitude;
|
||||
final int? applocationid;
|
||||
final int? locationid;
|
||||
final String? defaultaddress;
|
||||
final int? primaryaddress;
|
||||
final int? tenantid;
|
||||
final int? status;
|
||||
final String? intro;
|
||||
|
||||
// 🆕 Additional fields specific to Profile API
|
||||
final int? deliverylocationid;
|
||||
final int? allocationid;
|
||||
final int? tenantlocationid;
|
||||
final String? selectedlatitude;
|
||||
final String? selectedlongitude;
|
||||
final String? radius;
|
||||
final int? qrmode;
|
||||
|
||||
const Authentication({
|
||||
this.customerid,
|
||||
this.firstname,
|
||||
this.lastname,
|
||||
this.profileimage,
|
||||
this.gender,
|
||||
this.dob,
|
||||
this.dialcode,
|
||||
this.contactno,
|
||||
this.email,
|
||||
this.deviceid,
|
||||
this.devicetype,
|
||||
this.authmode,
|
||||
this.configid,
|
||||
this.customertoken,
|
||||
this.address,
|
||||
this.suburb,
|
||||
this.city,
|
||||
this.state,
|
||||
this.landmark,
|
||||
this.doorno,
|
||||
this.postcode,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.applocationid,
|
||||
this.locationid,
|
||||
this.defaultaddress,
|
||||
this.primaryaddress,
|
||||
this.tenantid,
|
||||
this.status,
|
||||
this.intro,
|
||||
this.deliverylocationid,
|
||||
this.allocationid,
|
||||
this.tenantlocationid,
|
||||
this.selectedlatitude,
|
||||
this.selectedlongitude,
|
||||
this.radius,
|
||||
this.qrmode,
|
||||
});
|
||||
|
||||
factory Authentication.fromJson(Map<String, dynamic> json) {
|
||||
return Authentication(
|
||||
customerid: json['customerid']?.toString(),
|
||||
firstname: json['firstname'],
|
||||
lastname: json['lastname'],
|
||||
profileimage: json['profileimage'],
|
||||
gender: json['gender'],
|
||||
dob: json['dob'],
|
||||
dialcode: json['dialcode'],
|
||||
contactno: json['contactno'],
|
||||
email: json['email'],
|
||||
deviceid: json['deviceid'],
|
||||
devicetype: json['devicetype'],
|
||||
authmode: json['authmode'],
|
||||
configid: json['configid'],
|
||||
customertoken: json['customertoken'],
|
||||
address: json['address'],
|
||||
suburb: json['suburb'],
|
||||
city: json['city'],
|
||||
state: json['state'],
|
||||
landmark: json['landmark'],
|
||||
doorno: json['doorno'],
|
||||
postcode: json['postcode'],
|
||||
latitude: json['latitude'],
|
||||
longitude: json['longitude'],
|
||||
applocationid: json['applocationid'],
|
||||
locationid: json['locationid'],
|
||||
defaultaddress: json['defaultaddress'],
|
||||
primaryaddress: json['primaryaddress'],
|
||||
tenantid: json['tenantid'],
|
||||
status: json['status'],
|
||||
intro: json['intro'],
|
||||
);
|
||||
}
|
||||
|
||||
/// 🏠 Factory for location API
|
||||
factory Authentication.fromLocationJson(Map<String, dynamic> json) {
|
||||
return Authentication(
|
||||
customerid: json['customerid']?.toString(),
|
||||
address: json['address'],
|
||||
suburb: json['suburb'],
|
||||
city: json['city'],
|
||||
state: json['state'],
|
||||
landmark: json['landmark'],
|
||||
doorno: json['doorno'],
|
||||
postcode: json['postcode'],
|
||||
latitude: json['latitude'],
|
||||
longitude: json['longitude'],
|
||||
locationid: json['locationid'],
|
||||
primaryaddress: json['primaryaddress'],
|
||||
status: json['status'],
|
||||
);
|
||||
}
|
||||
|
||||
/// 🆕 Factory for Profile API
|
||||
factory Authentication.fromProfileJson(Map<String, dynamic> json) {
|
||||
final details = json['details'] ?? {};
|
||||
|
||||
return Authentication(
|
||||
customerid: details['customerid']?.toString(),
|
||||
firstname: details['firstname'],
|
||||
lastname: details['lastname'],
|
||||
profileimage: details['profileimage'],
|
||||
gender: details['gender'],
|
||||
dob: details['dob'],
|
||||
dialcode: details['dialcode'],
|
||||
contactno: details['contactno'],
|
||||
email: details['email'],
|
||||
deviceid: details['deviceid'],
|
||||
devicetype: details['devicetype'],
|
||||
authmode: details['authmode'],
|
||||
configid: details['configid'],
|
||||
customertoken: details['customertoken'],
|
||||
address: details['address'],
|
||||
suburb: details['suburb'],
|
||||
city: details['city'],
|
||||
state: details['state'],
|
||||
landmark: details['landmark'],
|
||||
doorno: details['doorno'],
|
||||
postcode: details['postcode'],
|
||||
latitude: details['latitude'],
|
||||
longitude: details['longitude'],
|
||||
applocationid: details['applocationid'],
|
||||
primaryaddress: details['primaryaddress'],
|
||||
tenantid: details['tenantid'],
|
||||
status: details['status'],
|
||||
intro: details['intro'],
|
||||
deliverylocationid: details['deliverylocationid'],
|
||||
allocationid: details['allocationid'],
|
||||
tenantlocationid: details['tenantlocationid'],
|
||||
selectedlatitude: details['selectedlatitude'],
|
||||
selectedlongitude: details['selectedlongitude'],
|
||||
radius: details['radius'],
|
||||
qrmode: details['qrmode'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'customerid': customerid,
|
||||
'firstname': firstname,
|
||||
'lastname': lastname,
|
||||
'profileimage': profileimage,
|
||||
'gender': gender,
|
||||
'dob': dob,
|
||||
'dialcode': dialcode,
|
||||
'contactno': contactno,
|
||||
'email': email,
|
||||
'deviceid': deviceid,
|
||||
'devicetype': devicetype,
|
||||
'authmode': authmode,
|
||||
'configid': configid,
|
||||
'customertoken': customertoken,
|
||||
'address': address,
|
||||
'suburb': suburb,
|
||||
'city': city,
|
||||
'state': state,
|
||||
'landmark': landmark,
|
||||
'doorno': doorno,
|
||||
'postcode': postcode,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'applocationid': applocationid,
|
||||
'locationid': locationid,
|
||||
'defaultaddress': defaultaddress,
|
||||
'primaryaddress': primaryaddress,
|
||||
'tenantid': tenantid,
|
||||
'status': status,
|
||||
'intro': intro,
|
||||
'deliverylocationid': deliverylocationid,
|
||||
'allocationid': allocationid,
|
||||
'tenantlocationid': tenantlocationid,
|
||||
'selectedlatitude': selectedlatitude,
|
||||
'selectedlongitude': selectedlongitude,
|
||||
'radius': radius,
|
||||
'qrmode': qrmode,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Customer {
|
||||
final int customerId;
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
final String profileImage;
|
||||
final String gender;
|
||||
final String dob;
|
||||
final String dialCode;
|
||||
final String contactNo;
|
||||
final String email;
|
||||
final String deviceId;
|
||||
final String deviceType;
|
||||
final int authMode;
|
||||
final int configId;
|
||||
final String customerToken;
|
||||
final int deliveryLocationId;
|
||||
final String address;
|
||||
final String suburb;
|
||||
final String city;
|
||||
final String state;
|
||||
final String landmark;
|
||||
final String doorNo;
|
||||
final String postcode;
|
||||
final String latitude;
|
||||
final String longitude;
|
||||
final int appLocationId;
|
||||
final int allocationId;
|
||||
final int primaryAddress;
|
||||
final int tenantLocationId;
|
||||
final int tenantId;
|
||||
final int status;
|
||||
final String intro;
|
||||
final String selectedLatitude;
|
||||
final String selectedLongitude;
|
||||
final String radius;
|
||||
final int qrMode;
|
||||
|
||||
Customer({
|
||||
required this.customerId,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.profileImage,
|
||||
required this.gender,
|
||||
required this.dob,
|
||||
required this.dialCode,
|
||||
required this.contactNo,
|
||||
required this.email,
|
||||
required this.deviceId,
|
||||
required this.deviceType,
|
||||
required this.authMode,
|
||||
required this.configId,
|
||||
required this.customerToken,
|
||||
required this.deliveryLocationId,
|
||||
required this.address,
|
||||
required this.suburb,
|
||||
required this.city,
|
||||
required this.state,
|
||||
required this.landmark,
|
||||
required this.doorNo,
|
||||
required this.postcode,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.appLocationId,
|
||||
required this.allocationId,
|
||||
required this.primaryAddress,
|
||||
required this.tenantLocationId,
|
||||
required this.tenantId,
|
||||
required this.status,
|
||||
required this.intro,
|
||||
required this.selectedLatitude,
|
||||
required this.selectedLongitude,
|
||||
required this.radius,
|
||||
required this.qrMode,
|
||||
});
|
||||
|
||||
factory Customer.fromJson(Map<String, dynamic> json) {
|
||||
return Customer(
|
||||
customerId: json['customerid'] ?? 0,
|
||||
firstName: json['firstname'] ?? '',
|
||||
lastName: json['lastname'] ?? '',
|
||||
profileImage: json['profileimage'] ?? '',
|
||||
gender: json['gender'] ?? '',
|
||||
dob: json['dob'] ?? '',
|
||||
dialCode: json['dialcode'] ?? '',
|
||||
contactNo: json['contactno'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
deviceId: json['deviceid'] ?? '',
|
||||
deviceType: json['devicetype'] ?? '',
|
||||
authMode: json['authmode'] ?? 0,
|
||||
configId: json['configid'] ?? 0,
|
||||
customerToken: json['customertoken'] ?? '',
|
||||
deliveryLocationId: json['deliverylocationid'] ?? 0,
|
||||
address: json['address'] ?? '',
|
||||
suburb: json['suburb'] ?? '',
|
||||
city: json['city'] ?? '',
|
||||
state: json['state'] ?? '',
|
||||
landmark: json['landmark'] ?? '',
|
||||
doorNo: json['doorno'] ?? '',
|
||||
postcode: json['postcode'] ?? '',
|
||||
latitude: json['latitude'] ?? '',
|
||||
longitude: json['longitude'] ?? '',
|
||||
appLocationId: json['applocationid'] ?? 0,
|
||||
allocationId: json['allocationid'] ?? 0,
|
||||
primaryAddress: json['primaryaddress'] ?? 0,
|
||||
tenantLocationId: json['tenantlocationid'] ?? 0,
|
||||
tenantId: json['tenantid'] ?? 0,
|
||||
status: json['status'] ?? 0,
|
||||
intro: json['intro'] ?? '',
|
||||
selectedLatitude: json['selectedlatitude'] ?? '',
|
||||
selectedLongitude: json['selectedlongitude'] ?? '',
|
||||
radius: json['radius'] ?? '',
|
||||
qrMode: json['qrmode'] ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
126
lib/modules/authentication/getbyid.dart
Normal file
126
lib/modules/authentication/getbyid.dart
Normal file
@@ -0,0 +1,126 @@
|
||||
class Customerrequest {
|
||||
final List<CustomerFullView>? customerFullView;
|
||||
|
||||
Customerrequest({
|
||||
this.customerFullView,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
class CustomerFullView {
|
||||
final int? customerid;
|
||||
final String? firstname;
|
||||
final dynamic lastname;
|
||||
final String? profileimage;
|
||||
final String? gender;
|
||||
final DateTime? dob;
|
||||
final String? dialcode;
|
||||
final String? contactno;
|
||||
final String? email;
|
||||
final String? deviceid;
|
||||
final String? devicetype;
|
||||
final int? authmode;
|
||||
final int? configid;
|
||||
final String? customertoken;
|
||||
final int? deliverylocationid;
|
||||
final String? address;
|
||||
final String? suburb;
|
||||
final String? city;
|
||||
final String? state;
|
||||
final String? landmark;
|
||||
final String? doorno;
|
||||
final String? postcode;
|
||||
final String? latitude;
|
||||
final String? longitude;
|
||||
final int? applocationid;
|
||||
final int? allocationid;
|
||||
final int? primaryaddress;
|
||||
final int? tenantlocationid;
|
||||
final int? tenantid;
|
||||
final int? status;
|
||||
final dynamic intro;
|
||||
final String? selectedlatitude;
|
||||
final String? selectedlongitude;
|
||||
final int? radius;
|
||||
final int? qrmode;
|
||||
|
||||
CustomerFullView({
|
||||
this.customerid,
|
||||
this.firstname,
|
||||
this.lastname,
|
||||
this.profileimage,
|
||||
this.gender,
|
||||
this.dob,
|
||||
this.dialcode,
|
||||
this.contactno,
|
||||
this.email,
|
||||
this.deviceid,
|
||||
this.devicetype,
|
||||
this.authmode,
|
||||
this.configid,
|
||||
this.customertoken,
|
||||
this.deliverylocationid,
|
||||
this.address,
|
||||
this.suburb,
|
||||
this.city,
|
||||
this.state,
|
||||
this.landmark,
|
||||
this.doorno,
|
||||
this.postcode,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.applocationid,
|
||||
this.allocationid,
|
||||
this.primaryaddress,
|
||||
this.tenantlocationid,
|
||||
this.tenantid,
|
||||
this.status,
|
||||
this.intro,
|
||||
this.selectedlatitude,
|
||||
this.selectedlongitude,
|
||||
this.radius,
|
||||
this.qrmode,
|
||||
});
|
||||
|
||||
factory CustomerFullView.fromJson(Map<String, dynamic> json) {
|
||||
return CustomerFullView(
|
||||
customerid: json['customerid'] as int?,
|
||||
firstname: json['firstname'] as String?,
|
||||
lastname: json['lastname'],
|
||||
profileimage: json['profileimage'] as String?,
|
||||
gender: json['gender'] as String?,
|
||||
dob: json['dob'] != null ? DateTime.tryParse(json['dob']) : null,
|
||||
dialcode: json['dialcode'] as String?,
|
||||
contactno: json['contactno'] as String?,
|
||||
email: json['email'] as String?,
|
||||
deviceid: json['deviceid'] as String?,
|
||||
devicetype: json['devicetype'] as String?,
|
||||
authmode: json['authmode'] as int?,
|
||||
configid: json['configid'] as int?,
|
||||
customertoken: json['customertoken'] as String?,
|
||||
deliverylocationid: json['deliverylocationid'] as int?,
|
||||
address: json['address'] as String?,
|
||||
suburb: json['suburb'] as String?,
|
||||
city: json['city'] as String?,
|
||||
state: json['state'] as String?,
|
||||
landmark: json['landmark'] as String?,
|
||||
doorno: json['doorno'] as String?,
|
||||
postcode: json['postcode'] as String?,
|
||||
latitude: json['latitude'] as String?,
|
||||
longitude: json['longitude'] as String?,
|
||||
applocationid: json['applocationid'] as int?,
|
||||
allocationid: json['allocationid'] as int?,
|
||||
primaryaddress: json['primaryaddress'] as int?,
|
||||
tenantlocationid: json['tenantlocationid'] as int?,
|
||||
tenantid: json['tenantid'] as int?,
|
||||
status: json['status'] as int?,
|
||||
intro: json['intro'],
|
||||
selectedlatitude: json['selectedlatitude'] as String?,
|
||||
selectedlongitude: json['selectedlongitude'] as String?,
|
||||
radius: json['radius'] as int?,
|
||||
qrmode: json['qrmode'] as int?,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
223
lib/modules/orders/create_order.dart
Normal file
223
lib/modules/orders/create_order.dart
Normal file
@@ -0,0 +1,223 @@
|
||||
// lib/modules/orders/create_order.dart
|
||||
import 'dart:convert';
|
||||
|
||||
CreateOrderRequest createOrderRequestFromJson(String str) =>
|
||||
CreateOrderRequest.fromJson(json.decode(str));
|
||||
|
||||
String createOrderRequestToJson(CreateOrderRequest data) =>
|
||||
json.encode(data.toJson());
|
||||
|
||||
CreateOrderResponse createOrderResponseFromJson(String str) =>
|
||||
CreateOrderResponse.fromJson(json.decode(str));
|
||||
|
||||
|
||||
|
||||
class CreateOrderRequest {
|
||||
final CreateOrder? orders;
|
||||
|
||||
CreateOrderRequest({this.orders});
|
||||
|
||||
factory CreateOrderRequest.fromJson(Map<String, dynamic> json) =>
|
||||
CreateOrderRequest(
|
||||
orders: json["orders"] == null ? null : CreateOrder.fromJson(json["orders"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"orders": orders?.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class CreateOrder {
|
||||
final int? applocationid;
|
||||
final String? applocation;
|
||||
final int? tenantid;
|
||||
final int? partnerid;
|
||||
final int? locationid;
|
||||
final int? categoryid;
|
||||
final int? subcategoryid;
|
||||
final int? moduleid;
|
||||
final int? configid;
|
||||
final String? orderdate;
|
||||
final String? deliverydate;
|
||||
final String? orderstatus;
|
||||
final double? deliverycharge;
|
||||
final int? customerid;
|
||||
final String? pickupcustomer;
|
||||
final String? pickupcontactno;
|
||||
final String? pickupaddress;
|
||||
final int? pickuplocationid;
|
||||
final String? pickupcity;
|
||||
final String? deliverycustomer;
|
||||
final String? deliverycontactno;
|
||||
final String? deliveryaddress;
|
||||
final int? deliverylocationid;
|
||||
final String? deliverylat;
|
||||
final String? deliverylong;
|
||||
final int? paymenttype;
|
||||
final List<OrderItem>? items;
|
||||
|
||||
CreateOrder({
|
||||
this.applocationid,
|
||||
this.applocation,
|
||||
this.tenantid,
|
||||
this.partnerid,
|
||||
this.locationid,
|
||||
this.categoryid,
|
||||
this.subcategoryid,
|
||||
this.moduleid,
|
||||
this.configid,
|
||||
this.orderdate,
|
||||
this.deliverydate,
|
||||
this.orderstatus,
|
||||
this.deliverycharge,
|
||||
this.customerid,
|
||||
this.pickupcustomer,
|
||||
this.pickupcontactno,
|
||||
this.pickupaddress,
|
||||
this.pickuplocationid,
|
||||
this.pickupcity,
|
||||
this.deliverycustomer,
|
||||
this.deliverycontactno,
|
||||
this.deliveryaddress,
|
||||
this.deliverylocationid,
|
||||
this.deliverylat,
|
||||
this.deliverylong,
|
||||
this.paymenttype,
|
||||
this.items,
|
||||
});
|
||||
|
||||
factory CreateOrder.fromJson(Map<String, dynamic> json) => CreateOrder(
|
||||
applocationid: json["applocationid"],
|
||||
applocation: json["applocation"],
|
||||
tenantid: json["tenantid"],
|
||||
partnerid: json["partnerid"],
|
||||
locationid: json["locationid"],
|
||||
categoryid: json["categoryid"],
|
||||
subcategoryid: json["subcategoryid"],
|
||||
moduleid: json["moduleid"],
|
||||
configid: json["configid"],
|
||||
orderdate: json["orderdate"],
|
||||
deliverydate: json["deliverydate"],
|
||||
orderstatus: json["orderstatus"],
|
||||
deliverycharge: json["deliverycharge"]?.toDouble(),
|
||||
customerid: json["customerid"],
|
||||
pickupcustomer: json["pickupcustomer"],
|
||||
pickupcontactno: json["pickupcontactno"],
|
||||
pickupaddress: json["pickupaddress"],
|
||||
pickuplocationid: json["pickuplocationid"],
|
||||
pickupcity: json["pickupcity"],
|
||||
deliverycustomer: json["deliverycustomer"],
|
||||
deliverycontactno: json["deliverycontactno"],
|
||||
deliveryaddress: json["deliveryaddress"],
|
||||
deliverylocationid: json["deliverylocationid"],
|
||||
deliverylat: json["deliverylat"],
|
||||
deliverylong: json["deliverylong"],
|
||||
paymenttype: json["paymenttype"],
|
||||
items: json["items"] == null
|
||||
? []
|
||||
: List<OrderItem>.from(json["items"].map((x) => OrderItem.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"applocationid": applocationid,
|
||||
"applocation": applocation,
|
||||
"tenantid": tenantid,
|
||||
"partnerid": partnerid,
|
||||
"locationid": locationid,
|
||||
"categoryid": categoryid,
|
||||
"subcategoryid": subcategoryid,
|
||||
"moduleid": moduleid,
|
||||
"configid": configid,
|
||||
"orderdate": orderdate,
|
||||
"deliverydate": deliverydate,
|
||||
"orderstatus": orderstatus,
|
||||
"deliverycharge": deliverycharge,
|
||||
"customerid": customerid,
|
||||
"pickupcustomer": pickupcustomer,
|
||||
"pickupcontactno": pickupcontactno,
|
||||
"pickupaddress": pickupaddress,
|
||||
"pickuplocationid": pickuplocationid,
|
||||
"pickupcity": pickupcity,
|
||||
"deliverycustomer": deliverycustomer,
|
||||
"deliverycontactno": deliverycontactno,
|
||||
"deliveryaddress": deliveryaddress,
|
||||
"deliverylocationid": deliverylocationid,
|
||||
"deliverylat": deliverylat,
|
||||
"deliverylong": deliverylong,
|
||||
"paymenttype": paymenttype,
|
||||
"items": items?.map((x) => x.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
class OrderItem {
|
||||
final int? productid;
|
||||
final String? productname;
|
||||
final String? productdescription;
|
||||
final int? orderqty;
|
||||
final double? price;
|
||||
final double? discount;
|
||||
final double? tax;
|
||||
final double? tenantfee;
|
||||
final int? unitid;
|
||||
final String? unitname;
|
||||
final double? productsumprice;
|
||||
|
||||
|
||||
OrderItem({
|
||||
this.productid,
|
||||
this.productname,
|
||||
this.productdescription,
|
||||
this.orderqty,
|
||||
this.price,
|
||||
this.discount,
|
||||
this.tenantfee,
|
||||
this.tax,
|
||||
this.unitid,
|
||||
this.unitname,
|
||||
this.productsumprice,
|
||||
|
||||
});
|
||||
|
||||
factory OrderItem.fromJson(Map<String, dynamic> json) => OrderItem(
|
||||
productid: json["productid"],
|
||||
productname: json["productname"],
|
||||
productdescription: json["productdescription"],
|
||||
orderqty: json["orderqty"],
|
||||
price: json["price"]?.toDouble(),
|
||||
tenantfee: json["tenantfee"]?.toDouble(),
|
||||
|
||||
unitid: json["unitid"],
|
||||
unitname: json["unitname"],
|
||||
productsumprice: json["productsumprice"]?.toDouble(),
|
||||
discount: json["discount"]?.toDouble(),
|
||||
tax: json["tax"]?.toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"productid": productid,
|
||||
"productname": productname,
|
||||
"productdescription": productdescription,
|
||||
"orderqty": orderqty,
|
||||
"price": price,
|
||||
"discount": discount,
|
||||
"tax": tax,
|
||||
"tenantfee": tenantfee,
|
||||
"unitid": unitid,
|
||||
"unitname": unitname,
|
||||
"productsumprice": productsumprice,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
class CreateOrderResponse {
|
||||
final String? status;
|
||||
final int? message_id;
|
||||
|
||||
CreateOrderResponse({this.status, this.message_id});
|
||||
|
||||
factory CreateOrderResponse.fromJson(Map<String, dynamic> json) =>
|
||||
CreateOrderResponse(
|
||||
status: json["status"],
|
||||
message_id: json["message_id"],
|
||||
);
|
||||
}
|
||||
223
lib/modules/orders/getcustomerorders.dart
Normal file
223
lib/modules/orders/getcustomerorders.dart
Normal file
@@ -0,0 +1,223 @@
|
||||
class OrderResponse {
|
||||
final List<Order> orders;
|
||||
|
||||
OrderResponse({required this.orders});
|
||||
|
||||
factory OrderResponse.fromJson(Map<String, dynamic> json) {
|
||||
return OrderResponse(
|
||||
orders: (json['orders'] as List? ?? [])
|
||||
.map((e) => Order.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Order {
|
||||
final int orderheaderid;
|
||||
final String orderid;
|
||||
final String orderstatus;
|
||||
final DateTime? orderdate;
|
||||
final String? ordernotes;
|
||||
|
||||
final String? deliverytime;
|
||||
final String? pending;
|
||||
final String? processing;
|
||||
final String? ready;
|
||||
final String? delivered;
|
||||
final String? cancelled;
|
||||
|
||||
final double? deliverycharge;
|
||||
final String? kms;
|
||||
|
||||
final String? pickupaddress;
|
||||
final String? pickupcustomer;
|
||||
final String? pickupcontactno;
|
||||
final String? pickupcity;
|
||||
|
||||
final String? deliveryaddress;
|
||||
final String? deliverylat;
|
||||
final String? deliverylong;
|
||||
final String? deliverycustomer;
|
||||
final String? deliverycontactno;
|
||||
|
||||
// ✅ Flat tenant fields (used directly in UI)
|
||||
final String? tenantname;
|
||||
final String? tenanttoken;
|
||||
final String? tenantcontactno;
|
||||
final String? tenantpostcode;
|
||||
final String? tenantsuburb;
|
||||
final String? tenantcity;
|
||||
final String? tenantimage;
|
||||
final String? registrationno;
|
||||
final String? gstno;
|
||||
|
||||
// ✅ Flat tenant location fields
|
||||
final String? locationname;
|
||||
final String? locationcontactno;
|
||||
final String? locationpostcode;
|
||||
final String? locationsuburb;
|
||||
final String? locationcity;
|
||||
|
||||
// ✅ App location
|
||||
final String? applocationname;
|
||||
|
||||
// ✅ Financial
|
||||
final double? totaltaxamount;
|
||||
|
||||
// ✅ Order details as a LIST (UI iterates over this)
|
||||
final List<OrderDetail>? orderdetails;
|
||||
|
||||
Order({
|
||||
required this.orderheaderid,
|
||||
required this.orderid,
|
||||
required this.orderstatus,
|
||||
this.orderdate,
|
||||
this.ordernotes,
|
||||
this.deliverytime,
|
||||
this.pending,
|
||||
this.processing,
|
||||
this.ready,
|
||||
this.delivered,
|
||||
this.cancelled,
|
||||
this.deliverycharge,
|
||||
this.kms,
|
||||
this.pickupaddress,
|
||||
this.pickupcustomer,
|
||||
this.pickupcontactno,
|
||||
this.pickupcity,
|
||||
this.deliveryaddress,
|
||||
this.deliverylat,
|
||||
this.deliverylong,
|
||||
this.deliverycustomer,
|
||||
this.deliverycontactno,
|
||||
this.tenantname,
|
||||
this.tenanttoken,
|
||||
this.tenantcontactno,
|
||||
this.tenantpostcode,
|
||||
this.tenantsuburb,
|
||||
this.tenantcity,
|
||||
this.tenantimage,
|
||||
this.registrationno,
|
||||
this.gstno,
|
||||
this.locationname,
|
||||
this.locationcontactno,
|
||||
this.locationpostcode,
|
||||
this.locationsuburb,
|
||||
this.locationcity,
|
||||
this.applocationname,
|
||||
this.totaltaxamount,
|
||||
this.orderdetails,
|
||||
});
|
||||
|
||||
factory Order.fromJson(Map<String, dynamic> json) {
|
||||
// ✅ Safely extract nested objects if present
|
||||
final tenant = json['tenant'] as Map<String, dynamic>? ?? {};
|
||||
final tenantlocation = json['tenantlocation'] as Map<String, dynamic>? ?? {};
|
||||
final applocation = json['applocation'] as Map<String, dynamic>? ?? {};
|
||||
|
||||
// ✅ Parse orderdate safely
|
||||
DateTime? parsedDate;
|
||||
final rawDate = json['orderdate'];
|
||||
if (rawDate != null && rawDate.toString().isNotEmpty) {
|
||||
try {
|
||||
parsedDate = DateTime.parse(rawDate.toString());
|
||||
} catch (_) {
|
||||
parsedDate = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Safe parser — API may return orderdetails as {}, [], or null
|
||||
List<OrderDetail> parseOrderDetails(dynamic raw) {
|
||||
if (raw == null) return [];
|
||||
if (raw is List) return raw.map((e) => OrderDetail.fromJson(e as Map<String, dynamic>)).toList();
|
||||
if (raw is Map<String, dynamic>) return [OrderDetail.fromJson(raw)];
|
||||
return [];
|
||||
}
|
||||
|
||||
return Order(
|
||||
orderheaderid: json['orderheaderid'] ?? 0,
|
||||
orderid: json['orderid'] ?? '',
|
||||
orderstatus: json['orderstatus'] ?? 'pending',
|
||||
orderdate: parsedDate,
|
||||
ordernotes: json['ordernotes'],
|
||||
|
||||
deliverytime: json['deliverytime'],
|
||||
pending: json['pending'],
|
||||
processing: json['processing'],
|
||||
ready: json['ready'],
|
||||
delivered: json['delivered'],
|
||||
cancelled: json['cancelled'],
|
||||
|
||||
deliverycharge: (json['deliverycharge'] ?? 0).toDouble(),
|
||||
kms: json['kms'],
|
||||
|
||||
pickupaddress: json['pickupaddress'] ?? '',
|
||||
pickupcustomer: json['pickupcustomer'] ?? '',
|
||||
pickupcontactno: json['pickupcontactno'] ?? '',
|
||||
pickupcity: json['pickupcity'] ?? '',
|
||||
|
||||
deliveryaddress: json['deliveryaddress'] ?? '',
|
||||
deliverylat: json['deliverylat']?.toString(),
|
||||
deliverylong: json['deliverylong']?.toString(),
|
||||
deliverycustomer: json['deliverycustomer'] ?? '',
|
||||
deliverycontactno: json['deliverycontactno'] ?? '',
|
||||
|
||||
// ✅ Try flat field first, fallback to nested tenant object
|
||||
tenantname: json['tenantname'] ?? tenant['tenantname'] ?? 'Unknown Store',
|
||||
tenanttoken: json['tenanttoken'] ?? tenant['tenanttoken'] ?? '',
|
||||
tenantcontactno: json['tenantcontactno'] ?? tenant['tenantcontactno'] ?? '',
|
||||
tenantpostcode: json['tenantpostcode'] ?? tenant['tenantpostcode'] ?? '',
|
||||
tenantsuburb: json['tenantsuburb'] ?? tenant['tenantsuburb'] ?? '',
|
||||
tenantcity: json['tenantcity'] ?? tenant['tenantcity'] ?? '',
|
||||
tenantimage: json['tenantimage'] ?? tenant['tenantimage'],
|
||||
registrationno: json['registrationno'] ?? tenant['registrationno'] ?? '',
|
||||
gstno: json['gstno'] ?? tenant['gstno'] ?? '',
|
||||
|
||||
locationname: json['locationname'] ?? tenantlocation['locationname'] ?? '',
|
||||
locationcontactno: json['locationcontactno'] ?? tenantlocation['locationcontactno'] ?? '',
|
||||
locationpostcode: json['locationpostcode'] ?? tenantlocation['locationpostcode'] ?? '',
|
||||
locationsuburb: json['locationsuburb'] ?? tenantlocation['locationsuburb'] ?? '',
|
||||
locationcity: json['locationcity'] ?? tenantlocation['locationcity'] ?? '',
|
||||
|
||||
applocationname: json['applocationname'] ?? applocation['locationname'] ?? '',
|
||||
|
||||
totaltaxamount: (json['totaltaxamount'] ?? 0).toDouble(),
|
||||
|
||||
// ✅ Handles Map {}, List [], or null safely
|
||||
orderdetails: parseOrderDetails(json['orderdetails']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OrderDetail {
|
||||
final int orderdetailid;
|
||||
final String? productname;
|
||||
final int? orderqty;
|
||||
final double? price;
|
||||
final double? productsumprice; // ✅ used for total amount calculation in UI
|
||||
final double? discountamount; // ✅ used in OrderDetailsPage
|
||||
final String? productimage; // ✅ used in OrderDetailsPage
|
||||
|
||||
OrderDetail({
|
||||
required this.orderdetailid,
|
||||
this.productname,
|
||||
this.orderqty,
|
||||
this.price,
|
||||
this.productsumprice,
|
||||
this.discountamount,
|
||||
this.productimage,
|
||||
});
|
||||
|
||||
factory OrderDetail.fromJson(Map<String, dynamic> json) {
|
||||
return OrderDetail(
|
||||
orderdetailid: json['orderdetailid'] ?? 0,
|
||||
productname: json['productname'] ?? 'Unknown Product',
|
||||
orderqty: json['orderqty'] ?? 0,
|
||||
price: (json['price'] ?? 0).toDouble(),
|
||||
// ✅ fallback to price if productsumprice not in response
|
||||
productsumprice: (json['productsumprice'] ?? json['price'] ?? 0).toDouble(),
|
||||
discountamount: (json['discountamount'] ?? 0).toDouble(),
|
||||
productimage: json['productimage'] ?? json['image'],
|
||||
);
|
||||
}
|
||||
}
|
||||
25
lib/modules/product/discount.dart
Normal file
25
lib/modules/product/discount.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
class Discount {
|
||||
final int discountid;
|
||||
final String discountname;
|
||||
final String discountcode;
|
||||
final String discountterms;
|
||||
final double discountvalue;
|
||||
|
||||
Discount({
|
||||
required this.discountid,
|
||||
required this.discountname,
|
||||
required this.discountcode,
|
||||
required this.discountterms,
|
||||
required this.discountvalue,
|
||||
});
|
||||
|
||||
factory Discount.fromJson(Map<String, dynamic> json) {
|
||||
return Discount(
|
||||
discountid: json['discountid'],
|
||||
discountname: json['discountname'],
|
||||
discountcode: json['discountcode'],
|
||||
discountterms: json['discountterms'],
|
||||
discountvalue: (json['discountvalue'] ?? 0).toDouble(),
|
||||
);
|
||||
}
|
||||
}
|
||||
336
lib/modules/product/product.dart
Normal file
336
lib/modules/product/product.dart
Normal file
@@ -0,0 +1,336 @@
|
||||
import 'dart:convert';
|
||||
|
||||
/// Parse JSON to ProductResponse
|
||||
ProductResponse productResponseFromJson(String str) =>
|
||||
ProductResponse.fromJson(json.decode(str));
|
||||
|
||||
String productResponseToJson(ProductResponse data) =>
|
||||
json.encode(data.toJson());
|
||||
|
||||
class ProductResponse {
|
||||
final int? code;
|
||||
final Data? data;
|
||||
final String? message;
|
||||
final bool? status;
|
||||
final List<Product>? details; // for variants API
|
||||
|
||||
ProductResponse({
|
||||
this.code,
|
||||
this.data,
|
||||
this.message,
|
||||
this.status,
|
||||
this.details,
|
||||
});
|
||||
|
||||
factory ProductResponse.fromJson(Map<String, dynamic> json) =>
|
||||
ProductResponse(
|
||||
code: json["code"],
|
||||
data: json["data"] == null ? null : Data.fromJson(json["data"]),
|
||||
details: json["details"] != null
|
||||
? List<Product>.from(
|
||||
json["details"]!.map((x) => Product.fromVariantJson(x)))
|
||||
: null,
|
||||
message: json["message"],
|
||||
status: json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"data": data?.toJson(),
|
||||
"details": details == null
|
||||
? null
|
||||
: List<dynamic>.from(details!.map((x) => x.toJson())),
|
||||
"message": message,
|
||||
"status": status,
|
||||
};
|
||||
}
|
||||
|
||||
/// Data class for main product API
|
||||
class Data {
|
||||
final String? address;
|
||||
final String? city;
|
||||
final List<Detail>? details;
|
||||
final String? licenseno;
|
||||
final String? locationname;
|
||||
final String? pickuplat;
|
||||
final int? pickuplocationid;
|
||||
final String? pickuplong;
|
||||
final String? postcode;
|
||||
final String? primarycontact;
|
||||
final String? primaryemail;
|
||||
final String? suburb;
|
||||
final String? tenantname;
|
||||
|
||||
Data({
|
||||
this.address,
|
||||
this.city,
|
||||
this.details,
|
||||
this.licenseno,
|
||||
this.locationname,
|
||||
this.pickuplat,
|
||||
this.pickuplocationid,
|
||||
this.pickuplong,
|
||||
this.postcode,
|
||||
this.primarycontact,
|
||||
this.primaryemail,
|
||||
this.suburb,
|
||||
this.tenantname,
|
||||
});
|
||||
|
||||
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||||
address: json["address"],
|
||||
city: json["city"],
|
||||
details: json["details"] == null
|
||||
? []
|
||||
: List<Detail>.from(
|
||||
json["details"]!.map((x) => Detail.fromJson(x))),
|
||||
licenseno: json["licenseno"],
|
||||
locationname: json["locationname"],
|
||||
pickuplat: json["pickuplat"],
|
||||
pickuplocationid: json["pickuplocationid"],
|
||||
pickuplong: json["pickuplong"],
|
||||
postcode: json["postcode"],
|
||||
primarycontact: json["primarycontact"],
|
||||
primaryemail: json["primaryemail"],
|
||||
suburb: json["suburb"],
|
||||
tenantname: json["tenantname"],
|
||||
);
|
||||
|
||||
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"address": address,
|
||||
"city": city,
|
||||
"details": details == null
|
||||
? []
|
||||
: List<dynamic>.from(details!.map((x) => x.toJson())),
|
||||
"licenseno": licenseno,
|
||||
"locationname": locationname,
|
||||
"pickuplat": pickuplat,
|
||||
"pickuplocationid": pickuplocationid,
|
||||
"pickuplong": pickuplong,
|
||||
"postcode": postcode,
|
||||
"primarycontact": primarycontact,
|
||||
"primaryemail": primaryemail,
|
||||
"suburb": suburb,
|
||||
"tenantname": tenantname,
|
||||
};
|
||||
}
|
||||
|
||||
/// Detail class for subcategories
|
||||
class Detail {
|
||||
final int? subcategoryid;
|
||||
final String? subcategoryname;
|
||||
final String? image;
|
||||
final List<Product>? products;
|
||||
|
||||
Detail({
|
||||
this.subcategoryid,
|
||||
this.subcategoryname,
|
||||
this.image,
|
||||
this.products,
|
||||
});
|
||||
|
||||
factory Detail.fromJson(Map<String, dynamic> json) => Detail(
|
||||
subcategoryid: json["subcategoryid"],
|
||||
subcategoryname: json["subcategoryname"],
|
||||
image: json["image"],
|
||||
products: json["products"] == null
|
||||
? []
|
||||
: List<Product>.from(
|
||||
json["products"]!.map((x) => Product.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"subcategoryid": subcategoryid,
|
||||
"subcategoryname": subcategoryname,
|
||||
"image": image,
|
||||
"products": products == null
|
||||
? []
|
||||
: List<dynamic>.from(products!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
/// Product class for both main products and variants
|
||||
class Product {
|
||||
final int? productid;
|
||||
final int? applocationid;
|
||||
final int? productlocationid;
|
||||
final int? tenantid;
|
||||
final int? categoryid;
|
||||
final String? categoryname;
|
||||
final int? subcategoryid;
|
||||
final String? subcategoryname;
|
||||
final String? productname;
|
||||
final String? productimage;
|
||||
final String? productdesc;
|
||||
final Productunit? productunit;
|
||||
final String? unitvalue;
|
||||
final double? productcost;
|
||||
final double? discount;
|
||||
final double? taxamount;
|
||||
final int? taxpercent;
|
||||
final int? producttax;
|
||||
final int? productstock;
|
||||
final int? productcombo;
|
||||
final int? variants;
|
||||
final int? quantity;
|
||||
final int? approve;
|
||||
final Productstatus? productstatus;
|
||||
|
||||
Product({
|
||||
this.productid,
|
||||
this.applocationid,
|
||||
this.productlocationid,
|
||||
this.tenantid,
|
||||
this.categoryid,
|
||||
this.categoryname,
|
||||
this.subcategoryid,
|
||||
this.subcategoryname,
|
||||
this.productname,
|
||||
this.productimage,
|
||||
this.productdesc,
|
||||
this.productunit,
|
||||
this.unitvalue,
|
||||
this.productcost,
|
||||
this.discount,
|
||||
this.taxamount,
|
||||
this.taxpercent,
|
||||
this.producttax,
|
||||
this.productstock,
|
||||
this.productcombo,
|
||||
this.variants,
|
||||
this.quantity,
|
||||
this.approve,
|
||||
this.productstatus,
|
||||
});
|
||||
|
||||
/// Factory for main product API
|
||||
factory Product.fromJson(Map<String, dynamic> json) => Product(
|
||||
productid: json["productid"],
|
||||
applocationid: json["applocationid"],
|
||||
productlocationid: json["productlocationid"],
|
||||
tenantid: json["tenantid"],
|
||||
categoryid: json["categoryid"],
|
||||
categoryname: json["categoryname"],
|
||||
subcategoryid: json["subcategoryid"],
|
||||
subcategoryname: json["Subcategoryname"],
|
||||
productname: json["productname"],
|
||||
productimage: json["productimage"],
|
||||
productdesc: json["productdesc"],
|
||||
productunit: productunitValues.map[json["productunit"]] ?? Productunit.KG,
|
||||
unitvalue: json["unitvalue"],
|
||||
productcost: (json["productcost"] ?? 0).toDouble(),
|
||||
discount: (json["discountvalue"] ?? 0).toDouble(),
|
||||
taxamount: (json["taxamount"] ?? 0).toDouble(),
|
||||
taxpercent: json["taxpercent"],
|
||||
producttax: json["producttax"],
|
||||
productstock: json["productstock"],
|
||||
productcombo: json["productcombo"],
|
||||
variants: json["variants"],
|
||||
quantity: json["quantity"],
|
||||
approve: json["approve"],
|
||||
productstatus: productstatusValues.map[json["productstatus"]] ?? Productstatus.AVAILABLE,
|
||||
);
|
||||
|
||||
/// Factory for variants API (flat structure)
|
||||
factory Product.fromVariantJson(Map<String, dynamic> json) => Product(
|
||||
productid: json["productid"],
|
||||
applocationid: json["applocationid"],
|
||||
productlocationid: json["productlocationid"],
|
||||
tenantid: json["tenantid"],
|
||||
categoryid: json["categoryid"],
|
||||
categoryname: json["categoryname"],
|
||||
subcategoryid: json["subcategoryid"] ?? 0,
|
||||
subcategoryname: json["Subcategoryname"] ?? "",
|
||||
productname: json["productname"],
|
||||
productimage: json["productimage"],
|
||||
productdesc: json["productdesc"].toString(),
|
||||
productunit: productunitValues.map[json["productunit"]] ?? Productunit.KG,
|
||||
unitvalue: json["unitvalue"] ?? "",
|
||||
productcost: (json["productcost"] ?? 0).toDouble(),
|
||||
discount: (json["discountvalue"] ?? 0).toDouble(),
|
||||
taxamount: (json["producttax"] ?? 0).toDouble(),
|
||||
taxpercent: json["taxpercent"] ?? 0,
|
||||
producttax: json["producttax"] ?? 0,
|
||||
productstock: json["productstock"] ?? 0,
|
||||
productcombo: json["productcombo"] ?? 0,
|
||||
variants: json["variants"] ?? 0,
|
||||
quantity: json["quantity"] ?? 0,
|
||||
approve: json["approve"] ?? 0,
|
||||
productstatus: productstatusValues.map[json["productstatus"]] ?? Productstatus.AVAILABLE,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"productid": productid,
|
||||
"applocationid": applocationid,
|
||||
"productlocationid": productlocationid,
|
||||
"tenantid": tenantid,
|
||||
"categoryid": categoryid,
|
||||
"categoryname": categoryname,
|
||||
"subcategoryid": subcategoryid,
|
||||
"Subcategoryname": subcategoryname,
|
||||
"productname": productname,
|
||||
"productimage": productimage,
|
||||
"productdesc": productdesc,
|
||||
"productunit": productunitValues.reverse[productunit],
|
||||
"unitvalue": unitvalue,
|
||||
"productcost": productcost,
|
||||
"discount": discount,
|
||||
"taxamount": taxamount,
|
||||
"taxpercent": taxpercent,
|
||||
"producttax": producttax,
|
||||
"productstock": productstock,
|
||||
"productcombo": productcombo,
|
||||
"variants": variants,
|
||||
"quantity": quantity,
|
||||
"approve": approve,
|
||||
"productstatus": productstatusValues.reverse[productstatus],
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Convert a JSON list into List<Product>
|
||||
static List<Product> fromJsonList(List<dynamic> list) {
|
||||
return list.map((e) => Product.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
/// Convert a JSON list for variants into List<Product>
|
||||
static List<Product> fromVariantJsonList(List<dynamic> list) {
|
||||
return list.map((e) => Product.fromVariantJson(e)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
enum Productstatus { ACTIVE, AVAILABLE, OUTOFSTOCK }
|
||||
final productstatusValues = EnumValues({
|
||||
"Active": Productstatus.ACTIVE,
|
||||
"available": Productstatus.AVAILABLE,
|
||||
"outofstock": Productstatus.OUTOFSTOCK
|
||||
});
|
||||
|
||||
enum Productunit { BOX, KG, LTR, PCS }
|
||||
|
||||
final productunitValues = EnumValues({
|
||||
"box": Productunit.BOX,
|
||||
"kg": Productunit.KG,
|
||||
"ltr": Productunit.LTR,
|
||||
"pcs": Productunit.PCS,
|
||||
});
|
||||
|
||||
/// Enum helper class
|
||||
class EnumValues<T> {
|
||||
Map<String, T> map;
|
||||
late Map<T, String> reverseMap;
|
||||
|
||||
EnumValues(this.map);
|
||||
|
||||
Map<T, String> get reverse {
|
||||
reverseMap = map.map((k, v) => MapEntry(v, k));
|
||||
return reverseMap;
|
||||
}
|
||||
}
|
||||
84
lib/modules/profile/customer_request.dart
Normal file
84
lib/modules/profile/customer_request.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
class CustomerRequestModel {
|
||||
final String referencedate;
|
||||
final String referencetype;
|
||||
final int customerid;
|
||||
final int tenantid;
|
||||
final int locationid;
|
||||
final String subject;
|
||||
final String remarks;
|
||||
final int status;
|
||||
final int apptypeid;
|
||||
|
||||
CustomerRequestModel({
|
||||
required this.referencedate,
|
||||
required this.referencetype,
|
||||
required this.customerid,
|
||||
required this.tenantid,
|
||||
required this.locationid,
|
||||
required this.subject,
|
||||
required this.remarks,
|
||||
required this.status,
|
||||
required this.apptypeid,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"referencedate": referencedate,
|
||||
"referencetype": referencetype,
|
||||
"customerid": customerid,
|
||||
"tenantid": tenantid,
|
||||
"locationid": locationid,
|
||||
"subject": subject,
|
||||
"remarks": remarks,
|
||||
"status": status,
|
||||
"apptypeid": apptypeid,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class CustomerRequestStatusModel {
|
||||
final int customerrequestid;
|
||||
final String referencedate;
|
||||
final String referencetype;
|
||||
final int customerid;
|
||||
final int tenantid;
|
||||
final int apptypeid;
|
||||
final int locationid;
|
||||
final String subject;
|
||||
final String remarks;
|
||||
final int status;
|
||||
final String created;
|
||||
final String updated;
|
||||
|
||||
CustomerRequestStatusModel({
|
||||
required this.customerrequestid,
|
||||
required this.referencedate,
|
||||
required this.referencetype,
|
||||
required this.customerid,
|
||||
required this.tenantid,
|
||||
required this.apptypeid,
|
||||
required this.locationid,
|
||||
required this.subject,
|
||||
required this.remarks,
|
||||
required this.status,
|
||||
required this.created,
|
||||
required this.updated,
|
||||
});
|
||||
|
||||
factory CustomerRequestStatusModel.fromJson(Map<String, dynamic> json) {
|
||||
return CustomerRequestStatusModel(
|
||||
customerrequestid: json['customerrequestid'] ?? 0,
|
||||
referencedate: json['referencedate'] ?? "",
|
||||
referencetype: json['referencetype'] ?? "",
|
||||
customerid: json['customerid'] ?? 0,
|
||||
tenantid: json['tenantid'] ?? 0,
|
||||
apptypeid: json['apptypeid'] ?? 0,
|
||||
locationid: json['locationid'] ?? 0,
|
||||
subject: json['subject'] ?? "",
|
||||
remarks: json['remarks'] ?? "",
|
||||
status: json['status'] ?? 0,
|
||||
created: json['created'] ?? "",
|
||||
updated: json['updated'] ?? "",
|
||||
);
|
||||
}
|
||||
}
|
||||
19
lib/modules/tenant/category.dart
Normal file
19
lib/modules/tenant/category.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
class Category {
|
||||
final int id;
|
||||
final String name;
|
||||
final String icon;
|
||||
|
||||
Category({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
factory Category.fromJson(Map<String, dynamic> json) {
|
||||
return Category(
|
||||
id: json['categoryid'],
|
||||
name: json['categoryname'] ?? '',
|
||||
icon: json['iconurl'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
680
lib/modules/tenant/get_tenant.dart
Normal file
680
lib/modules/tenant/get_tenant.dart
Normal file
@@ -0,0 +1,680 @@
|
||||
import 'dart:convert';
|
||||
|
||||
CustomerTenantsResponse customerTenantsResponseFromJson(String str) =>
|
||||
CustomerTenantsResponse.fromJson(json.decode(str));
|
||||
|
||||
String customerTenantsResponseToJson(CustomerTenantsResponse data) =>
|
||||
json.encode(data.toJson());
|
||||
|
||||
class CustomerTenantsResponse {
|
||||
final int? code;
|
||||
final List<Tenant>? details;
|
||||
final String? message;
|
||||
final bool? status;
|
||||
|
||||
CustomerTenantsResponse({
|
||||
this.code,
|
||||
this.details,
|
||||
this.message,
|
||||
this.status,
|
||||
});
|
||||
|
||||
factory CustomerTenantsResponse.fromJson(Map<String, dynamic> json) =>
|
||||
CustomerTenantsResponse(
|
||||
code: json["code"],
|
||||
details: json["details"] == null
|
||||
? []
|
||||
: List<Tenant>.from(json["details"].map((x) => Tenant.fromJson(x))),
|
||||
message: json["message"],
|
||||
status: json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"details": details == null
|
||||
? []
|
||||
: List<dynamic>.from(details!.map((x) => x.toJson())),
|
||||
"message": message,
|
||||
"status": status,
|
||||
};
|
||||
}
|
||||
|
||||
class Data {
|
||||
final Customer? customer;
|
||||
final List<Tenant>? tenants;
|
||||
|
||||
Data({
|
||||
this.customer,
|
||||
this.tenants,
|
||||
});
|
||||
|
||||
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||||
customer: json["customer"] == null
|
||||
? null
|
||||
: Customer.fromJson(json["customer"]),
|
||||
tenants: json["tenants"] == null
|
||||
? []
|
||||
: List<Tenant>.from(
|
||||
json["tenants"]!.map((x) => Tenant.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"customer": customer?.toJson(),
|
||||
"tenants": tenants == null
|
||||
? []
|
||||
: List<dynamic>.from(tenants!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class Customer {
|
||||
final int? customerid;
|
||||
final String? firstname;
|
||||
final String? lastname;
|
||||
final String? profileimage;
|
||||
final String? gender;
|
||||
final String? dob;
|
||||
final String? dialcode;
|
||||
final String? contactno;
|
||||
final String? email;
|
||||
final String? deviceid;
|
||||
final String? devicetype;
|
||||
final int? authmode;
|
||||
final int? configid;
|
||||
final String? customertoken;
|
||||
final String? address;
|
||||
final String? suburb;
|
||||
final String? city;
|
||||
final String? state;
|
||||
final String? landmark;
|
||||
final String? doorno;
|
||||
final String? postcode;
|
||||
final String? latitude;
|
||||
final String? longitude;
|
||||
final int? applocationid;
|
||||
final int? status;
|
||||
final String? intro;
|
||||
|
||||
Customer({
|
||||
this.customerid,
|
||||
this.firstname,
|
||||
this.lastname,
|
||||
this.profileimage,
|
||||
this.gender,
|
||||
this.dob,
|
||||
this.dialcode,
|
||||
this.contactno,
|
||||
this.email,
|
||||
this.deviceid,
|
||||
this.devicetype,
|
||||
this.authmode,
|
||||
this.configid,
|
||||
this.customertoken,
|
||||
this.address,
|
||||
this.suburb,
|
||||
this.city,
|
||||
this.state,
|
||||
this.landmark,
|
||||
this.doorno,
|
||||
this.postcode,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.applocationid,
|
||||
this.status,
|
||||
this.intro,
|
||||
});
|
||||
|
||||
factory Customer.fromJson(Map<String, dynamic> json) => Customer(
|
||||
customerid: json["customerid"],
|
||||
firstname: json["firstname"],
|
||||
lastname: json["lastname"],
|
||||
profileimage: json["profileimage"],
|
||||
gender: json["gender"],
|
||||
dob: json["dob"],
|
||||
dialcode: json["dialcode"],
|
||||
contactno: json["contactno"],
|
||||
email: json["email"],
|
||||
deviceid: json["deviceid"],
|
||||
devicetype: json["devicetype"],
|
||||
authmode: json["authmode"],
|
||||
configid: json["configid"],
|
||||
customertoken: json["customertoken"],
|
||||
address: json["address"],
|
||||
suburb: json["suburb"],
|
||||
city: json["city"],
|
||||
state: json["state"],
|
||||
landmark: json["landmark"],
|
||||
doorno: json["doorno"],
|
||||
postcode: json["postcode"],
|
||||
latitude: json["latitude"],
|
||||
longitude: json["longitude"],
|
||||
applocationid: json["applocationid"],
|
||||
status: json["status"],
|
||||
intro: json["intro"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"customerid": customerid,
|
||||
"firstname": firstname,
|
||||
"lastname": lastname,
|
||||
"profileimage": profileimage,
|
||||
"gender": gender,
|
||||
"dob": dob,
|
||||
"dialcode": dialcode,
|
||||
"contactno": contactno,
|
||||
"email": email,
|
||||
"deviceid": deviceid,
|
||||
"devicetype": devicetype,
|
||||
"authmode": authmode,
|
||||
"configid": configid,
|
||||
"customertoken": customertoken,
|
||||
"address": address,
|
||||
"suburb": suburb,
|
||||
"city": city,
|
||||
"state": state,
|
||||
"landmark": landmark,
|
||||
"doorno": doorno,
|
||||
"postcode": postcode,
|
||||
"latitude": latitude,
|
||||
"longitude": longitude,
|
||||
"applocationid": applocationid,
|
||||
"status": status,
|
||||
"intro": intro,
|
||||
};
|
||||
}
|
||||
|
||||
class Tenant {
|
||||
final int? tenantid;
|
||||
final String? tenantname;
|
||||
final String? tenanttoken;
|
||||
final String? tenantbanner;
|
||||
final double? tenantcharge;
|
||||
final String? address;
|
||||
final String? licenseno;
|
||||
final String? primaryemail;
|
||||
final String? primarycontact;
|
||||
final int? pickuplocationid;
|
||||
final int? applocationid;
|
||||
final String? suburb;
|
||||
final String? city;
|
||||
final String? latitude;
|
||||
final String? longitude;
|
||||
final String? postcode;
|
||||
final String? tenantimage;
|
||||
final int? locationid;
|
||||
final String? locationname;
|
||||
final int? subcategoryid;
|
||||
final int? categoryid;
|
||||
final String? registrationno;
|
||||
final int? orderscount;
|
||||
final List<Subcategory>? subcategories;
|
||||
|
||||
Tenant({
|
||||
this.tenantid,
|
||||
this.tenantname,
|
||||
this.tenanttoken,
|
||||
this.tenantbanner,
|
||||
this.tenantcharge,
|
||||
this.address,
|
||||
this.licenseno,
|
||||
this.primaryemail,
|
||||
this.primarycontact,
|
||||
this.pickuplocationid,
|
||||
this.applocationid,
|
||||
this.suburb,
|
||||
this.city,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.postcode,
|
||||
this.tenantimage,
|
||||
this.locationid,
|
||||
this.locationname,
|
||||
this.subcategoryid,
|
||||
this.categoryid,
|
||||
this.registrationno,
|
||||
this.orderscount,
|
||||
this.subcategories,
|
||||
});
|
||||
|
||||
factory Tenant.fromJson(Map<String, dynamic> json) => Tenant(
|
||||
tenantid: json["tenantid"],
|
||||
tenantname: json["tenantname"],
|
||||
tenanttoken: json["userfcmtoken"],
|
||||
tenantbanner: json["tenantbanner"],
|
||||
tenantcharge: json["tenantcharge"],
|
||||
address: json["address"],
|
||||
licenseno: json["licenseno"],
|
||||
primaryemail: json["primaryemail"],
|
||||
primarycontact: json["primarycontact"],
|
||||
pickuplocationid: json["pickuplocationid"],
|
||||
applocationid: json["applocationid"],
|
||||
suburb: json["suburb"],
|
||||
city: json["city"],
|
||||
latitude: json["latitude"],
|
||||
longitude: json["longitude"],
|
||||
postcode: json["postcode"],
|
||||
tenantimage: json["tenantimage"],
|
||||
locationid: json["locationid"],
|
||||
locationname: json["locationname"],
|
||||
subcategoryid: json["subcategoryid"],
|
||||
categoryid: json["categoryid"],
|
||||
registrationno: json["registrationno"],
|
||||
orderscount: json["orderscount"],
|
||||
subcategories: json["productsubcategory"] == null
|
||||
? []
|
||||
: List<Subcategory>.from(
|
||||
json["productsubcategory"].map((x) => Subcategory.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"tenantid": tenantid,
|
||||
"tenantname": tenantname,
|
||||
"userfcmtoken": tenanttoken,
|
||||
"tenantbanner": tenantbanner,
|
||||
"tenantchanrge": tenantcharge,
|
||||
"address": address,
|
||||
"licenseno": licenseno,
|
||||
"primaryemail": primaryemail,
|
||||
"primarycontact": primarycontact,
|
||||
"pickuplocationid": pickuplocationid,
|
||||
"applocationid": applocationid,
|
||||
"suburb": suburb,
|
||||
"city": city,
|
||||
"latitude": latitude,
|
||||
"longitude": longitude,
|
||||
"postcode": postcode,
|
||||
"tenantimage": tenantimage,
|
||||
"locationid": locationid,
|
||||
"locationname": locationname,
|
||||
"subcategoryid": subcategoryid,
|
||||
"categoryid": categoryid,
|
||||
"registrationno": registrationno,
|
||||
"orderscount": orderscount,
|
||||
"productsubcategory": subcategories == null
|
||||
? []
|
||||
: List<dynamic>.from(subcategories!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class Subcategory {
|
||||
final int? subcatid;
|
||||
final int? categoryid;
|
||||
final int? tenantid;
|
||||
final String? subcatname;
|
||||
final String? status;
|
||||
final String? image;
|
||||
|
||||
Subcategory({
|
||||
this.subcatid,
|
||||
this.categoryid,
|
||||
this.tenantid,
|
||||
this.subcatname,
|
||||
this.status,
|
||||
this.image,
|
||||
});
|
||||
|
||||
factory Subcategory.fromJson(Map<String, dynamic> json) => Subcategory(
|
||||
subcatid: json["subcatid"],
|
||||
categoryid: json["categoryid"],
|
||||
tenantid: json["tenantid"],
|
||||
subcatname: json["subcatname"],
|
||||
status: json["status"],
|
||||
image: json["image"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"subcatid": subcatid,
|
||||
"categoryid": categoryid,
|
||||
"tenantid": tenantid,
|
||||
"subcatname": subcatname,
|
||||
"status": status,
|
||||
"image": image,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
OrdersResponse ordersResponseFromJson(String str) =>
|
||||
OrdersResponse.fromJson(json.decode(str));
|
||||
|
||||
String ordersResponseToJson(OrdersResponse data) =>
|
||||
json.encode(data.toJson());
|
||||
|
||||
class OrdersResponse {
|
||||
final int? code;
|
||||
final List<OrderDatum>? data;
|
||||
final String? message;
|
||||
final bool? status;
|
||||
|
||||
OrdersResponse({
|
||||
this.code,
|
||||
this.data,
|
||||
this.message,
|
||||
this.status,
|
||||
});
|
||||
|
||||
factory OrdersResponse.fromJson(Map<String, dynamic> json) =>
|
||||
OrdersResponse(
|
||||
code: json["code"],
|
||||
data: json["data"] == null
|
||||
? []
|
||||
: List<OrderDatum>.from(
|
||||
json["data"].map((x) => OrderDatum.fromJson(x))),
|
||||
message: json["message"],
|
||||
status: json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"data": data == null
|
||||
? []
|
||||
: List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"message": message,
|
||||
"status": status,
|
||||
};
|
||||
}
|
||||
|
||||
class OrderDatum {
|
||||
final int? orderheaderid;
|
||||
final String? gstno;
|
||||
final String? orderid;
|
||||
final String? orderstatus;
|
||||
final DateTime? orderdate;
|
||||
final int? itemcount;
|
||||
final double? deliverycharge;
|
||||
final double? orderamount;
|
||||
final double? taxamount;
|
||||
final double? totaltaxamount;
|
||||
final String? tenantname;
|
||||
final String? tenantsuburb;
|
||||
final String? tenantcity;
|
||||
final String? deliveryaddress;
|
||||
final String? deliverystatus;
|
||||
final String? pickupaddress;
|
||||
final String? pickupcustomer;
|
||||
final String? pickupcontactno;
|
||||
final String? deliverycustomer;
|
||||
final String? deliverycontactno;
|
||||
final String? locationname;
|
||||
final String? locationcity;
|
||||
final String? tenantimage;
|
||||
final List<OrderDetail>? orderdetails;
|
||||
|
||||
OrderDatum({
|
||||
this.orderheaderid,
|
||||
this.orderid,
|
||||
this.gstno,
|
||||
this.orderstatus,
|
||||
this.orderdate,
|
||||
this.itemcount,
|
||||
this.deliverycharge,
|
||||
this.orderamount,
|
||||
this.taxamount,
|
||||
this.totaltaxamount,
|
||||
this.tenantname,
|
||||
this.tenantsuburb,
|
||||
this.tenantcity,
|
||||
this.deliveryaddress,
|
||||
this.deliverystatus,
|
||||
this.pickupaddress,
|
||||
this.pickupcustomer,
|
||||
this.pickupcontactno,
|
||||
this.deliverycustomer,
|
||||
this.deliverycontactno,
|
||||
this.locationname,
|
||||
this.locationcity,
|
||||
this.orderdetails,
|
||||
this.tenantimage,
|
||||
});
|
||||
|
||||
factory OrderDatum.fromJson(Map<String, dynamic> json) => OrderDatum(
|
||||
orderheaderid: json["orderheaderid"],
|
||||
orderid: json["orderid"],
|
||||
gstno: json["registrationno"],
|
||||
orderstatus: json["orderstatus"],
|
||||
orderdate:
|
||||
json["orderdate"] == null ? null : DateTime.parse(json["orderdate"]),
|
||||
itemcount: json["itemcount"],
|
||||
deliverycharge: json["deliverycharge"]?.toDouble(),
|
||||
orderamount: json["orderamount"]?.toDouble(),
|
||||
taxamount: json["taxamount"]?.toDouble(),
|
||||
totaltaxamount: json["totaltaxamount"]?.toDouble(),
|
||||
tenantname: json["tenantname"],
|
||||
tenantsuburb: json["tenantsuburb"],
|
||||
tenantcity: json["tenantcity"],
|
||||
deliveryaddress: json["deliveryaddress"],
|
||||
deliverystatus: json["deliverystatus"],
|
||||
pickupaddress: json["pickupaddress"],
|
||||
pickupcustomer: json["pickupcustomer"],
|
||||
pickupcontactno: json["pickupcontactno"],
|
||||
deliverycustomer: json["deliverycustomer"],
|
||||
deliverycontactno: json["deliverycontactno"],
|
||||
locationname: json["locationname"],
|
||||
tenantimage: json["tenantimage"],
|
||||
locationcity: json["locationcity"],
|
||||
orderdetails: json["orderdetails"] == null
|
||||
? []
|
||||
: List<OrderDetail>.from(
|
||||
json["orderdetails"].map((x) => OrderDetail.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"orderheaderid": orderheaderid,
|
||||
"orderid": orderid,
|
||||
"gstno": gstno,
|
||||
"orderstatus": orderstatus,
|
||||
"orderdate": orderdate?.toIso8601String(),
|
||||
"itemcount": itemcount,
|
||||
"deliverycharge": deliverycharge,
|
||||
"orderamount": orderamount,
|
||||
"taxamount": taxamount,
|
||||
"totaltaxamount": totaltaxamount,
|
||||
"tenantname": tenantname,
|
||||
"tenantsuburb": tenantsuburb,
|
||||
"tenantcity": tenantcity,
|
||||
"deliveryaddress": deliveryaddress,
|
||||
"deliverystatus": deliverystatus,
|
||||
"pickupaddress": pickupaddress,
|
||||
"pickupcustomer": pickupcustomer,
|
||||
"pickupcontactno": pickupcontactno,
|
||||
"deliverycustomer": deliverycustomer,
|
||||
"deliverycontactno": deliverycontactno,
|
||||
"locationname": locationname,
|
||||
"locationcity": locationcity,
|
||||
"orderdetails": orderdetails == null
|
||||
? []
|
||||
: List<dynamic>.from(orderdetails!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class OrderDetail {
|
||||
final int? orderdetailid;
|
||||
final int? orderheaderid;
|
||||
final int? productid;
|
||||
final String? productname;
|
||||
final String? productdescription;
|
||||
final int? orderqty;
|
||||
final double? price;
|
||||
final String? unitname;
|
||||
final double? productsumprice;
|
||||
final String? productimage;
|
||||
|
||||
OrderDetail({
|
||||
this.orderdetailid,
|
||||
this.orderheaderid,
|
||||
this.productid,
|
||||
this.productname,
|
||||
this.productdescription,
|
||||
this.orderqty,
|
||||
this.price,
|
||||
this.unitname,
|
||||
this.productsumprice,
|
||||
this.productimage,
|
||||
});
|
||||
|
||||
factory OrderDetail.fromJson(Map<String, dynamic> json) => OrderDetail(
|
||||
orderdetailid: json["orderdetailid"],
|
||||
orderheaderid: json["orderheaderid"],
|
||||
productid: json["productid"],
|
||||
productname: json["productname"],
|
||||
productdescription: json["productdescription"],
|
||||
orderqty: json["orderqty"],
|
||||
price: json["price"]?.toDouble(),
|
||||
unitname: json["unitname"],
|
||||
productsumprice: json["productsumprice"]?.toDouble(),
|
||||
productimage: json["productimage"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"orderdetailid": orderdetailid,
|
||||
"orderheaderid": orderheaderid,
|
||||
"productid": productid,
|
||||
"productname": productname,
|
||||
"productdescription": productdescription,
|
||||
"orderqty": orderqty,
|
||||
"price": price,
|
||||
"unitname": unitname,
|
||||
"productsumprice": productsumprice,
|
||||
"productimage": productimage,
|
||||
};
|
||||
}
|
||||
class TenantLocation {
|
||||
final int locationId;
|
||||
final int tenantId;
|
||||
final int applocationId;
|
||||
final int moduleId;
|
||||
final int roleId;
|
||||
final String locationName;
|
||||
final String email;
|
||||
final String contactNo;
|
||||
final String latitude;
|
||||
final String longitude;
|
||||
final String address;
|
||||
final String suburb;
|
||||
final String city;
|
||||
final String state;
|
||||
final String postcode;
|
||||
final String openTime;
|
||||
final String closeTime;
|
||||
final int partnerId;
|
||||
final int deliveryRadius;
|
||||
final int deliveryMins;
|
||||
final int cancelSecs;
|
||||
final String status;
|
||||
|
||||
TenantLocation({
|
||||
required this.locationId,
|
||||
required this.tenantId,
|
||||
required this.applocationId,
|
||||
required this.moduleId,
|
||||
required this.roleId,
|
||||
required this.locationName,
|
||||
required this.email,
|
||||
required this.contactNo,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.address,
|
||||
required this.suburb,
|
||||
required this.city,
|
||||
required this.state,
|
||||
required this.postcode,
|
||||
required this.openTime,
|
||||
required this.closeTime,
|
||||
required this.partnerId,
|
||||
required this.deliveryRadius,
|
||||
required this.deliveryMins,
|
||||
required this.cancelSecs,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory TenantLocation.fromJson(Map<String, dynamic> json) {
|
||||
return TenantLocation(
|
||||
locationId: json['locationid'] ?? 0,
|
||||
tenantId: json['tenantid'] ?? 0,
|
||||
applocationId: json['applocationid'] ?? 0,
|
||||
moduleId: json['moduleid'] ?? 0,
|
||||
roleId: json['roleid'] ?? 0,
|
||||
locationName: json['locationname'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
contactNo: json['contactno'] ?? '',
|
||||
latitude: json['latitude'] ?? '',
|
||||
longitude: json['longitude'] ?? '',
|
||||
address: json['address'] ?? '',
|
||||
suburb: json['suburb'] ?? '',
|
||||
city: json['city'] ?? '',
|
||||
state: json['state'] ?? '',
|
||||
postcode: json['postcode'] ?? '',
|
||||
openTime: json['opentime'] ?? '',
|
||||
closeTime: json['closetime'] ?? '',
|
||||
partnerId: json['partnerid'] ?? 0,
|
||||
deliveryRadius: json['deliveryradius'] ?? 0,
|
||||
deliveryMins: json['deliverymins'] ?? 0,
|
||||
cancelSecs: json['cancelsecs'] ?? 0,
|
||||
status: json['status'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'locationid': locationId,
|
||||
'tenantid': tenantId,
|
||||
'applocationid': applocationId,
|
||||
'moduleid': moduleId,
|
||||
'roleid': roleId,
|
||||
'locationname': locationName,
|
||||
'email': email,
|
||||
'contactno': contactNo,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'address': address,
|
||||
'suburb': suburb,
|
||||
'city': city,
|
||||
'state': state,
|
||||
'postcode': postcode,
|
||||
'opentime': openTime,
|
||||
'closetime': closeTime,
|
||||
'partnerid': partnerId,
|
||||
'deliveryradius': deliveryRadius,
|
||||
'deliverymins': deliveryMins,
|
||||
'cancelsecs': cancelSecs,
|
||||
'status': status,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class TenantLocationsResponse {
|
||||
final int code;
|
||||
final List<TenantLocation> details;
|
||||
final String message;
|
||||
final bool status;
|
||||
|
||||
TenantLocationsResponse({
|
||||
required this.code,
|
||||
required this.details,
|
||||
required this.message,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory TenantLocationsResponse.fromJson(Map<String, dynamic> json) {
|
||||
final listJson = json['details'] as List<dynamic>?; // safer cast
|
||||
final detailsList = listJson != null
|
||||
? listJson.map((e) => TenantLocation.fromJson(e as Map<String, dynamic>)).toList()
|
||||
: <TenantLocation>[];
|
||||
|
||||
return TenantLocationsResponse(
|
||||
code: json['code'] ?? 0,
|
||||
details: detailsList,
|
||||
message: json['message'] ?? '',
|
||||
status: json['status'] ?? true, // default true if API doesn't send
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'code': code,
|
||||
'details': details.map((e) => e.toJson()).toList(),
|
||||
'message': message,
|
||||
'status': status,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user