You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_common_app/lib/models/chat_models/chat_message_model.dart

106 lines
3.0 KiB
Dart

import 'dart:developer';
import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/utils/enums.dart';
class ChatMessageModel {
int? id;
String? senderUserID;
String? senderName;
int? messageType;
ChatMessageTypeEnum? chatMessageTypeEnum;
String? chatText;
int? requestID;
int? reqOfferID;
int? serviceProviderID;
int? offerStatus;
ReqOffer? reqOffer;
bool? isRead;
String? readOn;
bool? isMyMessage;
ChatMessageModel({
this.id,
this.senderUserID,
this.senderName,
this.messageType,
this.chatMessageTypeEnum,
this.chatText,
this.requestID,
this.reqOfferID,
this.serviceProviderID,
this.offerStatus,
this.reqOffer,
this.isRead,
this.readOn,
this.isMyMessage,
});
@override
String toString() {
return 'ChatMessageModel{id: $id, senderUserID: $senderUserID, senderName: $senderName, messageType: $messageType, chatMessageTypeEnum: $chatMessageTypeEnum, chatText: $chatText, requestID: $requestID, reqOfferID: $reqOfferID, serviceProviderID: $serviceProviderID, offerStatus: $offerStatus, reqOffer: $reqOffer, isRead: $isRead, readOn: $readOn, isMyMessage: $isMyMessage}';
}
ChatMessageModel.fromJson(Map<String, dynamic> json) {
final myUserId = AppState().getUser.data!.userInfo!.userId.toString().toUpperCase();
id = json['id'];
senderUserID = json['senderUserID'];
senderName = json['senderName'];
messageType = json['messageType'];
chatMessageTypeEnum = (json['messageType'] as int).toChatMessageTypeEnum();
chatText = json['chatText'];
requestID = json['requestID'];
reqOfferID = json['reqOfferID'];
serviceProviderID = json['serviceProviderID'];
offerStatus = json['offerStatus'];
reqOffer = json['reqOffer'] != null ? ReqOffer.fromJson(json['reqOffer']) : null;
isRead = json['isRead'];
readOn = json['readOn'];
isMyMessage = (json['senderUserID']).toString().toUpperCase()== myUserId;
}
}
class ReqOffer {
int? id;
int? requestID;
int? serviceProviderID;
int? offerStatus;
String? offerStatusText;
String? comment;
double? price;
RequestOfferStatusEnum? requestOfferStatusEnum;
ReqOffer({
this.id,
this.requestID,
this.serviceProviderID,
this.offerStatus,
this.offerStatusText,
this.comment,
this.price,
this.requestOfferStatusEnum,
});
ReqOffer.fromJson(Map<String, dynamic> json) {
log("the json: $json");
id = json['id'];
requestID = json['requestID'];
serviceProviderID = json['serviceProviderID'];
offerStatus = json['offerStatus'];
offerStatusText = json['offerStatusText'];
comment = json['comment'];
price = json['price'];
requestOfferStatusEnum = ((json['offerStatus']) as int).toRequestOfferStatusEnum();
}
}
class OfferRequestCommentModel {
int? index;
String? title;
bool? isSelected;
OfferRequestCommentModel({this.index, this.title, this.isSelected});
}