2026-01-13 11:36:24 +05:30

338 lines
9.1 KiB
Dart

import 'dart:convert';
PostModel postModelFromJson(String str) => PostModel.fromJson(json.decode(str));
String postModelToJson(PostModel data) => json.encode(data.toJson());
class PostModel {
bool? isSuccess;
int? statusCode;
String? message;
Data? data;
dynamic errors;
PostModel({
this.isSuccess,
this.statusCode,
this.message,
this.data,
this.errors,
});
factory PostModel.fromJson(Map<String, dynamic> json) => PostModel(
isSuccess: json["isSuccess"],
statusCode: json["statusCode"],
message: json["message"],
data: json["data"] == null ? null : Data.fromJson(json["data"]),
errors: json["errors"],
);
Map<String, dynamic> toJson() => {
"isSuccess": isSuccess,
"statusCode": statusCode,
"message": message,
"data": data?.toJson(),
"errors": errors,
};
}
class Data {
int? totalCount;
List<SocialPostItem>? items;
Data({this.totalCount, this.items});
factory Data.fromJson(Map<String, dynamic> json) => Data(
totalCount: json["totalCount"],
items:
json["items"] == null
? []
: List<SocialPostItem>.from(
json["items"]!.map((x) => SocialPostItem.fromJson(x)),
),
);
Map<String, dynamic> toJson() => {
"totalCount": totalCount,
"items":
items == null ? [] : List<dynamic>.from(items!.map((x) => x.toJson())),
};
}
class SocialPostItem {
int? postId;
String? userId;
String? firstName;
String? lastName;
String? fullName;
String? profilePicture;
int? userTypeId;
String? userTypeName;
String? coachTypeName;
int? coachRequestStatus;
String? content;
int? postTypeId;
int? postVisibilityId;
int? deviceTypeId;
bool? isTribe;
dynamic tribeId;
DateTime? createdAt;
DateTime? updateAt;
List<MediaFile>? mediaFiles;
Poll? poll;
List<dynamic>? comments;
int? totalPostComments;
int? totalPostReactions;
dynamic postReactionTypeId;
SocialPostItem({
this.postId,
this.userId,
this.firstName,
this.lastName,
this.fullName,
this.profilePicture,
this.userTypeId,
this.userTypeName,
this.coachTypeName,
this.coachRequestStatus,
this.content,
this.postTypeId,
this.postVisibilityId,
this.deviceTypeId,
this.isTribe,
this.tribeId,
this.createdAt,
this.updateAt,
this.mediaFiles,
this.poll,
this.comments,
this.totalPostComments,
this.totalPostReactions,
this.postReactionTypeId,
});
factory SocialPostItem.fromJson(Map<String, dynamic> json) => SocialPostItem(
postId: json["postID"],
userId: json["userID"],
firstName: json["firstName"],
lastName: json["lastName"],
fullName: json["fullName"],
profilePicture: json["profilePicture"],
userTypeId: json["userTypeId"],
userTypeName: json["userTypeName"],
coachTypeName: json["coachTypeName"],
coachRequestStatus: json["coachRequestStatus"],
content: json["content"],
postTypeId: json["postTypeID"],
postVisibilityId: json["postVisibilityID"],
deviceTypeId: json["deviceTypeID"],
isTribe: json["isTribe"],
tribeId: json["tribeID"],
createdAt:
json["createdAt"] == null ? null : DateTime.parse(json["createdAt"]),
updateAt:
json["updateAt"] == null ? null : DateTime.parse(json["updateAt"]),
mediaFiles:
json["mediaFiles"] == null
? []
: List<MediaFile>.from(
json["mediaFiles"]!.map((x) => MediaFile.fromJson(x)),
),
poll: json["poll"] == null ? null : Poll.fromJson(json["poll"]),
comments:
json["comments"] == null
? []
: List<dynamic>.from(json["comments"]!.map((x) => x)),
totalPostComments: json["totalPostComments"],
totalPostReactions: json["totalPostReactions"],
postReactionTypeId: json["postReactionTypeID"],
);
Map<String, dynamic> toJson() => {
"postID": postId,
"userID": userId,
"firstName": firstName,
"lastName": lastName,
"fullName": fullName,
"profilePicture": profilePicture,
"userTypeId": userTypeId,
"userTypeName": userTypeName,
"coachTypeName": coachTypeName,
"coachRequestStatus": coachRequestStatus,
"content": content,
"postTypeID": postTypeId,
"postVisibilityID": postVisibilityId,
"deviceTypeID": deviceTypeId,
"isTribe": isTribe,
"tribeID": tribeId,
"createdAt": createdAt?.toIso8601String(),
"updateAt": updateAt?.toIso8601String(),
"mediaFiles":
mediaFiles == null
? []
: List<dynamic>.from(mediaFiles!.map((x) => x.toJson())),
"poll": poll?.toJson(),
"comments":
comments == null ? [] : List<dynamic>.from(comments!.map((x) => x)),
"totalPostComments": totalPostComments,
"totalPostReactions": totalPostReactions,
"postReactionTypeID": postReactionTypeId,
};
SocialPostItem copyWith({
int? postId,
String? userId,
String? firstName,
String? lastName,
String? fullName,
String? profilePicture,
int? userTypeId,
String? userTypeName,
String? coachTypeName,
int? coachRequestStatus,
String? content,
int? postTypeId,
int? postVisibilityId,
int? deviceTypeId,
bool? isTribe,
dynamic tribeId,
DateTime? createdAt,
DateTime? updateAt,
List<MediaFile>? mediaFiles,
Poll? poll,
List<dynamic>? comments,
int? totalPostComments,
int? totalPostReactions,
dynamic postReactionTypeId,
}) {
return SocialPostItem(
postId: postId ?? this.postId,
userId: userId ?? this.userId,
firstName: firstName ?? this.firstName,
lastName: lastName ?? this.lastName,
fullName: fullName ?? this.fullName,
profilePicture: profilePicture ?? this.profilePicture,
userTypeId: userTypeId ?? this.userTypeId,
userTypeName: userTypeName ?? this.userTypeName,
coachTypeName: coachTypeName ?? this.coachTypeName,
coachRequestStatus: coachRequestStatus ?? this.coachRequestStatus,
content: content ?? this.content,
postTypeId: postTypeId ?? this.postTypeId,
postVisibilityId: postVisibilityId ?? this.postVisibilityId,
deviceTypeId: deviceTypeId ?? this.deviceTypeId,
isTribe: isTribe ?? this.isTribe,
tribeId: tribeId ?? this.tribeId,
createdAt: createdAt ?? this.createdAt,
updateAt: updateAt ?? this.updateAt,
mediaFiles: mediaFiles ?? this.mediaFiles,
poll: poll ?? this.poll,
comments: comments ?? this.comments,
totalPostComments: totalPostComments ?? this.totalPostComments,
totalPostReactions: totalPostReactions ?? this.totalPostReactions,
postReactionTypeId: postReactionTypeId ?? this.postReactionTypeId,
);
}
}
class MediaFile {
String? mediaFile;
String? mediaType;
String? thumbnailFile;
MediaFile({this.mediaFile, this.mediaType, this.thumbnailFile});
factory MediaFile.fromJson(Map<String, dynamic> json) => MediaFile(
mediaFile: json["mediaFile"],
mediaType: json["mediaType"],
thumbnailFile: json["thumbnailFile"],
);
Map<String, dynamic> toJson() => {
"mediaFile": mediaFile,
"mediaType": mediaType,
"thumbnailFile": thumbnailFile,
};
}
class Poll {
int? pollPostId;
String? question;
DateTime? expiryDate;
List<Option>? options;
int? totalPollVotes;
Poll({
this.pollPostId,
this.question,
this.expiryDate,
this.options,
this.totalPollVotes,
});
factory Poll.fromJson(Map<String, dynamic> json) => Poll(
pollPostId: json["pollPostID"],
question: json["question"],
expiryDate:
json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]),
options:
json["options"] == null
? []
: List<Option>.from(
json["options"]!.map((x) => Option.fromJson(x)),
),
totalPollVotes: json["totalPollVotes"],
);
Map<String, dynamic> toJson() => {
"pollPostID": pollPostId,
"question": question,
"expiryDate": expiryDate?.toIso8601String(),
"options":
options == null
? []
: List<dynamic>.from(options!.map((x) => x.toJson())),
"totalPollVotes": totalPollVotes,
};
}
class Option {
int? optionId;
int? pollId;
String? userId;
String? optionLabel;
int? totalOptionPollVotes;
int? percentageOptionPollVotes;
bool? hasUserVoted;
Option({
this.optionId,
this.pollId,
this.userId,
this.optionLabel,
this.totalOptionPollVotes,
this.percentageOptionPollVotes,
this.hasUserVoted,
});
factory Option.fromJson(Map<String, dynamic> json) => Option(
optionId: json["optionID"],
pollId: json["pollID"],
userId: json["userID"],
optionLabel: json["optionLabel"],
totalOptionPollVotes: json["totalOptionPollVotes"],
percentageOptionPollVotes: json["percentageOptionPollVotes"],
hasUserVoted: json["hasUserVoted"],
);
Map<String, dynamic> toJson() => {
"optionID": optionId,
"pollID": pollId,
"userID": userId,
"optionLabel": optionLabel,
"totalOptionPollVotes": totalOptionPollVotes,
"percentageOptionPollVotes": percentageOptionPollVotes,
"hasUserVoted": hasUserVoted,
};
}