// To parse this JSON data, do
//
// final order = orderFromJson(jsonString);
import 'package:concierge/data/remote/converters/order_status_converter.dart';
import 'package:json_annotation/json_annotation.dart';
part '../../../_generated/data/remote/models/order.g.dart';
enum OrderStatus {
received("RECEIVED"),
accepted("ACCEPTED"),
inProgress("INPROGRESS"),
delivered("DELIVERED"),
cancelled("CANCELLED");
final String serializedValue;
const OrderStatus(this.serializedValue);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Order {
final int id;
@OrderStatusConverter()
final OrderStatus status;
final String type;
final bool isArchived;
final dynamic archivedAt;
final dynamic cancelReason;
final int totalPrice;
final String deliveryMethod;
final String requestedDeliveryTime;
@JsonKey(defaultValue: "ASAP")
final String estimatedDeliveryTime;
final dynamic pickupLocation;
final int areaId;
final int? locationId;
final DateTime createdAt;
final DateTime updatedAt;
final dynamic customerComment;
final bool delivery;
final int deliveryPrice;
final String deliveryMethodString;
final String statusString;
final String typeString;
final String? locationCode;
final List<OrderItem> orderItems;
final Payment payment;
final Customer? customer;
final dynamic lastUpdateFrom;
final Image image;
Order({
required this.id,
required this.status,
required this.type,
required this.isArchived,
required this.archivedAt,
required this.cancelReason,
required this.totalPrice,
required this.deliveryMethod,
required this.requestedDeliveryTime,
required this.estimatedDeliveryTime,
required this.pickupLocation,
required this.areaId,
required this.locationId,
required this.createdAt,
required this.updatedAt,
required this.customerComment,
required this.delivery,
required this.deliveryPrice,
required this.deliveryMethodString,
required this.statusString,
required this.typeString,
required this.locationCode,
required this.orderItems,
required this.payment,
required this.customer,
required this.lastUpdateFrom,
required this.image,
});
factory Order.fromJson(Map<String, dynamic> json) => _$OrderFromJson(json);
Map<String, dynamic> toJson() => _$OrderToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Customer {
final String id;
final String firstName;
final dynamic lastName;
final dynamic email;
final bool isComwellClub;
final String phone;
final String phonePrefix;
Customer({
required this.id,
required this.firstName,
required this.lastName,
required this.email,
required this.isComwellClub,
required this.phone,
required this.phonePrefix,
});
factory Customer.fromJson(Map<String, dynamic> json) => _$CustomerFromJson(json);
Map<String, dynamic> toJson() => _$CustomerToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Image {
final String url;
final String preload;
final String thumbnail;
final String productHero;
final String alt;
Image({
required this.url,
required this.preload,
required this.thumbnail,
required this.productHero,
required this.alt,
});
factory Image.fromJson(Map<String, dynamic> json) => _$ImageFromJson(json);
Map<String, dynamic> toJson() => _$ImageToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class OrderItem {
final int id;
final double price;
final int quantity;
final String itemType;
final String alternativeName;
final int? productId;
final int orderId;
final List<dynamic>? options;
final String itemTypeString;
final List<dynamic> vouchers;
final int totalPrice;
final int totalPriceBeforeSavings;
OrderItem({
required this.id,
required this.price,
required this.quantity,
required this.itemType,
required this.alternativeName,
required this.productId,
required this.orderId,
required this.options,
required this.itemTypeString,
required this.vouchers,
required this.totalPrice,
required this.totalPriceBeforeSavings,
});
factory OrderItem.fromJson(Map<String, dynamic> json) => _$OrderItemFromJson(json);
Map<String, dynamic> toJson() => _$OrderItemToJson(this);
}
@JsonSerializable(fieldRename: FieldRename.snake)
class Payment {
final int id;
final String paymentType;
final dynamic room;
final dynamic meeting;
final dynamic fullName;
final String paymentTypeString;
Payment({
required this.id,
required this.paymentType,
required this.room,
required this.meeting,
required this.fullName,
required this.paymentTypeString,
});
factory Payment.fromJson(Map<String, dynamic> json) => _$PaymentFromJson(json);
Map<String, dynamic> toJson() => _$PaymentToJson(this);
}