133 lines
3.3 KiB
Dart
133 lines
3.3 KiB
Dart
import 'dart:convert';
|
|
|
|
class TableResponseModel {
|
|
final bool? success;
|
|
final TableData? data;
|
|
final dynamic errors;
|
|
|
|
TableResponseModel({
|
|
this.success,
|
|
this.data,
|
|
this.errors,
|
|
});
|
|
|
|
factory TableResponseModel.fromJson(String str) =>
|
|
TableResponseModel.fromMap(json.decode(str));
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory TableResponseModel.fromMap(Map<String, dynamic> json) =>
|
|
TableResponseModel(
|
|
success: json["success"],
|
|
data: json["data"] == null ? null : TableData.fromMap(json["data"]),
|
|
errors: json["errors"],
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"success": success,
|
|
"data": data?.toMap(),
|
|
"errors": errors,
|
|
};
|
|
}
|
|
|
|
class TableData {
|
|
final List<TableModel>? tables;
|
|
final int? totalCount;
|
|
final int? page;
|
|
final int? limit;
|
|
final int? totalPages;
|
|
|
|
TableData({
|
|
this.tables,
|
|
this.totalCount,
|
|
this.page,
|
|
this.limit,
|
|
this.totalPages,
|
|
});
|
|
|
|
factory TableData.fromMap(Map<String, dynamic> json) => TableData(
|
|
tables: json["tables"] == null
|
|
? []
|
|
: List<TableModel>.from(
|
|
json["tables"].map((x) => TableModel.fromMap(x))),
|
|
totalCount: json["total_count"],
|
|
page: json["page"],
|
|
limit: json["limit"],
|
|
totalPages: json["total_pages"],
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"tables": tables == null
|
|
? []
|
|
: List<dynamic>.from(tables!.map((x) => x.toMap())),
|
|
"total_count": totalCount,
|
|
"page": page,
|
|
"limit": limit,
|
|
"total_pages": totalPages,
|
|
};
|
|
}
|
|
|
|
class TableModel {
|
|
String? id;
|
|
String? organizationId;
|
|
String? outletId;
|
|
String? tableName;
|
|
String? status;
|
|
int? paymentAmount;
|
|
double? positionX;
|
|
double? positionY;
|
|
int? capacity;
|
|
bool? isActive;
|
|
DateTime? createdAt;
|
|
DateTime? updatedAt;
|
|
|
|
TableModel({
|
|
this.id,
|
|
this.organizationId,
|
|
this.outletId,
|
|
this.tableName,
|
|
this.status,
|
|
this.paymentAmount,
|
|
this.positionX,
|
|
this.positionY,
|
|
this.capacity,
|
|
this.isActive,
|
|
this.createdAt,
|
|
this.updatedAt,
|
|
});
|
|
|
|
factory TableModel.fromMap(Map<String, dynamic> json) => TableModel(
|
|
id: json["id"],
|
|
organizationId: json["organization_id"],
|
|
outletId: json["outlet_id"],
|
|
tableName: json["table_name"],
|
|
status: json["status"],
|
|
paymentAmount: json["payment_amount"],
|
|
positionX: json["position_x"]?.toDouble(),
|
|
positionY: json["position_y"]?.toDouble(),
|
|
capacity: json["capacity"],
|
|
isActive: json["is_active"],
|
|
createdAt: json["created_at"] == null
|
|
? null
|
|
: DateTime.parse(json["created_at"]),
|
|
updatedAt: json["updated_at"] == null
|
|
? null
|
|
: DateTime.parse(json["updated_at"]),
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"id": id,
|
|
"organization_id": organizationId,
|
|
"outlet_id": outletId,
|
|
"table_name": tableName,
|
|
"status": status,
|
|
"payment_amount": paymentAmount,
|
|
"position_x": positionX,
|
|
"position_y": positionY,
|
|
"capacity": capacity,
|
|
"is_active": isActive,
|
|
"created_at": createdAt?.toIso8601String(),
|
|
"updated_at": updatedAt?.toIso8601String(),
|
|
};
|
|
}
|