Merge pull request #108 from WDI-Ideas/PriyankaH
populattab api integration
This commit is contained in:
@@ -92,6 +92,8 @@ class ApiUrls {
|
||||
static const getblockuser = "${baseUrl}fetch-blocked-profile";
|
||||
static const postblockuser = "${baseUrl}block-profile";
|
||||
static const getlatestpost = "${baseUrl}fetch-latest-post";
|
||||
static const getpopularpost = "${baseUrl}fetch-popular-post";
|
||||
|
||||
static const getfeedpost = "${baseUrl}fetch-post";
|
||||
static const tagcommunityuser = "${baseUrl}fetch-communities-tags-to-pin";
|
||||
|
||||
|
||||
242
lib/Main_Screens/Community/Model/PopularPostModel.dart
Normal file
242
lib/Main_Screens/Community/Model/PopularPostModel.dart
Normal file
@@ -0,0 +1,242 @@
|
||||
class PopularpostModel {
|
||||
PopularpostModel({
|
||||
required this.status,
|
||||
required this.statusCode,
|
||||
required this.message,
|
||||
required this.data,
|
||||
});
|
||||
|
||||
final String? status;
|
||||
final int? statusCode;
|
||||
final String? message;
|
||||
final List<Datum> data;
|
||||
|
||||
factory PopularpostModel.fromJson(Map<String, dynamic> json){
|
||||
return PopularpostModel(
|
||||
status: json["status"],
|
||||
statusCode: json["status_code"],
|
||||
message: json["message"],
|
||||
data: json["data"] == null ? [] : List<Datum>.from(json["data"]!.map((x) => Datum.fromJson(x))),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Datum {
|
||||
Datum({
|
||||
required this.id,
|
||||
required this.likecount,
|
||||
required this.isISaved,
|
||||
required this.tagsXid,
|
||||
required this.isILiked,
|
||||
required this.totalComment,
|
||||
required this.totalSave,
|
||||
required this.iamPrincipalXid,
|
||||
required this.postIn,
|
||||
required this.caption,
|
||||
required this.image,
|
||||
required this.manageTagsXids,
|
||||
required this.postAs,
|
||||
required this.ctaTitle,
|
||||
required this.ctaLink,
|
||||
required this.createdAt,
|
||||
required this.likeIcon,
|
||||
required this.totalViewCount,
|
||||
required this.totalReactionCount,
|
||||
required this.totalCommentCount,
|
||||
required this.totalImpressionCount,
|
||||
required this.totalPopularScore,
|
||||
required this.totalHoursAgo,
|
||||
required this.iamPrincipal,
|
||||
required this.community,
|
||||
required this.attachTags,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final int? likecount;
|
||||
final bool? isISaved;
|
||||
final List<int> tagsXid;
|
||||
final bool? isILiked;
|
||||
final int? totalComment;
|
||||
final int? totalSave;
|
||||
final int? iamPrincipalXid;
|
||||
final int? postIn;
|
||||
final String? caption;
|
||||
final String? image;
|
||||
final String? manageTagsXids;
|
||||
final String? postAs;
|
||||
final String? ctaTitle;
|
||||
final String? ctaLink;
|
||||
final DateTime? createdAt;
|
||||
final LikeIcon? likeIcon;
|
||||
final int? totalViewCount;
|
||||
final int? totalReactionCount;
|
||||
final int? totalCommentCount;
|
||||
final int? totalImpressionCount;
|
||||
final int? totalPopularScore;
|
||||
final int? totalHoursAgo;
|
||||
final IamPrincipal? iamPrincipal;
|
||||
final Community? community;
|
||||
final List<AttachTag> attachTags;
|
||||
|
||||
factory Datum.fromJson(Map<String, dynamic> json){
|
||||
return Datum(
|
||||
id: json["id"],
|
||||
likecount: json["likecount"],
|
||||
isISaved: json["is_i_saved"],
|
||||
tagsXid: json["tags_xid"] == null ? [] : List<int>.from(json["tags_xid"]!.map((x) => x)),
|
||||
isILiked: json["is_i_liked"],
|
||||
totalComment: json["total_comment"],
|
||||
totalSave: json["total_save"],
|
||||
iamPrincipalXid: json["iam_principal_xid"],
|
||||
postIn: json["post_in"],
|
||||
caption: json["caption"],
|
||||
image: json["image"],
|
||||
manageTagsXids: json["manage_tags_xids"],
|
||||
postAs: json["post_as"],
|
||||
ctaTitle: json["cta_title"],
|
||||
ctaLink: json["cta_link"],
|
||||
createdAt: DateTime.tryParse(json["created_at"] ?? ""),
|
||||
likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]),
|
||||
totalViewCount: json["totalViewCount"],
|
||||
totalReactionCount: json["totalReactionCount"],
|
||||
totalCommentCount: json["totalCommentCount"],
|
||||
totalImpressionCount: json["totalImpressionCount"],
|
||||
totalPopularScore: json["totalPopularScore"],
|
||||
totalHoursAgo: json["totalHoursAgo"],
|
||||
iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]),
|
||||
community: json["community"] == null ? null : Community.fromJson(json["community"]),
|
||||
attachTags: json["attach_tags"] == null ? [] : List<AttachTag>.from(json["attach_tags"]!.map((x) => AttachTag.fromJson(x))),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AttachTag {
|
||||
AttachTag({
|
||||
required this.managePostXid,
|
||||
required this.manageTagXid,
|
||||
required this.manageTag,
|
||||
});
|
||||
|
||||
final int? managePostXid;
|
||||
final int? manageTagXid;
|
||||
final ManageTag? manageTag;
|
||||
|
||||
factory AttachTag.fromJson(Map<String, dynamic> json){
|
||||
return AttachTag(
|
||||
managePostXid: json["manage_post_xid"],
|
||||
manageTagXid: json["manage_tag_xid"],
|
||||
manageTag: json["manage_tag"] == null ? null : ManageTag.fromJson(json["manage_tag"]),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ManageTag {
|
||||
ManageTag({
|
||||
required this.id,
|
||||
required this.isPinned,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final bool? isPinned;
|
||||
final String? name;
|
||||
|
||||
factory ManageTag.fromJson(Map<String, dynamic> json){
|
||||
return ManageTag(
|
||||
id: json["id"],
|
||||
isPinned: json["is_pinned"],
|
||||
name: json["name"],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Community {
|
||||
Community({
|
||||
required this.id,
|
||||
required this.communityProfilePhoto,
|
||||
required this.communityName,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? communityProfilePhoto;
|
||||
final String? communityName;
|
||||
|
||||
factory Community.fromJson(Map<String, dynamic> json){
|
||||
return Community(
|
||||
id: json["id"],
|
||||
communityProfilePhoto: json["community_profile_photo"],
|
||||
communityName: json["community_name"],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class IamPrincipal {
|
||||
IamPrincipal({
|
||||
required this.id,
|
||||
required this.isUserPinned,
|
||||
required this.principalTypeXid,
|
||||
required this.userName,
|
||||
required this.fullName,
|
||||
required this.profilePhoto,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final bool? isUserPinned;
|
||||
final int? principalTypeXid;
|
||||
final String? userName;
|
||||
final String? fullName;
|
||||
final String? profilePhoto;
|
||||
|
||||
factory IamPrincipal.fromJson(Map<String, dynamic> json){
|
||||
return IamPrincipal(
|
||||
id: json["id"],
|
||||
isUserPinned: json["is_user_pinned"],
|
||||
principalTypeXid: json["principal_type_xid"],
|
||||
userName: json["user_name"],
|
||||
fullName: json["full_name"],
|
||||
profilePhoto: json["profile_photo"],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LikeIcon {
|
||||
LikeIcon({
|
||||
required this.likeIconsXid,
|
||||
required this.likeIcon,
|
||||
});
|
||||
|
||||
final int? likeIconsXid;
|
||||
final LikeIconClass? likeIcon;
|
||||
|
||||
factory LikeIcon.fromJson(Map<String, dynamic> json){
|
||||
return LikeIcon(
|
||||
likeIconsXid: json["like_icons_xid"],
|
||||
likeIcon: json["like_icon"] == null ? null : LikeIconClass.fromJson(json["like_icon"]),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LikeIconClass {
|
||||
LikeIconClass({
|
||||
required this.id,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? image;
|
||||
|
||||
factory LikeIconClass.fromJson(Map<String, dynamic> json){
|
||||
return LikeIconClass(
|
||||
id: json["id"],
|
||||
image: json["image"],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
26
lib/Main_Screens/Community/ViewModel/PopularPost.dart
Normal file
26
lib/Main_Screens/Community/ViewModel/PopularPost.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:regroup/Common/api_urls.dart';
|
||||
import 'package:regroup/Common/base_manager.dart';
|
||||
import 'package:regroup/Common/controller/data/network/network_api.dart';
|
||||
import 'package:regroup/Main_Screens/Community/Model/PopularPostModel.dart';
|
||||
|
||||
PopularpostModel? popularpostobj;
|
||||
|
||||
class PopularpostApi {
|
||||
PopularpostApi();
|
||||
|
||||
Future<ResponseData<dynamic>> getPopularPostApi() async {
|
||||
final response = await NetworkApiServices().getApi(ApiUrls.getpopularpost);
|
||||
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
if (response.data["status"] == "success") {
|
||||
popularpostobj = PopularpostModel.fromJson(response.data);
|
||||
}
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
} else {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user