From 188944e9768ecdd56c2dbd97299ad9cc50d276eb Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sat, 18 May 2024 20:29:08 +0200 Subject: [PATCH 01/19] refactored AdvancedCommunityInfo [ # ] AdvancedCommunityInfo is now adapted to work with the default JSON serializer [ + ] Added AdvancedCommunitySettings [ + ] Added CommunityNewsFeed [ + ] Added CommunityRankingTable [ + ] Added CommunityThemePack --- Amino.NET/Objects/AdvancedCommunityInfo.cs | 254 +++--------------- .../Objects/CommunityAdvancedSettings.cs | 21 ++ Amino.NET/Objects/CommunityNewsFeed.cs | 15 ++ Amino.NET/Objects/CommunityRankingTable.cs | 17 ++ Amino.NET/Objects/CommunityThemePack.cs | 18 ++ 5 files changed, 104 insertions(+), 221 deletions(-) create mode 100644 Amino.NET/Objects/CommunityAdvancedSettings.cs create mode 100644 Amino.NET/Objects/CommunityNewsFeed.cs create mode 100644 Amino.NET/Objects/CommunityRankingTable.cs create mode 100644 Amino.NET/Objects/CommunityThemePack.cs diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs index 0329813..f5cc16b 100644 --- a/Amino.NET/Objects/AdvancedCommunityInfo.cs +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -4,231 +4,43 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class AdvancedCommunityInfo { - public bool isCurrentUserJoined { get; } - public bool searchable { get; } - public bool isStandaloneAppDeprecated { get; } - public int listedStatus { get; } - public int probationStatus { get; } - public string keywords { get; } - public int membersCount { get; } - public string primaryLanguage { get; } - public float communityHeat { get; } - public string content { get; } - public bool isStandaloneAppMonetizationEnabled { get; } - public string tagline { get; } - public int joinType { get; } - public int status { get; } - public string modifiedTime { get; } - public int communityId { get; } - public string link { get; } - public string iconUrl { get; } - public string updatedTime { get; } - public string endpoint { get; } - public string name { get; } - public int templateId { get; } - public string createdTime { get; } - public string json { get; } - public List<_User> communityHeadList { get; } = new List<_User>(); - public _User Agent { get; } - public _ThemePack ThemePack { get; } - public _AdvancedSettings AdvancedSettings { get; } - - - - public AdvancedCommunityInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { isCurrentUserJoined = (bool)jsonObj["isCurrentUserJoined"]; } catch { } - try { searchable = (bool)jsonObj["community"]["searchable"]; } catch { } - try { isStandaloneAppDeprecated = (bool)jsonObj["community"]["isStandaloneAppDeprecated"]; } catch { } - try { listedStatus = (int)jsonObj["community"]["listedStatus"]; } catch { } - try { probationStatus = (int)jsonObj["community"]["probationStatus"]; }catch { } - try { keywords = (string)jsonObj["community"]["keywords"]; }catch { } - try { membersCount = (int)jsonObj["community"]["membersCount"]; }catch { } - try { primaryLanguage = (string)jsonObj["community"]["primaryLanguage"]; } catch { } - try { communityHeat = (float)jsonObj["community"]["communityHeat"]; } catch { } - try { content = (string)jsonObj["community"]["content"]; } catch { } - try { isStandaloneAppMonetizationEnabled = (bool)jsonObj["community"]["isStandaloneAppMonetizationEnabled"]; } catch { } - try { tagline = (string)jsonObj["community"]["tagline"]; } catch { } - try { joinType = (int)jsonObj["community"]["joinType"]; } catch { } - try { status = (int)jsonObj["community"]["status"]; } catch { } - try { modifiedTime = (string)jsonObj["community"]["modifiedTime"]; } catch { } - try { communityId = (int)jsonObj["community"]["ndcId"]; } catch { } - try { link = (string)jsonObj["community"]["link"]; } catch { } - try { iconUrl = (string)jsonObj["community"]["icon"]; } catch { } - try { updatedTime = (string)jsonObj["community"]["updatedTime"]; }catch { } - try { endpoint = (string)jsonObj["community"]["endpoint"]; } catch { } - try { name = (string)jsonObj["community"]["name"]; } catch { } - try { templateId = (int)jsonObj["community"]["templateId"]; }catch { } - try { createdTime = (string)jsonObj["community"]["createdTime"]; } catch { } - try { json = _json.ToString(); } catch { } - try { Agent = new _User(jsonObj["community"]["agent"]); } catch { } - try { ThemePack = new _ThemePack(jsonObj["community"]["themePack"]); } catch { } - try { AdvancedSettings = new _AdvancedSettings(jsonObj["community"]["advancedSettings"]); } catch { } - try - { - JArray userArray = jsonObj["community"]["communityHeadList"]; - if (userArray != null) - { - foreach (JObject user in userArray) - { - _User _user = new _User(user); - communityHeadList.Add(_user); - } - } - - }catch { } - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _User - { - public int status { get; } - public bool isNicknameVerified { get; } - public string userId { get; } - public int level { get; } - public int followingStatus { get; } - public int accountMembershipStatus { get; } - public bool isGlobal { get; } - public int membershipStatus { get; } - public string avatarFrameId { get; } - public int reputation { get; } - public int role { get; } - public int communityId { get; } - public int membersCount { get; } - public string nickname { get; } - public string iconUrl { get; } - - - public _User(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { status = (int)jsonObj["status"]; } catch { } - try { isNicknameVerified = (bool)jsonObj["isNicknameVerified"]; } catch { } - try { userId = (string)jsonObj["uid"]; } catch { } - try { level = (int)jsonObj["level"]; } catch { } - try { followingStatus = (int)jsonObj["followingStatus"]; } catch { } - try { accountMembershipStatus = (int)jsonObj["accountMembershipStatus"]; } catch { } - try { isGlobal = (bool)jsonObj["isGlobal"]; } catch { } - try { membershipStatus = (int)jsonObj["membershipStatus"]; } catch { } - try { avatarFrameId = (string)jsonObj["avatarFrameId"]; } catch { } - try { reputation = (int)jsonObj["reputation"]; } catch { } - try { role = (int)jsonObj["role"]; } catch { } - try { communityId = (int)jsonObj["ndcId"]; } catch { } - try { membersCount = (int)jsonObj["membersCount"]; } catch { } - try { nickname = (string)jsonObj["nickname"]; } catch { } - try { iconUrl = (string)jsonObj["icon"]; } catch { } - - } - - - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _ThemePack - { - public string themeColor { get; } - public string themePackHash { get; } - public int themePackRevision { get; } - public string themePackUrl { get; } - - public _ThemePack(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { themeColor = (string)jsonObj["themeColor"]; } catch { } - try { themePackHash = (string)jsonObj["themePackHash"]; } catch { } - try { themePackRevision = (int)jsonObj["themePackRevision"]; } catch { } - try { themePackUrl = (string)jsonObj["themePackUrl"]; } catch { } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AdvancedSettings - { - public int defaultRakingTypeInLeaderBoard { get; } - public int frontPageLayout { get; } - public bool hasPendingReviewRequest { get; } - public bool welcomeMessageEnabled { get; } - public string welcomeMessageText { get; } - public int pollMinFullBarCount { get; } - public bool catalogEnabled { get; } - public List<_NewsFeed> NewsFeed { get; } = new List<_NewsFeed>(); - public List<_Ranks> Ranks { get; } = new List<_Ranks>(); - - public _AdvancedSettings(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { defaultRakingTypeInLeaderBoard = (int)jsonObj["defaultRankingTypeInLeaderboard"]; } catch { } - try { frontPageLayout = (int)jsonObj["frontPageLayout"]; } catch { } - try { hasPendingReviewRequest = (bool)jsonObj["hasPendingReviewRequest"]; } catch { } - try { welcomeMessageEnabled = (bool)jsonObj["welcomeMessageEnabled"]; } catch { } - try { pollMinFullBarCount = (int)jsonObj["pollMinFullBarCount"]; } catch { } - try { catalogEnabled = (bool)jsonObj["catalogEnabled"]; } catch { } - try - { - JArray newsFeed = jsonObj["newsfeedPages"]; - foreach (JObject post in newsFeed) - { - _NewsFeed _post = new _NewsFeed(post); - NewsFeed.Add(_post); - } - }catch { } - try - { - JArray ranks = jsonObj["rankingTable"]; - foreach (JObject rank in ranks) - { - _Ranks _rank = new _Ranks(rank); - Ranks.Add(_rank); - } - }catch { } - } - - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _NewsFeed - { - public int status { get; } - public int type { get; } - - public _NewsFeed(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { status = (int)jsonObj["status"]; } catch { } - try { type = (int)jsonObj["type"]; } catch { } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Ranks - { - public int level { get; } - public int reputation { get; } - public string id { get; } - public string title { get; } - - public _Ranks(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { level = (int)jsonObj["level"]; } catch { } - try { reputation = (int)jsonObj["reputation"]; } catch { } - try { id = (string)jsonObj["id"]; } catch { } - try { title = (string)jsonObj["title"]; } catch { } - } - } - - } - - + // Base JSON key: community + + public bool IsCurrentUserJoined { get; set; } // MUST BE SET AFTER + public string json { get; set; } // MUST BE SET AFTER + [JsonPropertyName("searchable")] public bool Searchable { get; set; } + [JsonPropertyName("isStandaloneAppDepricated")] public bool IsStandaloneAppDeprecated { get; set; } + [JsonPropertyName("listedStatus")] public int ListedStatus { get; set; } + [JsonPropertyName("probationStatus")] public int ProbationStatus { get; set; } + [JsonPropertyName("keywords")] public string Keywords { get; set; } + [JsonPropertyName("membersCount")] public int MemberCount { get; set; } + [JsonPropertyName("primaryLanguage")] public string PrimaryLanguage { get; set; } + [JsonPropertyName("communityHeat")] public float CommunityHeat { get; set; } + [JsonPropertyName("content")] public string Content { get; set; } + [JsonPropertyName("isStandaloneAppMonetizationEnabled")] public bool IsStandaloneAppMonetizationEnabled { get; set; } + [JsonPropertyName("tagline")] public string Tagline { get; set; } + [JsonPropertyName("joinType")] public int JoinType { get; set; } + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; } + [JsonPropertyName("ndcId")] public int CommunityId { get; set; } + [JsonPropertyName("link")] public string Link { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + [JsonPropertyName("updatedTime")] public string UpdatedTime { get; set; } + [JsonPropertyName("endpoint")] public string Endpoint { get; set; } + [JsonPropertyName("name")] public string Name { get; set; } + [JsonPropertyName("templateId")] public int TemplateId { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + + [JsonPropertyName("communityHeadList")] public List CommunityHeadList { get; set; } + [JsonPropertyName("agent")] public CommunityProfile Agent { get; set; } + [JsonPropertyName("themePack")] public CommunityThemePack ThemePack { get; set; } + [JsonPropertyName("advancedSettings")] public CommunityAdvancedSettings AdvancedSettings { get; } } -} +} \ No newline at end of file diff --git a/Amino.NET/Objects/CommunityAdvancedSettings.cs b/Amino.NET/Objects/CommunityAdvancedSettings.cs new file mode 100644 index 0000000..d52659e --- /dev/null +++ b/Amino.NET/Objects/CommunityAdvancedSettings.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class CommunityAdvancedSettings + { + [JsonPropertyName("defaultRankingTypeInLeaderboard")] public int DefaultRankingTypeInLeaderboard { get; set; } + [JsonPropertyName("frontPageLayout")] public int FrontPageLayout { get; set; } + [JsonPropertyName("hasPendingReviewRequest")] public bool HasPendingReviewRequest { get; set; } + [JsonPropertyName("welcomeMessageEnabled")] public bool WelcomeMessageEnabled { get; set; } + [JsonPropertyName("pollMinFullBarCount")] public int PollMinFullBarCount { get; set; } + [JsonPropertyName("catalogEnabled")] public bool CatalogEnabled { get; set; } + [JsonPropertyName("newsFeedPages")] public List NewsFeed { get; set; } + [JsonPropertyName("rankingTable")] public List Ranks { get; set; } + } +} diff --git a/Amino.NET/Objects/CommunityNewsFeed.cs b/Amino.NET/Objects/CommunityNewsFeed.cs new file mode 100644 index 0000000..1a4d43d --- /dev/null +++ b/Amino.NET/Objects/CommunityNewsFeed.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class CommunityNewsFeed + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("type")] public int Type { get; set; } + } +} diff --git a/Amino.NET/Objects/CommunityRankingTable.cs b/Amino.NET/Objects/CommunityRankingTable.cs new file mode 100644 index 0000000..9f048f5 --- /dev/null +++ b/Amino.NET/Objects/CommunityRankingTable.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class CommunityRankingTable + { + [JsonPropertyName("level")] public int Level { get; set; } + [JsonPropertyName("reputation")] public int Reputation { get; set; } + [JsonPropertyName("id")] public string ID { get; set; } + [JsonPropertyName("title")] public string Title { get; set; } + } +} diff --git a/Amino.NET/Objects/CommunityThemePack.cs b/Amino.NET/Objects/CommunityThemePack.cs new file mode 100644 index 0000000..3022811 --- /dev/null +++ b/Amino.NET/Objects/CommunityThemePack.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class CommunityThemePack + { + [JsonPropertyName("themeColor")] public string ThemeColor { get; set; } + [JsonPropertyName("themePackHash")] public string ThemePackHash { get; set; } + [JsonPropertyName("themePackRevision")] public string ThemePackRevision { get; set; } + [JsonPropertyName("themePackUrl")] public string ThemePackUrl { get; set; } + } +} From f249d679004d1c1d5c26bda3f5e40ca9cb51aeea Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sat, 18 May 2024 20:51:29 +0200 Subject: [PATCH 02/19] refactored AvatarFrame [ # ] AvatarFrame is now set to work with the default JSON class [ + ] Added AdditionalItemInfo [ + ] Added AvatarFrameConfig [ + ] Added ItemOwnershipInfo [ + ] Added ItemRestrictionInfo [ + ] Added AdditionalItemBenefits --- Amino.NET/Objects/AdditionalItemBenefits.cs | 14 ++ Amino.NET/Objects/AvatarFrame.cs | 142 +++----------------- Amino.NET/Objects/AvatarFrameConfig.cs | 19 +++ Amino.NET/Objects/ItemOwnershipInfo.cs | 18 +++ Amino.NET/Objects/ItemRestrictionInfo.cs | 20 +++ 5 files changed, 91 insertions(+), 122 deletions(-) create mode 100644 Amino.NET/Objects/AdditionalItemBenefits.cs create mode 100644 Amino.NET/Objects/AvatarFrameConfig.cs create mode 100644 Amino.NET/Objects/ItemOwnershipInfo.cs create mode 100644 Amino.NET/Objects/ItemRestrictionInfo.cs diff --git a/Amino.NET/Objects/AdditionalItemBenefits.cs b/Amino.NET/Objects/AdditionalItemBenefits.cs new file mode 100644 index 0000000..da394ea --- /dev/null +++ b/Amino.NET/Objects/AdditionalItemBenefits.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class AdditionalItemBenefits + { + [JsonPropertyName("firstMonthFreeAminoPlusMembership")] public bool FirstMonthFreeAminoPlus { get; set; } + } +} diff --git a/Amino.NET/Objects/AvatarFrame.cs b/Amino.NET/Objects/AvatarFrame.cs index 3737482..d448864 100644 --- a/Amino.NET/Objects/AvatarFrame.cs +++ b/Amino.NET/Objects/AvatarFrame.cs @@ -1,131 +1,29 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class AvatarFrame { - public bool isGloballyAvailable { get; } - public bool isNew { get; } - public int version { get; } - public string createdTime { get; } - public int frameType { get; } - public string modifiedTime { get; } - public string frameUrl { get; } - public string md5 { get; } - public string iconUrl { get; } - public string frameId { get; } - public string objectId { get; } - public int ownershipStatus { get; } - public string name { get; } - public string resourceUrl { get; } - public int status { get; } - public _AdditionalBenefits AdditionalBenefits { get; } - public _RestrictionInfo RestrictionInfo { get; } - public _OwnershipInfo OwnershipInfo { get; } - public _Config Config { get; } - - - public AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - isGloballyAvailable = (bool)jsonObj["isGloballyAvailable"]; - isNew = (bool)jsonObj["isNew"]; - version = (int)jsonObj["version"]; - createdTime = (string)jsonObj["createdTime"]; - frameType = (int)jsonObj["frameType"]; - modifiedTime = (string)jsonObj["modifiedTime"]; - frameUrl = (string)jsonObj["frameUrl"]; - md5 = (string)jsonObj["md5"]; - iconUrl = (string)jsonObj["icon"]; - frameId = (string)jsonObj["frameId"]; - objectId = (string)jsonObj["uid"]; - ownershipStatus = (int)jsonObj["ownershipStatus"]; - name = (string)jsonObj["name"]; - resourceUrl = (string)jsonObj["resourceUrl"]; - status = (int)jsonObj["status"]; - if(jsonObj["additionalBenefits"] != null) { AdditionalBenefits = new _AdditionalBenefits(_json); } - if(jsonObj["restrictionInfo"] != null) { RestrictionInfo = new _RestrictionInfo(_json); } - if(jsonObj["ownershipInfo"] != null) { OwnershipInfo = new _OwnershipInfo(_json); } - if(jsonObj["config"] != null) { Config = new _Config(_json); } - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AdditionalBenefits - { - public bool firstMonthFreeAminoPlus { get; } - - public _AdditionalBenefits(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - firstMonthFreeAminoPlus = (bool)jsonObj["additionalBenefits"]["firstMonthFreeAminoPlusMembership"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _RestrictionInfo - { - public int restrictValue { get; } - public string availableDuration { get; } - public int discountValue { get; } - public int discountStatus { get; } - public string ownerUserId { get; } - public int ownerType { get; } - public int restrictType { get; } - - public _RestrictionInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - restrictValue = (int)jsonObj["restrictionInfo"]["restrictValue"]; - availableDuration = (string)jsonObj["restrictionInfo"]["availableDuration"]; - if(jsonObj["restrictionInfo"]["discountValue"] != null) { discountValue = (int)jsonObj["restrictionInfo"]["discountValue"]; } - if(jsonObj["restrictionInfo"]["discountStatus"] != null) { discountStatus = (int)jsonObj["restrictionInfo"]["discountStatus"]; } - ownerType = (int)jsonObj["restrictionInfo"]["ownerType"]; - restrictType = (int)jsonObj["restrictionInfo"]["restrictType"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _OwnershipInfo - { - public string createdTime { get; } - public int ownershipStatus { get; } - public bool isAutoRenew { get; } - public string expiredTime { get; } - - public _OwnershipInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - createdTime = (string)jsonObj["ownershipInfo"]["createdTime"]; - ownershipStatus = (int)jsonObj["ownershipInfo"]["ownershipStatus"]; - isAutoRenew = (bool)jsonObj["ownershipInfo"]["isAutoRenew"]; - expiredTime = (string)jsonObj["ownershipInfo"]["expiredTime"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Config - { - public string avatarFramePath { get; } - public string objectId { get; } - public string moodColor { get; } - public string name { get; } - public int version { get; } - public string userIconBorderColor { get; } - - public _Config(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - avatarFramePath = (string)jsonObj["config"]["avatarFramePath"]; - objectId = (string)jsonObj["config"]["id"]; - moodColor = (string)jsonObj["config"]["moodColor"]; - name = (string)jsonObj["config"]["name"]; - version = (int)jsonObj["config"]["version"]; - userIconBorderColor = (string)jsonObj["config"]["userIconBorderColor"]; - } - - } + [JsonPropertyName("isGloballyAvailable")]public bool IsGloballyAvailable { get; set; } + [JsonPropertyName("isNew")]public bool IsNew { get; set; } + [JsonPropertyName("version")]public int Version { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("frameType")]public int FrameType { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("frameUrl")]public string FrameUrl { get; set; } + [JsonPropertyName("md5")]public string MD5 { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } + [JsonPropertyName("frameId")]public string FrameId { get; set; } + [JsonPropertyName("uid")]public string ObjectId { get; set; } + [JsonPropertyName("ownershipStatus")]public int OwnershipStatus { get; set; } + [JsonPropertyName("name")]public string Name { get; set; } + [JsonPropertyName("resourceUrl")]public string ResourceUrl { get; set; } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("additionalBenefits")]public AdditionalItemBenefits AdditionalBenefits { get; set; } + [JsonPropertyName("restrictionInfo")]public ItemRestrictionInfo RestrictionInfo { get; set; } + [JsonPropertyName("ownershipInfo")]public ItemOwnershipInfo OwnershipInfo { get; set; } + [JsonPropertyName("config")]public AvatarFrameConfig Config { get; set; } } } diff --git a/Amino.NET/Objects/AvatarFrameConfig.cs b/Amino.NET/Objects/AvatarFrameConfig.cs new file mode 100644 index 0000000..3db7256 --- /dev/null +++ b/Amino.NET/Objects/AvatarFrameConfig.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class AvatarFrameConfig + { + [JsonPropertyName("avattarFramePath")] public string AvatarFramePath { get; set; } + [JsonPropertyName("id")] public string ObjectId { get; set; } + [JsonPropertyName("moodColor")] public string MoodColor { get; set; } + [JsonPropertyName("name")] public string Name { get; set; } + [JsonPropertyName("version")] public int Version { get; set; } + [JsonPropertyName("userIconBorderColor")] public string UserIconBorderColor { get; set; } + } +} diff --git a/Amino.NET/Objects/ItemOwnershipInfo.cs b/Amino.NET/Objects/ItemOwnershipInfo.cs new file mode 100644 index 0000000..275724f --- /dev/null +++ b/Amino.NET/Objects/ItemOwnershipInfo.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class ItemOwnershipInfo + { + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("ownershipStatus")] public int OwnershipStatus { get; set; } + [JsonPropertyName("isAutoRenew")] public bool IsAutoRenew { get; set; } + [JsonPropertyName("expiredTime")] public string ExpiredTime { get; set; } + } +} diff --git a/Amino.NET/Objects/ItemRestrictionInfo.cs b/Amino.NET/Objects/ItemRestrictionInfo.cs new file mode 100644 index 0000000..8f75a53 --- /dev/null +++ b/Amino.NET/Objects/ItemRestrictionInfo.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class ItemRestrictionInfo + { + [JsonPropertyName("restrictValue")] public int RestrictValue { get; set; } + [JsonPropertyName("availableDuration")] public string AvailableDuration { get; set; } + [JsonPropertyName("discountValue")] public int DiscountValue { get; set; } + [JsonPropertyName("discountStatus")] public int DiscountStatus { get; set; } + [JsonPropertyName("ownerUserId")] public string OwnerUserId { get; set; } + [JsonPropertyName("ownerType")] public int OwnerType { get; set; } + [JsonPropertyName("restrictType")] public int RestrictType { get; set; } + } +} From bbf7396a9873d7df1d41eecc6cd775b3837a3b14 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sat, 18 May 2024 21:11:06 +0200 Subject: [PATCH 03/19] refactored Blog [ # ] Renamed CommunityProfile to GenericProfile as it contains lots of repetetive data not community related [ - ] Deleted BlockedUser as it is just GenericUser [ # ] Adapted Blog to work with the default JSON class [ + ] Added GenericAvatarFrame --- Amino.NET/Client.cs | 6 +- Amino.NET/Objects/AdvancedCommunityInfo.cs | 4 +- Amino.NET/Objects/BlockedUser.cs | 45 ------ Amino.NET/Objects/Blog.cs | 152 ++++-------------- Amino.NET/Objects/GenericAvatarFrame.cs | 20 +++ ...{communityProfile.cs => GenericProfile.cs} | 6 +- 6 files changed, 56 insertions(+), 177 deletions(-) delete mode 100644 Amino.NET/Objects/BlockedUser.cs create mode 100644 Amino.NET/Objects/GenericAvatarFrame.cs rename Amino.NET/Objects/{communityProfile.cs => GenericProfile.cs} (90%) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 6976d64..15bf303 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -749,11 +749,11 @@ public Amino.Objects.EventLog get_event_log() /// /// /// List : Amino.Objects.CommunityProfile - public List get_subClient_profiles(int start = 0, int size = 25) + public List get_subClient_profiles(int start = 0, int size = 25) { if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List profileList = new List(); + List profileList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/community/joined?v=1&start={start}&size={size}"); request.AddHeaders(headers); @@ -767,7 +767,7 @@ public Amino.Objects.EventLog get_event_log() .ToList(); foreach (var profile in profiles) { - Objects.CommunityProfile C_Profile = new Objects.CommunityProfile(profile); + Objects.GenericProfile C_Profile = new Objects.GenericProfile(profile); profileList.Add(C_Profile); } diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs index f5cc16b..d517667 100644 --- a/Amino.NET/Objects/AdvancedCommunityInfo.cs +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -38,8 +38,8 @@ public class AdvancedCommunityInfo [JsonPropertyName("templateId")] public int TemplateId { get; set; } [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } - [JsonPropertyName("communityHeadList")] public List CommunityHeadList { get; set; } - [JsonPropertyName("agent")] public CommunityProfile Agent { get; set; } + [JsonPropertyName("communityHeadList")] public List CommunityHeadList { get; set; } + [JsonPropertyName("agent")] public GenericProfile Agent { get; set; } [JsonPropertyName("themePack")] public CommunityThemePack ThemePack { get; set; } [JsonPropertyName("advancedSettings")] public CommunityAdvancedSettings AdvancedSettings { get; } } diff --git a/Amino.NET/Objects/BlockedUser.cs b/Amino.NET/Objects/BlockedUser.cs deleted file mode 100644 index ce958d9..0000000 --- a/Amino.NET/Objects/BlockedUser.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Amino.Objects -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class BlockedUser - { - public int status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int membershipStatus { get; private set; } - public int reputation { get; private set; } - public int role { get; private set; } - public int communityId { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - public string json { get; private set; } - - public BlockedUser(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["status"]; - isNicknameVerified = (bool)jsonObj["isNicknameVerified"]; - userId = (string)jsonObj["uid"]; - level = (int)jsonObj["level"]; - followingStatus = (int)jsonObj["followingStatus"]; - accountMembershipStatus = (int)jsonObj["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["isGlobal"]; - membershipStatus = (int)jsonObj["membershipStatus"]; - reputation = (int)jsonObj["reputation"]; - role = (int)jsonObj["role"]; - communityId = (int)jsonObj["ndcId"]; - membersCount = (int)jsonObj["membersCount"]; - nickname = (string)jsonObj["nickname"]; - iconUrl = (string)jsonObj["icon"]; - json = _json.ToString(); - } - } -} diff --git a/Amino.NET/Objects/Blog.cs b/Amino.NET/Objects/Blog.cs index 1238b21..2118a3f 100644 --- a/Amino.NET/Objects/Blog.cs +++ b/Amino.NET/Objects/Blog.cs @@ -4,136 +4,38 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class Blog { - - public int globalVotesCount { get; } = 0; - public int globalVotedValue { get; } = 0; - public int votedValue { get; } = 0; - public string keywords { get; } - public string strategyInfo { get; } - public int style { get; } = 0; - public int totalQuizPlayCount { get; } = 0; - public string title { get; } - public int contentRating { get; } = 0; - public string content { get; } - public bool needHidden { get; } = false; - public int guestVotesCount { get; } = 0; - public int type { get; } = 0; - public int status { get; } = 0; - public int globalCommentsCount { get; } = 0; - public string modifiedTime { get; } - public int totalPollVoteCount { get; } = 0; - public string blogId { get; } - public int viewCount { get; } = 0; - public int votesCount { get; } = 0; - public string createdTime { get; } - public int communityId { get; } = 0; - public string endTime { get; } - public int commentsCount { get; } = 0; - public string json { get; } - public _Author Author { get; } - - - public Blog(JObject json) - { - this.json = json.ToString(); - try { globalVotesCount = (int)json["globalVotesCount"]; } catch { } - try { globalVotedValue = (int)json["globalVotedValue"]; } catch { } - try { votedValue = (int)json["votedValue"]; } catch { } - try { keywords = (string)json["keywords"]; } catch { } - try { strategyInfo = (string)json["strategyInfo"]; } catch { } - try { style = (int)json["style"]; } catch { } - try { totalQuizPlayCount = (int)json["totalQuizPlayCount"]; } catch { } - try { title = (string)json["title"]; } catch { } - try { contentRating = (int)json["contentRating"]; } catch { } - try { content = (string)json["content"]; } catch { } - try { needHidden = (bool)json["needHidden"]; } catch { } - try { guestVotesCount = (int)json["guestVotesCount"]; } catch { } - try { type = (int)json["type"]; } catch { } - try { status = (int)json["status"]; } catch { } - try { globalCommentsCount = (int)json["globalCommentsCount"]; } catch { } - try { modifiedTime = (string)json["modifiedTime"]; } catch { } - try { totalPollVoteCount = (int)json["totalPollVoteCount"]; } catch { } - try { blogId = (string)json["blogId"]; } catch { } - try { viewCount = (int)json["viewCount"]; } catch { } - try { votesCount = (int)json["votesCount"]; } catch { } - try { communityId = (int)json["ndcId"]; } catch { } - try { createdTime = (string)json["createdTime"]; } catch { } - try { commentsCount = (int)json["commentsCount"]; } catch { } - Author = new _Author(JObject.Parse((string)json["author"])); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public int status { get; } = 0; - public bool isNicknameVerified { get; } = false; - public int level { get; } = 0; - public int followingStatus { get; } = 0; - public string userId { get; } - public int accountMembershipStatus { get; } - public bool isGlobal { get; } = false; - public int membershipStatus { get; } = 0; - public string avatarFrameId { get; } - public int reputation { get; } = 0; - public int role { get; } = 0; - public int communityId { get; } = 0; - public int membersCount { get; } = 0; - public string nickname { get; } - public string iconUrl { get; } - public _AvatarFrame AvatarFrame { get; } - - public _Author(JObject json) - { - try { status = (int)json["status"]; } catch { } - try { isNicknameVerified = (bool)json["isNicknameVerified"]; } catch { } - try { level = (int)json["level"]; } catch { } - try { userId = (string)json["uid"]; } catch { } - try { accountMembershipStatus = (int)json["accountMembershipStatus"]; } catch { } - try { isGlobal = (bool)json["isGlobal"]; } catch { } - try { followingStatus = (int)json["followingStatus"]; } catch { } - try { membershipStatus = (int)json["membershipStatus"]; } catch { } - try { avatarFrameId = (string)json["avatarFrameId"]; } catch { } - try { reputation = (int)json["reputation"]; } catch { } - try { role = (int)json["role"]; } catch { } - try { communityId = (int)json["ndcId"]; } catch { } - try { membersCount = (int)json["membersCount"]; } catch { } - try { nickname = (string)json["nickname"]; } catch { } - try { iconUrl = (string)json["icon"]; } catch { } - try { AvatarFrame = new(JObject.Parse((string)json["avatarFrame"])); } catch { } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } = 0; - public int version { get; } = 0; - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject json) - { - try { status = (int)json["status"]; } catch { } - try { version = (int)json["version"]; } catch { } - try { resourceUrl = (string)json["resourceUrl"]; } catch { } - try { name = (string)json["name"]; } catch { } - try { iconUrl = (string)json["icon"]; } catch { } - try { frameType = (int)json["frameType"]; } catch { } - try { frameId = (string)json["frameId"]; } catch { } - } - } - } - - + public string json { get; } // NEEDS TO BE ADDED AFTER + [JsonPropertyName("globalVotesCount")]public int GlobalVotesCount { get; set; } = 0; + [JsonPropertyName("globalVotedValue")]public int GlobalVotedValue { get; set; } = 0; + [JsonPropertyName("votedValue")]public int VotedValue { get; set; } = 0; + [JsonPropertyName("keywords")]public string Keywords { get; set; } + [JsonPropertyName("strategyInfo")]public string StrategyInfo { get; set; } + [JsonPropertyName("style")]public int Style { get; set; } = 0; + [JsonPropertyName("totalQuizPlayCount")]public int TotalQuizPlayCount { get; set; } = 0; + [JsonPropertyName("title")]public string Title { get; set; } + [JsonPropertyName("contentRating")]public int ContentRating { get; set; } = 0; + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("needHidden")]public bool NeedHidden { get; set; } = false; + [JsonPropertyName("guestVotesCount")]public int GuestVotesCount { get; set; } = 0; + [JsonPropertyName("type")]public int Type { get; set; } = 0; + [JsonPropertyName("status")]public int Status { get; set; } = 0; + [JsonPropertyName("globalCommentsCount")]public int GlobalCommentsCount { get; set; } = 0; + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("totalPollVoteCount")]public int TotalPollVoteCount { get; set; } = 0; + [JsonPropertyName("blogId")]public string BlogId { get; set; } + [JsonPropertyName("viewCount")]public int ViewCount { get; set; } = 0; + [JsonPropertyName("votesCount")]public int VotesCount { get; set; } = 0; + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } = 0; + [JsonPropertyName("endTime")]public string EndTime { get; set; } + [JsonPropertyName("commentsCount")]public int commentsCount { get; set; } = 0; + [JsonPropertyName("author")]public GenericProfile Author { get; } } } diff --git a/Amino.NET/Objects/GenericAvatarFrame.cs b/Amino.NET/Objects/GenericAvatarFrame.cs new file mode 100644 index 0000000..9914564 --- /dev/null +++ b/Amino.NET/Objects/GenericAvatarFrame.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class GenericAvatarFrame + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("version")] public int Version { get; set; } + [JsonPropertyName("resourceUrl")] public string ResourceUrl { get; set; } + [JsonPropertyName("name")] public string Name { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + [JsonPropertyName("frameType")] public int FrameType { get; set; } + [JsonPropertyName("frameId")] public string FrameId { get; set; } + } +} diff --git a/Amino.NET/Objects/communityProfile.cs b/Amino.NET/Objects/GenericProfile.cs similarity index 90% rename from Amino.NET/Objects/communityProfile.cs rename to Amino.NET/Objects/GenericProfile.cs index f2dc854..44465b1 100644 --- a/Amino.NET/Objects/communityProfile.cs +++ b/Amino.NET/Objects/GenericProfile.cs @@ -1,10 +1,11 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class CommunityProfile + public class GenericProfile { public int status { get; private set; } public bool isNicknameVerified { get; private set; } @@ -21,8 +22,9 @@ public class CommunityProfile public string iconUrl { get; private set; } public int communityId { get; private set; } public string json { get; private set; } + [JsonPropertyName("avatarFrame")] public GenericAvatarFrame AvatarFrame { get; set; } - public CommunityProfile(JObject _json) + public GenericProfile(JObject _json) { dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); From 30255ae5144c4b54dca5eb926d8bec929bb7af69 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sat, 18 May 2024 21:41:34 +0200 Subject: [PATCH 04/19] refactored Chat [ # ] Chat is now adapted to work with the default JSON class [ + ] Added ChatExtensions [ + ] Added GenericChatMember [ + ] Added LastChatMessageSummary --- Amino.NET/Objects/Chat.cs | 202 +++----------------- Amino.NET/Objects/ChatExtensions.cs | 16 ++ Amino.NET/Objects/GenericChatMember.cs | 19 ++ Amino.NET/Objects/LastChatMessageSummary.cs | 21 ++ 4 files changed, 84 insertions(+), 174 deletions(-) create mode 100644 Amino.NET/Objects/ChatExtensions.cs create mode 100644 Amino.NET/Objects/GenericChatMember.cs create mode 100644 Amino.NET/Objects/LastChatMessageSummary.cs diff --git a/Amino.NET/Objects/Chat.cs b/Amino.NET/Objects/Chat.cs index a1c2100..101b5ef 100644 --- a/Amino.NET/Objects/Chat.cs +++ b/Amino.NET/Objects/Chat.cs @@ -1,184 +1,38 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class Chat { - public string userId { get; private set; } - public int membersQuota { get; private set; } - public string threadId { get; private set; } - public string keywords { get; private set; } - public int membersCount { get; private set; } - public string strategyInfo { get; private set; } - public bool isPinned { get; private set; } - public string title { get; private set; } - public int membershipStatus { get; private set; } - public string content { get; private set; } - public bool needHidden { get; private set; } - public int alertOption { get; private set; } - public string lastReadTime { get; private set; } - public int type { get; private set; } - public int status { get; private set; } - public bool mentionMe { get; private set; } - public string modifiedTime { get; private set; } - public int condition { get; private set; } - public string iconUrl { get; private set; } - public string latestActivityTime { get; private set; } - public int communityId { get; private set; } - public string createdTime { get; private set; } - public string json { get; private set; } - public List<_member> MemberSummary { get; } = new List<_member>(); - public _author Author { get; } - public _extensions Extensions { get; } - - public Chat(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - json = _json.ToString(); - - userId = (string)jsonObj["uid"]; - membersQuota = (int)jsonObj["membersQuota"]; - threadId = (string)jsonObj["threadId"]; - keywords = (string)jsonObj["keywords"]; - membersCount = (int)jsonObj["membersCount"]; - strategyInfo = (string)jsonObj["strategyInfo"]; - isPinned = (bool)jsonObj["isPinned"]; - title = (string)jsonObj["title"]; - membershipStatus = (int)jsonObj["membershipStatus"]; - content = (string)jsonObj["content"]; - needHidden = (bool)jsonObj["needHidden"]; - alertOption = (int)jsonObj["alertOption"]; - lastReadTime = (string)jsonObj["lastReadTime"]; - type = (int)jsonObj["type"]; - status = (int)jsonObj["status"]; - modifiedTime = (string)jsonObj["modifiedTime"]; - condition = (int)jsonObj["condition"]; - iconUrl = (string)jsonObj["icon"]; - communityId = (int)jsonObj["ndcId"]; - createdTime = (string)jsonObj["createdTime"]; - JArray _memberList = jsonObj["membersSummary"]; - - foreach (JObject _member in _memberList) - { - _member member = new _member(_member); - - MemberSummary.Add(member); - } - - Author = new _author(_json); - Extensions = new _extensions(_json); - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _member - { - public int status { get; private set; } - public string userId { get; private set; } - public int membershipStatus { get; private set; } - public int role { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - - public _member(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["status"]; - userId = (string)jsonObj["uid"]; - membershipStatus = (int)jsonObj["membershipStatus"]; - role = (int)jsonObj["role"]; - nickname = (string)jsonObj["nickname"]; - iconUrl = (string)jsonObj["icon"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _lastMessageSummary - { - public string userId { get; private set; } - public bool isHidden { get; private set; } - public string mediaType { get; private set; } - public string content { get; private set; } - public string messageId { get; private set; } - public string createdTime { get; private set; } - public int type { get; private set; } - public string mediaValue { get; private set; } - - public _lastMessageSummary(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["lastMessageSummary"]["uid"]; - isHidden = (bool)jsonObj["lastMessageSummary"]["isHidden"]; - mediaType = (string)jsonObj["lastMessageSummary"]["mediaType"]; - content = (string)jsonObj["lastMessageSummary"]["content"]; - messageId = (string)jsonObj["lastMessageSummary"]["messageId"]; - createdTime = (string)jsonObj["lastMessageSummary"]["createdTime"]; - type = (int)jsonObj["lastMessageSummary"]["type"]; - mediaType = (string)jsonObj["lastMessageSummary"]["mediaType"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _author - { - public int status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int membershipStatus { get; private set; } - public int reputation { get; private set; } - public int role { get; private set; } - public string aminoId { get; private set; } - public int communityId { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - - public _author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["author"]["status"]; - isNicknameVerified = (bool)jsonObj["author"]["isNicknameVerified"]; - userId = (string)jsonObj["author"]["uid"]; - level = (int)jsonObj["author"]["level"]; - followingStatus = (int)jsonObj["author"]["followingStatus"]; - accountMembershipStatus = (int)jsonObj["author"]["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["author"]["isGlobal"]; - membershipStatus = (int)jsonObj["author"]["membershipStatus"]; - reputation = (int)jsonObj["author"]["reputation"]; - role = (int)jsonObj["author"]["role"]; - communityId = (int)jsonObj["author"]["ndcId"]; - membersCount = (int)jsonObj["author"]["membersCount"]; - nickname = (string)jsonObj["author"]["nickname"]; - iconUrl = (string)jsonObj["author"]["icon"]; - - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _extensions - { - public bool viewOnly { get; private set; } - public int lastMembersSummaryUpdateTime { get; private set; } - public string channelType { get; private set; } - - public _extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - - if (jsonObj["extensions"]["viewOnly"] != null) { viewOnly = (bool)jsonObj["extensions"]["viewOnly"]; } - lastMembersSummaryUpdateTime = (int)jsonObj["extensions"]["lastMembersSummaryUpdateTime"]; - if (jsonObj["extensions"]["channelType"] != null) { channelType = (string)jsonObj["extensions"]["channelType"]; } - } - - } + public string json { get; private set; } // NEEDS TO BE ADDED LATER + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("membersQuota")]public int MembersQuota { get; set; } + [JsonPropertyName("threadId")]public string ThreadId { get; set; } + [JsonPropertyName("keywords")]public string Keywords { get; set; } + [JsonPropertyName("membersCount")]public int MemberCount { get; set; } + [JsonPropertyName("strategyInfo")]public string StrategyInfo { get; set; } + [JsonPropertyName("isPinned")]public bool IsPinned { get; set; } + [JsonPropertyName("title")]public string Title { get; set; } + [JsonPropertyName("membershipStatus")]public int MembershipStatus { get; set; } + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("needHidden")]public bool NeedHidden { get; set; } + [JsonPropertyName("alrtOption")]public int alertOption { get; set; } + [JsonPropertyName("lastReadTime")]public string LastReadTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("mentionMe")]public bool MentionMe { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("condition")]public int Condition { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } + [JsonPropertyName("latestActivityTime")]public string LatestActivityTime { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } + [JsonPropertyName("membersSummary")] public List ChatMemberSummary { get; set; } + [JsonPropertyName("lastMessageSummary")] public LastChatMessageSummary LastMessageSummary { get; set; } + [JsonPropertyName("extensions")] public ChatExtensions Extensions { get; set; } } } diff --git a/Amino.NET/Objects/ChatExtensions.cs b/Amino.NET/Objects/ChatExtensions.cs new file mode 100644 index 0000000..1c1d1d4 --- /dev/null +++ b/Amino.NET/Objects/ChatExtensions.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class ChatExtensions + { + [JsonPropertyName("viewOnly")] public bool ViewOnly { get; set; } + [JsonPropertyName("lastMembersSummaryUpdatedTime")] public string LastMemberSummaryUpdatedTime { get; set; } + [JsonPropertyName("channelType")] public string ChannelType { get; set; } + } +} diff --git a/Amino.NET/Objects/GenericChatMember.cs b/Amino.NET/Objects/GenericChatMember.cs new file mode 100644 index 0000000..8c62be5 --- /dev/null +++ b/Amino.NET/Objects/GenericChatMember.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class GenericChatMember + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("uid")] public string UserId { get; set; } + [JsonPropertyName("membershipStatus")] public int MembershipStatus { get; set; } + [JsonPropertyName("role")] public int Role { get; set; } + [JsonPropertyName("nickname")] public string Nickname { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + } +} diff --git a/Amino.NET/Objects/LastChatMessageSummary.cs b/Amino.NET/Objects/LastChatMessageSummary.cs new file mode 100644 index 0000000..c52c34f --- /dev/null +++ b/Amino.NET/Objects/LastChatMessageSummary.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class LastChatMessageSummary + { + [JsonPropertyName("uid")] public string UserId { get; set; } + [JsonPropertyName("isHidden")] public bool IsHidden { get; set; } + [JsonPropertyName("mediaType")] public string MediaType { get; set; } + [JsonPropertyName("content")] public string Content { get; set; } + [JsonPropertyName("messageId")] public string MessageId { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("type")] public int Type { get; set; } + [JsonPropertyName("mediaValue")] public string MediaValue { get; set; } + } +} From 34c915cb11786f7d1e2a49b33ca200bf78ca91f1 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 19 May 2024 00:56:16 +0200 Subject: [PATCH 05/19] refactored ChatAnnouncement [ # ] Prepared EventHandler to discontinue Newtonsoft.Json [ + ] Added SocketBase [ # ] Adapted ChatAnnouncement --- Amino.NET/Events/EventHandler.cs | 5 +++ Amino.NET/Objects/ChatAnnouncement.cs | 53 +++++++-------------------- Amino.NET/Objects/SocketBase.cs | 16 ++++++++ 3 files changed, 35 insertions(+), 39 deletions(-) create mode 100644 Amino.NET/Objects/SocketBase.cs diff --git a/Amino.NET/Events/EventHandler.cs b/Amino.NET/Events/EventHandler.cs index e0d2e6d..68d990c 100644 --- a/Amino.NET/Events/EventHandler.cs +++ b/Amino.NET/Events/EventHandler.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json; using System.Threading.Tasks; +using Amino.Objects; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -25,9 +27,12 @@ public Task ReceiveEvent(JObject webSocketMessage, Client client) eventCall.callWebSocketMessageEvent(client, webSocketMessage); try { + JsonElement root = JsonDocument.Parse(webSocketMessage.ToString()).RootElement; + SocketBase sBase = JsonSerializer.Deserialize(root.GetProperty("o")); dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(webSocketMessage.ToString()); if(jsonObj["o"]["chatMessage"]["mediaType"] != null) { + switch((int)jsonObj["o"]["chatMessage"]["mediaType"]) { case 0: //TextMessage / MessageDeleted / ChatMember Left, ChatMember Joined / ChatBackground changed / ChatTitle changed / ChatContent chaaged / ChatAnnouncementPin / ChatAnnouncementUnpin / ChatViewOnlyOn / ChatViewOnlyOff / ChatTipEnabled / ChatTipDisabled / MessageForceRemoved / ChatTip diff --git a/Amino.NET/Objects/ChatAnnouncement.cs b/Amino.NET/Objects/ChatAnnouncement.cs index eb0e02b..e75aebe 100644 --- a/Amino.NET/Objects/ChatAnnouncement.cs +++ b/Amino.NET/Objects/ChatAnnouncement.cs @@ -1,49 +1,24 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class ChatAnnouncement { - public int _type { get; } - public int communityId { get; } - public int alertOption { get; } - public int membershipStatus { get; } - - public string chatId { get; } - public int mediaType { get; } - public string content { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - - public ChatAnnouncement(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - communityId = (int)jsonObj["o"]["ndcId"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - content = (string)jsonObj["o"]["chatMessage"]["content"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - } + public string json { get; set; } // NEEDS TO BE SET AFTER + public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } } } diff --git a/Amino.NET/Objects/SocketBase.cs b/Amino.NET/Objects/SocketBase.cs new file mode 100644 index 0000000..8ae3fd8 --- /dev/null +++ b/Amino.NET/Objects/SocketBase.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class SocketBase + { + [JsonPropertyName("alertOption")] public int AlertOption { get; set; } + [JsonPropertyName("membershipStatus")] public int MembershipStatus { get; set; } + [JsonPropertyName("ndcId")] public int CommunityId { get; set; } + } +} From fc1c73cef1c3fc4f4fcc5686e39c5b46dc750d4a Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 19 May 2024 01:07:06 +0200 Subject: [PATCH 06/19] efactored ChatEvent & ChatMember --- Amino.NET/Events/EventHandler.cs | 2 +- Amino.NET/Objects/ChatEvent.cs | 48 +++++++--------------- Amino.NET/Objects/chatMember.cs | 69 ++++++-------------------------- 3 files changed, 28 insertions(+), 91 deletions(-) diff --git a/Amino.NET/Events/EventHandler.cs b/Amino.NET/Events/EventHandler.cs index 68d990c..c5c3d99 100644 --- a/Amino.NET/Events/EventHandler.cs +++ b/Amino.NET/Events/EventHandler.cs @@ -28,7 +28,7 @@ public Task ReceiveEvent(JObject webSocketMessage, Client client) try { JsonElement root = JsonDocument.Parse(webSocketMessage.ToString()).RootElement; - SocketBase sBase = JsonSerializer.Deserialize(root.GetProperty("o")); + SocketBase sBase = System.Text.Json.JsonSerializer.Deserialize(root.GetProperty("o")); dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(webSocketMessage.ToString()); if(jsonObj["o"]["chatMessage"]["mediaType"] != null) { diff --git a/Amino.NET/Objects/ChatEvent.cs b/Amino.NET/Objects/ChatEvent.cs index 9382200..1eea757 100644 --- a/Amino.NET/Objects/ChatEvent.cs +++ b/Amino.NET/Objects/ChatEvent.cs @@ -1,45 +1,25 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class ChatEvent { - public int _type { get; } - public int alertOption { get; } - public int membershipStatus { get; } - public int communityId { get; } + public string json { get; set; } // NEEDS TO BE SET AFTER + public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER - public string chatId { get; } - public int mediaType { get; } - public int clientrefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - - public ChatEvent(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - communityId = (int)jsonObj["o"]["ndcId"]; - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientrefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clienttRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + } } diff --git a/Amino.NET/Objects/chatMember.cs b/Amino.NET/Objects/chatMember.cs index a426d23..620d1bb 100644 --- a/Amino.NET/Objects/chatMember.cs +++ b/Amino.NET/Objects/chatMember.cs @@ -4,68 +4,25 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class ChatMember { - public int status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int accountMembershipStatus { get; private set; } - public int membershipStatus { get; private set; } - public int reputation { get; private set; } - public int role { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - public string json { get; private set; } - public _AvatarFrame AvatarFrame { get; } + public string json { get; set; } // NEEDS TO BE ADDED AFTER + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("isNicknameVerified")]public bool IsNicknameVerified { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("level")]public int Level { get; set; } + [JsonPropertyName("accountMembershipStatus")]public int AccountMembershipStatus { get; set; } + [JsonPropertyName("membershipStatus")]public int MembershipStatus { get; set; } + [JsonPropertyName("reputation")]public int Reputation { get; set; } + [JsonPropertyName("role")]public int Role { get; set; } + [JsonPropertyName("nickname")]public string Nickname { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } - public ChatMember(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["status"]; - isNicknameVerified = (bool)jsonObj["isNicknameVerified"]; - userId = (string)jsonObj["uid"]; - level = (int)jsonObj["level"]; - accountMembershipStatus = (int)jsonObj["accountMembershipStatus"]; - membershipStatus = (int)jsonObj["membershipStatus"]; - reputation = (int)jsonObj["reputation"]; - role = (int)jsonObj["role"]; - nickname = (string)jsonObj["nickname"]; - iconUrl = (string)jsonObj["icon"]; - json = _json.ToString(); - if (jsonObj["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; private set; } - public int ownershipStatus { get; private set; } - public int verion { get; private set; } - public string resourceUrl { get; private set; } - public string name { get; private set; } - public string iconUrl { get; private set; } - public int frameType { get; private set; } - public string frameId { get; private set; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["avatarFrame"]["status"]; - ownershipStatus = (int)jsonObj["avatarFrame"]["ownershipStatus"]; - verion = (int)jsonObj["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["avatarFrame"]["icon"]; - frameType = (int)jsonObj["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["avatarFrame"]["frameId"]; - } - } + [JsonPropertyName("avatarFrame")]public GenericAvatarFrame AvatarFrame { get; set; } } } From 367f413265f81e80a4e2fa6236aee0101cbd3ede Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 19 May 2024 01:22:20 +0200 Subject: [PATCH 07/19] refactored ChatTip & ChatTipToggle --- Amino.NET/Objects/ChatTip.cs | 141 +++---------------------- Amino.NET/Objects/ChatTipExtensions.cs | 14 +++ Amino.NET/Objects/ChatTipToggle.cs | 127 +++------------------- Amino.NET/Objects/GenericProfile.cs | 2 + 4 files changed, 49 insertions(+), 235 deletions(-) create mode 100644 Amino.NET/Objects/ChatTipExtensions.cs diff --git a/Amino.NET/Objects/ChatTip.cs b/Amino.NET/Objects/ChatTip.cs index 8270103..000b341 100644 --- a/Amino.NET/Objects/ChatTip.cs +++ b/Amino.NET/Objects/ChatTip.cs @@ -1,134 +1,27 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class ChatTip { - public int _type { get; } - public int alertOption { get; } - public int membershipStatus { get; } - public int communityId { get; } + public string json { get; set; } // NEEDS TO BE SET AFTER + public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER + + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + + [JsonPropertyName("author")]public GenericProfile Author { get; set; } + [JsonPropertyName("extensions")]public ChatTipExtensions Extensions { get; set; } - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - public _Author Author { get; } - public _Extensions Extensions { get; } - - - public ChatTip(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - communityId = (int)jsonObj["o"]["ndcId"]; - - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - Author = new _Author(_json); - Extensions = new _Extensions(_json); - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public string avatarFrameId { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; - status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; - if(jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } - reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; - role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; - nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; - level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; - accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; - avatarFrameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrameId"]; - if(jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if(jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Extensions - { - public int tippedCoins { get; } - - public _Extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - tippedCoins = (int)jsonObj["o"]["chatMessage"]["extensions"]["tippingCoins"]; - } - } } } diff --git a/Amino.NET/Objects/ChatTipExtensions.cs b/Amino.NET/Objects/ChatTipExtensions.cs new file mode 100644 index 0000000..2354830 --- /dev/null +++ b/Amino.NET/Objects/ChatTipExtensions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class ChatTipExtensions + { + [JsonPropertyName("tippingCoins")] public int TippedCoins { get; set; } + } +} diff --git a/Amino.NET/Objects/ChatTipToggle.cs b/Amino.NET/Objects/ChatTipToggle.cs index 3d843b6..41e63e2 100644 --- a/Amino.NET/Objects/ChatTipToggle.cs +++ b/Amino.NET/Objects/ChatTipToggle.cs @@ -1,121 +1,26 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class ChatTipToggle { - public int _type { get; } - public int communityId { get; } - public int alertOption { get; } - public int membershipStatus { get; } - - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - public _Author Author { get; } - - public ChatTipToggle(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - communityId = (int)jsonObj["o"]["ndcId"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - Author = new _Author(_json); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; - status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; - if (jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } - reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; - role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; - nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; - level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; - accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; - if (jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if (jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - - - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - } + public string json { get; set; } // NEEDS TO BE ADDED AFTER + public SocketBase SocketBase { get; set; } // NEEDS TO BE ADDED AFTER + + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/GenericProfile.cs b/Amino.NET/Objects/GenericProfile.cs index 44465b1..5229c27 100644 --- a/Amino.NET/Objects/GenericProfile.cs +++ b/Amino.NET/Objects/GenericProfile.cs @@ -23,6 +23,8 @@ public class GenericProfile public int communityId { get; private set; } public string json { get; private set; } [JsonPropertyName("avatarFrame")] public GenericAvatarFrame AvatarFrame { get; set; } + [JsonPropertyName("influencerInfo")] public InfluencerPriceInfo InfluencerInfo { get; set; } + public GenericProfile(JObject _json) { From 52c6bd3da3e082d3d335725a9ad5d2fbe8d4503b Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 19 May 2024 02:01:59 +0200 Subject: [PATCH 08/19] refactored CoinHistoryEntry, Comment, Community, CommunityInfo, DeletedMessage, EventLog --- Amino.NET/Objects/CoinHistoryEntry.cs | 74 +++-------- Amino.NET/Objects/Comment.cs | 88 +++---------- Amino.NET/Objects/Community.cs | 93 ++++---------- Amino.NET/Objects/CommunityInfo.cs | 119 +----------------- Amino.NET/Objects/DeletedMessage.cs | 124 +++---------------- Amino.NET/Objects/ParticipatedExperiments.cs | 18 +++ Amino.NET/Objects/WalletHistoryExtraData.cs | 17 +++ Amino.NET/Objects/eventLog.cs | 67 +++------- 8 files changed, 121 insertions(+), 479 deletions(-) create mode 100644 Amino.NET/Objects/ParticipatedExperiments.cs create mode 100644 Amino.NET/Objects/WalletHistoryExtraData.cs diff --git a/Amino.NET/Objects/CoinHistoryEntry.cs b/Amino.NET/Objects/CoinHistoryEntry.cs index 6a43be3..88787d1 100644 --- a/Amino.NET/Objects/CoinHistoryEntry.cs +++ b/Amino.NET/Objects/CoinHistoryEntry.cs @@ -1,68 +1,26 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class CoinHistoryEntry { - public bool isPositive { get; } - public int totalCoins { get; } - public float originCoinsFloat { get; } - public int sourceType { get; } - public string createdTime { get; } - public int bonusCoins { get; } - public float totalCoinsFloat { get; } - public float bonusCoinsFloat { get; } - public float changedCoinsFloat { get; } - public float taxCoinsFloat { get; } - public int taxCoins { get; } - public string userId { get; } - public int changedCoins { get; } - public int originCoins { get; } - public string json { get; } - public _ExtData ExtData { get; } - - public CoinHistoryEntry(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - isPositive = (bool)jsonObj["isPositive"]; - totalCoins = (int)jsonObj["totalCoins"]; - originCoinsFloat = (int)jsonObj["originCoinsFloat"]; - sourceType = (int)jsonObj["sourceType"]; - createdTime = (string)jsonObj["createdTime"]; - if(jsonObj["bonusCoins"] != null) { bonusCoins = (int)jsonObj["bonusCoins"]; } - totalCoinsFloat = (float)jsonObj["totalCoinsFloat"]; - if(jsonObj["bonusCoinsFloat"] != null) { bonusCoinsFloat = (float)jsonObj["bonusCoinsFloat"]; } - changedCoinsFloat = (int)jsonObj["changedCoinsFloat"]; - if(jsonObj["taxCoinsFloat"] != null) { taxCoinsFloat = (float)jsonObj["taxCoinsFloat"]; } - if(jsonObj["taxCoins"] != null) { taxCoins = (int)jsonObj["taxCoins"]; } - userId = (string)jsonObj["uid"]; - changedCoins = (int)jsonObj["changedCoins"]; - originCoins = (int)jsonObj["originCoins"]; - json = _json.ToString(); - ExtData = new _ExtData(_json); - - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _ExtData - { - public string objectDeeplinkUrl { get; } - public string description { get; } - public string iconUrl { get; } - public string subtitle { get; } - - public _ExtData(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - objectDeeplinkUrl = (string)jsonObj["extData"]["objectDeeplinkUrl"]; - description = (string)jsonObj["extData"]["description"]; - if(jsonObj["extData"]["icon"] != null) { iconUrl = (string)jsonObj["extData"]["icon"]; } - subtitle = (string)jsonObj["extData"]["subtitle"]; - } - } + [JsonPropertyName("isPositive")]public bool IsPositive { get; set; } + [JsonPropertyName("totalCoins")]public int TotalCoins { get; set; } + [JsonPropertyName("originalCoinsFloat")]public float OriginCoinsFloat { get; set; } + [JsonPropertyName("sourceType")]public int SourceType { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("bonusCoins")]public int BonusCoins { get; set; } + [JsonPropertyName("totalCoinsFloat")]public float TotalCoinsFloat { get; set; } + [JsonPropertyName("bonusCoinsFloat")]public float BonusCoinsFloat { get; set; } + [JsonPropertyName("changedCoinsFloat")]public float ChangedCoinsFloat { get; set; } + [JsonPropertyName("taxCoinsFloat")]public float TaxCoinsFloat { get; set; } + [JsonPropertyName("taxCoins")]public int TaxCoins { get; set; } + [JsonPropertyName("uid")]public string EntryId { get; set; } + [JsonPropertyName("changedCoins")]public int ChangedCoins { get; set; } + [JsonPropertyName("originCoins")]public int OriginCoins { get; set; } + [JsonPropertyName("extData")]public WalletHistoryExtraData ExtData { get; set; } } } diff --git a/Amino.NET/Objects/Comment.cs b/Amino.NET/Objects/Comment.cs index 6b15563..567b5aa 100644 --- a/Amino.NET/Objects/Comment.cs +++ b/Amino.NET/Objects/Comment.cs @@ -1,85 +1,25 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class Comment { - public string modifiedTime { get; private set; } - public int communityId { get; private set; } - public int votedValue { get; private set; } - public int parentType { get; private set; } - public string commentId { get; private set; } - public int parentCommunityId { get; private set; } - public int votesSum { get; private set; } - public string content { get; private set; } - public string parentId { get; private set; } - public string createdTime { get; private set; } - public int subcommentsCount { get; private set; } - public int type { get; private set; } - public string json { get; private set; } - public _Author Author { get; private set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("votedValue")]public int VotedValue { get; set; } + [JsonPropertyName("parentType")]public int ParentType { get; set; } + [JsonPropertyName("commentId")]public string CommentId { get; set; } + [JsonPropertyName("parentNdcId")]public int ParentCommunityId { get; set; } + [JsonPropertyName("votesSum")]public int VotesSum { get; set; } + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("parentId")]public string ParentId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("subcommentsCount")]public int SubcommentsCount { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + public GenericProfile Author { get; private set; } - public Comment(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - modifiedTime = (string)jsonObj["modifiedTime"]; - communityId = (int)jsonObj["ndcId"]; - votedValue = (int)jsonObj["votedValue"]; - parentType = (int)jsonObj["parentType"]; - commentId = (string)jsonObj["commentId"]; - parentCommunityId = (int)jsonObj["parentNdcId"]; - votesSum = (int)jsonObj["votesSum"]; - content = (string)jsonObj["content"]; - parentId = (string)jsonObj["parentId"]; - createdTime = (string)jsonObj["createdTime"]; - subcommentsCount = (int)jsonObj["subcommentsCount"]; - type = (int)jsonObj["type"]; - json = _json.ToString(); - Author = new _Author(_json); - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public int status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public int reputation { get; private set; } - public bool isGlobal { get; private set; } - public int membershipStatus { get; private set; } - public int role { get; private set; } - public string aminoId { get; private set; } - public int communityId { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["author"]["status"]; - isNicknameVerified = (bool)jsonObj["author"]["isNicknameVerified"]; - userId = (string)jsonObj["author"]["uid"]; - level = (int)jsonObj["author"]["level"]; - followingStatus = (int)jsonObj["author"]["followingStatus"]; - accountMembershipStatus = (int)jsonObj["author"]["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["author"]["isGlobal"]; - membershipStatus = (int)jsonObj["author"]["membershipStatus"]; - reputation = (int)jsonObj["author"]["reputation"]; - role = (int)jsonObj["author"]["role"]; - aminoId = (string)jsonObj["author"]["aminoId"]; - communityId = (int)jsonObj["author"]["ndcId"]; - membersCount = (int)jsonObj["author"]["membersCount"]; - nickname = (string)jsonObj["author"]["nickname"]; - iconUrl = (string)jsonObj["author"]["icon"]; - } - } } } diff --git a/Amino.NET/Objects/Community.cs b/Amino.NET/Objects/Community.cs index 5c7d9ed..649efeb 100644 --- a/Amino.NET/Objects/Community.cs +++ b/Amino.NET/Objects/Community.cs @@ -1,81 +1,32 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class Community { - public int? listedStatus { get; private set; } - public int? probationStatus { get; private set; } - public int? membersCount { get; private set; } - public string primaryLanguage { get; private set; } - public float? communityHeat { get; private set; } - public string strategyInfo { get; private set; } - public string tagline { get; private set; } - public int? joinType { get; private set; } - public int? status { get; private set; } - public string modifiedTime { get; private set; } - public int? communityId { get; private set; } - public string communityLink { get; private set; } - public string iconUrl { get; private set; } - public string updatedTime { get; private set; } - public string endpoint { get; private set; } - public string communityName { get; private set; } - public int? templateId { get; private set; } - public string createdTime { get; private set; } - public string json { get; private set; } - public _Agent Agent { get; private set; } - - - public Community(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { listedStatus = (int)jsonObj["listedStatus"]; } catch { } - try { probationStatus = (int)jsonObj["probationStatus"]; }catch{ } - try { membersCount = (int)jsonObj["membersCount"]; } catch { } - try { joinType = (int)jsonObj["joinType"]; } catch { } - try { status = (int)jsonObj["status"]; } catch { } - try { communityId = (int)jsonObj["ndcId"]; } catch { } - try { communityHeat = (float)jsonObj["communityHeat"]; } catch { } - try { primaryLanguage = (string)jsonObj["primaryLanguage"]; } catch { } - try { strategyInfo = (string)jsonObj["strategyInfo"]; } catch { } - try { tagline = (string)jsonObj["tagline"]; } catch { } - try { modifiedTime = (string)jsonObj["modifiedTime"]; } catch { } - try { communityLink = (string)jsonObj["link"]; } catch { } - try { iconUrl = (string)jsonObj["icon"]; } catch { } - try { updatedTime = (string)jsonObj["updatedTime"]; } catch { } - try { endpoint = (string)jsonObj["endpoint"]; } catch { } - try { communityName = (string)jsonObj["name"]; } catch { } - try { createdTime = (string)jsonObj["createdTime"]; } catch { } - json = _json.ToString(); - Agent = new _Agent(_json); - } - - public class _Agent - { - public bool isNickNameVerified { get; private set; } - public string userId { get; private set; } - public int? level { get; private set; } - public int? followingStatus { get; private set; } - public int? membershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int? reputation { get; private set; } - public int? membersCount { get; private set; } - - public _Agent(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { isNickNameVerified = (bool)jsonObj["agent"]["isNicknameVerified"]; } catch { } - try { userId = (string)jsonObj["agent"]["uid"]; } catch { } - try { level = (int)jsonObj["agent"]["level"]; } catch { } - try { followingStatus = (int)jsonObj["agent"]["followingStatus"]; } catch { } - try { membershipStatus = (int)jsonObj["agent"]["membershipStatus"]; } catch { } - try { isGlobal = (bool)jsonObj["agent"]["isGlobal"]; } catch { } - try { reputation = (int)jsonObj["agent"]["reputation"]; } catch { } - try { membersCount = (int)jsonObj["agent"]["membersCount"]; } catch { } - } - } + [JsonPropertyName("listedStatus")] public int ListedStatus { get; set; } + [JsonPropertyName("probationStatus")] public int ProbationStatus { get; set; } + [JsonPropertyName("membersCount")] public int MemberCount { get; set; } + [JsonPropertyName("primaryLanguage")] public string PrimaryLanguage { get; set; } + [JsonPropertyName("communityHeat")] public float CommunityHeat { get; set; } + [JsonPropertyName("strategyInfo")] public string StrategyInfo { get; set; } + [JsonPropertyName("tagLine")] public string Tagline { get; set; } + [JsonPropertyName("joinType")]public int JoinType { get; set; } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("link")]public string CommunityLink { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } + [JsonPropertyName("updatedTime")]public string UpdatedTime { get; set; } + [JsonPropertyName("endpoint")]public string Endpoint { get; set; } + [JsonPropertyName("name")]public string CommunityName { get; set; } + [JsonPropertyName("templateId")]public int templateId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("userAddedTopicList")] public string UserAddedTopicList { get; set; } + [JsonPropertyName("agent")]public GenericProfile Agent { get; set; } + [JsonPropertyName("themePack")] public CommunityThemePack ThemePack { get; set; } } } diff --git a/Amino.NET/Objects/CommunityInfo.cs b/Amino.NET/Objects/CommunityInfo.cs index e0c6391..8fdb4b2 100644 --- a/Amino.NET/Objects/CommunityInfo.cs +++ b/Amino.NET/Objects/CommunityInfo.cs @@ -1,123 +1,16 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class CommunityInfo { - public int objectType { get; private set; } - public string aminoId { get; private set; } - public string objectId { get; private set; } - public int communityId { get; private set; } - public string userAddedTopicList { get; private set; } - public int listedStatus { get; private set; } - public int probationStatus { get; private set; } - public int membersCount { get; private set; } - public string primaryLanguage { get; private set; } - public float communityHeat { get; private set; } - public string strategyInfo { get; private set; } - public string tagline { get; private set; } - public int joinType { get; private set; } - public int status { get; private set; } - public string modifiedTime { get; private set; } - public string communityLink { get; private set; } - public string iconUrl { get; private set; } - public string updatedTime { get; private set; } - public string endpoint { get; private set; } - public string name { get; private set; } - public int templateId { get; private set; } - public string createdTime { get; private set; } - public string json { get; private set; } - public _Agent Agent { get; } - public _ThemePack ThemePack { get; } - - public CommunityInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - objectType = (int)jsonObj["objectType"]; - aminoId = (string)jsonObj["aminoId"]; - objectId = (string)jsonObj["objectId"]; - communityId = (int)jsonObj["ndcId"]; - userAddedTopicList = (string)jsonObj["refObject"]["userAddedTopicList"]; - listedStatus = (int)jsonObj["refObject"]["listedStatus"]; - probationStatus = (int)jsonObj["refObject"]["probationStatus"]; - membersCount = (int)jsonObj["refObject"]["membersCount"]; - primaryLanguage = (string)jsonObj["refObject"]["primaryLanguage"]; - communityHeat = (float)jsonObj["refObject"]["communityHeat"]; - strategyInfo = (string)jsonObj["refObject"]["strategyInfo"]; - tagline = (string)jsonObj["refObject"]["tagline"]; - joinType = (int)jsonObj["refObject"]["joinType"]; - status = (int)jsonObj["refObject"]["status"]; - modifiedTime = (string)jsonObj["refObject"]["modifiedTime"]; - communityLink = (string)jsonObj["refObject"]["link"]; - iconUrl = (string)jsonObj["refObject"]["icon"]; - updatedTime = (string)jsonObj["refObject"]["updatedTime"]; - endpoint = (string)jsonObj["refObject"]["endpoint"]; - name = (string)jsonObj["refObject"]["name"]; - templateId = (int)jsonObj["refObject"]["templateId"]; - createdTime = (string)jsonObj["refObject"]["createdTime"]; - json = _json.ToString(); - Agent = new _Agent(_json); - ThemePack = new _ThemePack(_json); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Agent - { - public string status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int membershipStatus { get; private set; } - public int reputation { get; private set; } - public int role { get; private set; } - public int communityId { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - - public _Agent(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (string)jsonObj["refObject"]["agent"]["status"]; - isNicknameVerified = (bool)jsonObj["refObject"]["agent"]["isNicknameVerified"]; - userId = (string)jsonObj["refObject"]["agent"]["uid"]; - level = (int)jsonObj["refObject"]["agent"]["level"]; - followingStatus = (int)jsonObj["refObject"]["agent"]["followingStatus"]; - accountMembershipStatus = (int)jsonObj["refObject"]["agent"]["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["refObject"]["agent"]["isGlobal"]; - membershipStatus = (int)jsonObj["refObject"]["agent"]["membershipStatus"]; - reputation = (int)jsonObj["refObject"]["agent"]["reputation"]; - if(jsonObj["refObject"]["agent"]["role"] != null) { role = (int)jsonObj["refObject"]["agent"]["role"]; } - if(jsonObj["refObject"]["agent"]["ndcId"] != null) { communityId = (int)jsonObj["refObject"]["agent"]["ndcId"]; } - membersCount = (int)jsonObj["refObject"]["agent"]["membersCount"]; - if(jsonObj["refObject"]["agent"]["nickname"] != null) { nickname = (string)jsonObj["refObject"]["agent"]["nickname"]; } - if(jsonObj["refObject"]["agent"]["icon"] != null) { iconUrl = (string)jsonObj["refObject"]["agent"]["icon"]; } - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _ThemePack - { - public string themeColor { get; private set; } - public string themePackHash { get; private set; } - public int themePackRevision { get; private set; } - public string themePackUrl { get; private set; } - - public _ThemePack(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - themeColor = (string)jsonObj["refObject"]["themePack"]["themeColor"]; - themePackHash = (string)jsonObj["refObject"]["themePack"]["themePackHash"]; - themePackRevision = (int)jsonObj["refObject"]["themePack"]["themePackRevision"]; - themePackUrl = (string)jsonObj["refObject"]["themePack"]["themePackUrl"]; - } - } + [JsonPropertyName("objectType")]public int ObjectType { get; set; } + [JsonPropertyName("aminoId")]public string AminoId { get; set; } + [JsonPropertyName("objectId")]public string ObjectId { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("refObject")]public Community CommunityBase { get; set; } } } diff --git a/Amino.NET/Objects/DeletedMessage.cs b/Amino.NET/Objects/DeletedMessage.cs index 729072a..2be1dfe 100644 --- a/Amino.NET/Objects/DeletedMessage.cs +++ b/Amino.NET/Objects/DeletedMessage.cs @@ -1,119 +1,23 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class DeletedMessage { - public int _type { get; } - public int alertOption { get; } - public int membershipStatus { get; } - public int communityId { get; } - - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - public _Author Author { get; } - - - public DeletedMessage(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - communityId = (int)jsonObj["o"]["ndcId"]; - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - Author = new _Author(_json); - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public string avatarFrameId { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; - status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; - if(jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } - reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; - role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; - nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; - level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; - accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; - avatarFrameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrameId"]; - if(jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if(jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["iconUrl"]; - frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - } + public SocketBase SocketBase { get; set; } // NEEDS TO BE ADDED AFTER + public string Json { get; set; } // NEEDS TO BE ADDED AFTER + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/ParticipatedExperiments.cs b/Amino.NET/Objects/ParticipatedExperiments.cs new file mode 100644 index 0000000..b1122d7 --- /dev/null +++ b/Amino.NET/Objects/ParticipatedExperiments.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class ParticipatedExperiments + { + [JsonPropertyName("chatMembersCommonChannel")] public int ChatMembersCommonChannel { get; set; } + [JsonPropertyName("couponPush")] public int CouponPush { get; set; } + [JsonPropertyName("communityMembersCommonChannel")] public int CommunityMembersCommonChannel { get; set; } + [JsonPropertyName("communityTabExp")] public int CommunityTabExp { get; set; } + [JsonPropertyName("userVectorCommunitySimilarityChannel")] public int UserVectorCommunitySimilarityChannel { get; set; } + } +} diff --git a/Amino.NET/Objects/WalletHistoryExtraData.cs b/Amino.NET/Objects/WalletHistoryExtraData.cs new file mode 100644 index 0000000..4c5eaeb --- /dev/null +++ b/Amino.NET/Objects/WalletHistoryExtraData.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class WalletHistoryExtraData + { + [JsonPropertyName("objectDeeplinkUrl")] public string ObjectDeeplinkUrl { get; set; } + [JsonPropertyName("description")] public string Description { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + [JsonPropertyName("subtitle")] public string Subtitle { get; set; } + } +} diff --git a/Amino.NET/Objects/eventLog.cs b/Amino.NET/Objects/eventLog.cs index 6d573d8..25ca901 100644 --- a/Amino.NET/Objects/eventLog.cs +++ b/Amino.NET/Objects/eventLog.cs @@ -1,63 +1,24 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class EventLog { - public string? globalStrategyInfo { get; private set; } - public string? userId { get; private set; } - public string? contentLanguage { get; private set; } - public int? signUpStrategy { get; private set; } - public int? landingOption { get; private set; } - public bool? needsBirthDateUpdate { get; private set; } - public int? interestPickerStyle { get; private set; } - public bool? showStoreBadge { get; private set; } - public string? amino_userId { get; private set; } - public bool? needTriggerInterestPicker { get; private set; } - public string? json { get; private set; } - public _ParticipatedExperiments ParticipatedExperiments { get; private set; } - - public EventLog(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - globalStrategyInfo = (string)jsonObj["globalStrategyInfo"]; - userId = (string)jsonObj["uid"]; - contentLanguage = (string)jsonObj["contentLanguage"]; - signUpStrategy = (int)jsonObj["signUpStrategy"]; - landingOption = (int)jsonObj["landingOption"]; - needsBirthDateUpdate = (bool)jsonObj["needsBirthDateUpdate"]; - interestPickerStyle = (int)jsonObj["interestPickerStyle"]; - showStoreBadge = (bool)jsonObj["showStoreBadge"]; - amino_userId = (string)jsonObj["auid"]; - needTriggerInterestPicker = (bool)jsonObj["needTriggerInterestPicker"]; - json = _json.ToString(); - - ParticipatedExperiments = new _ParticipatedExperiments(_json); - } - - - public class _ParticipatedExperiments - { - public int? chatMembersCommonChannel { get; private set; } - public int? couponPush { get; private set; } - public int? communityMembersCommonChannel { get; private set; } - public int? communityTabExp { get; private set; } - public int? userVectorCommunitySimilarityChannel { get; private set; } - - - public _ParticipatedExperiments(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - chatMembersCommonChannel = (int)jsonObj["participatedExperiments"]["chatMembersCommonChannel"]; - couponPush = (int)jsonObj["participatedExperiments"]["couponPush"]; - communityMembersCommonChannel = (int)jsonObj["participatedExperiments"]["communityMembersCommonChannel"]; - communityTabExp = (int)jsonObj["participatedExperiments"]["communityTabExp"]; - userVectorCommunitySimilarityChannel = (int)jsonObj["participatedExperiments"]["userVectorCommunitySimilarityChannel"]; - } - - } + + [JsonPropertyName("globalStrategyInfo")]public string GlobalStrategyInfo { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("contentLanguage")]public string ContentLanguage { get; set; } + [JsonPropertyName("signUpStrategy")]public int SignUpStrategy { get; set; } + [JsonPropertyName("landingOption")]public int LandingOption { get; set; } + [JsonPropertyName("needsBirthDateUpdate")]public bool NeedsBirthDateUpdate { get; set; } + [JsonPropertyName("interestPickerStyle")]public int InterestPickerStyle { get; set; } + [JsonPropertyName("showStoreBadge")]public bool ShowStoreBadge { get; set; } + [JsonPropertyName("auid")]public string AUID { get; set; } + [JsonPropertyName("needTriggerInterestPicker")]public bool NeedTriggerInterestPicker { get; set; } + [JsonPropertyName("participatedExperiments")]public ParticipatedExperiments ParticipatedExperiments { get; set; } + } } From 2855efc2bb01e556ab88c23e291f2b3c1b3f1869 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 19 May 2024 15:50:12 +0200 Subject: [PATCH 09/19] refactored more objects --- Amino.NET/Objects/AdvancedCommunityInfo.cs | 2 +- Amino.NET/Objects/Blog.cs | 4 +- Amino.NET/Objects/Chat.cs | 2 +- Amino.NET/Objects/Comment.cs | 3 +- .../Objects/CommunityAdvancedSettings.cs | 3 +- Amino.NET/Objects/CurrentUserInfo.cs | 15 + Amino.NET/Objects/FromCode.cs | 29 +- Amino.NET/Objects/FromId.cs | 36 -- Amino.NET/Objects/FromInvite.cs | 537 +----------------- Amino.NET/Objects/GenericProfile.cs | 55 +- Amino.NET/Objects/InfluencerFanClubMember.cs | 18 + Amino.NET/Objects/InfluencerPriceInfo.cs | 17 + Amino.NET/Objects/Invitation.cs | 22 + Amino.NET/Objects/LinkInfo.cs | 29 + Amino.NET/Objects/LinkInfoExtensions.cs | 15 + Amino.NET/Objects/UserProfile.cs | 4 + 16 files changed, 156 insertions(+), 635 deletions(-) create mode 100644 Amino.NET/Objects/CurrentUserInfo.cs delete mode 100644 Amino.NET/Objects/FromId.cs create mode 100644 Amino.NET/Objects/InfluencerFanClubMember.cs create mode 100644 Amino.NET/Objects/InfluencerPriceInfo.cs create mode 100644 Amino.NET/Objects/Invitation.cs create mode 100644 Amino.NET/Objects/LinkInfo.cs create mode 100644 Amino.NET/Objects/LinkInfoExtensions.cs diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs index d517667..42ea6e8 100644 --- a/Amino.NET/Objects/AdvancedCommunityInfo.cs +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -41,6 +41,6 @@ public class AdvancedCommunityInfo [JsonPropertyName("communityHeadList")] public List CommunityHeadList { get; set; } [JsonPropertyName("agent")] public GenericProfile Agent { get; set; } [JsonPropertyName("themePack")] public CommunityThemePack ThemePack { get; set; } - [JsonPropertyName("advancedSettings")] public CommunityAdvancedSettings AdvancedSettings { get; } + [JsonPropertyName("advancedSettings")] public CommunityAdvancedSettings AdvancedSettings { get; set; } } } \ No newline at end of file diff --git a/Amino.NET/Objects/Blog.cs b/Amino.NET/Objects/Blog.cs index 2118a3f..cc276e2 100644 --- a/Amino.NET/Objects/Blog.cs +++ b/Amino.NET/Objects/Blog.cs @@ -11,7 +11,7 @@ namespace Amino.Objects { public class Blog { - public string json { get; } // NEEDS TO BE ADDED AFTER + public string json { get; set; } // NEEDS TO BE ADDED AFTER [JsonPropertyName("globalVotesCount")]public int GlobalVotesCount { get; set; } = 0; [JsonPropertyName("globalVotedValue")]public int GlobalVotedValue { get; set; } = 0; [JsonPropertyName("votedValue")]public int VotedValue { get; set; } = 0; @@ -36,6 +36,6 @@ public class Blog [JsonPropertyName("ndcId")]public int CommunityId { get; set; } = 0; [JsonPropertyName("endTime")]public string EndTime { get; set; } [JsonPropertyName("commentsCount")]public int commentsCount { get; set; } = 0; - [JsonPropertyName("author")]public GenericProfile Author { get; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/Chat.cs b/Amino.NET/Objects/Chat.cs index 101b5ef..badfd77 100644 --- a/Amino.NET/Objects/Chat.cs +++ b/Amino.NET/Objects/Chat.cs @@ -7,7 +7,7 @@ namespace Amino.Objects { public class Chat { - public string json { get; private set; } // NEEDS TO BE ADDED LATER + public string json { get; set; } // NEEDS TO BE ADDED LATER [JsonPropertyName("uid")]public string UserId { get; set; } [JsonPropertyName("membersQuota")]public int MembersQuota { get; set; } [JsonPropertyName("threadId")]public string ThreadId { get; set; } diff --git a/Amino.NET/Objects/Comment.cs b/Amino.NET/Objects/Comment.cs index 567b5aa..5573e12 100644 --- a/Amino.NET/Objects/Comment.cs +++ b/Amino.NET/Objects/Comment.cs @@ -19,7 +19,6 @@ public class Comment [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } [JsonPropertyName("subcommentsCount")]public int SubcommentsCount { get; set; } [JsonPropertyName("type")]public int Type { get; set; } - public GenericProfile Author { get; private set; } - + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/CommunityAdvancedSettings.cs b/Amino.NET/Objects/CommunityAdvancedSettings.cs index d52659e..647fc93 100644 --- a/Amino.NET/Objects/CommunityAdvancedSettings.cs +++ b/Amino.NET/Objects/CommunityAdvancedSettings.cs @@ -16,6 +16,7 @@ public class CommunityAdvancedSettings [JsonPropertyName("pollMinFullBarCount")] public int PollMinFullBarCount { get; set; } [JsonPropertyName("catalogEnabled")] public bool CatalogEnabled { get; set; } [JsonPropertyName("newsFeedPages")] public List NewsFeed { get; set; } - [JsonPropertyName("rankingTable")] public List Ranks { get; set; } + [JsonPropertyName("rankingTable")] public List Ranks { get; set; } + [JsonPropertyName("welcomeMessageText")] public string WelcomeMessageText { get; set; } } } diff --git a/Amino.NET/Objects/CurrentUserInfo.cs b/Amino.NET/Objects/CurrentUserInfo.cs new file mode 100644 index 0000000..73cd40a --- /dev/null +++ b/Amino.NET/Objects/CurrentUserInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class CurrentUserInfo + { + [JsonPropertyName("notificationsCount")] public int NotificationsCount { get; set; } + [JsonPropertyName("userProfile")] public UserProfile UserProfile { get; set; } + } +} diff --git a/Amino.NET/Objects/FromCode.cs b/Amino.NET/Objects/FromCode.cs index 23fd901..520854c 100644 --- a/Amino.NET/Objects/FromCode.cs +++ b/Amino.NET/Objects/FromCode.cs @@ -1,35 +1,16 @@  using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: linkInfoV2 public class FromCode { - public string path { get; } - public string objectId { get; } - public int targetCode { get; } - public int communityId { get; } - public string fullPath { get; } - public string shortCode { get; } - public int objectType { get; } - public string json { get; } - public Community Community { get; } = null; + public string json { get; set; } // NEEDS TO BE SET AFTER + [JsonPropertyName("path")]public string Path { get; set; } + [JsonPropertyName("extensions")]public LinkInfoExtensions Extensions { get; set; } - public FromCode(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { if (jsonObj["linkInfoV2"]["path"] != null) { path = (string)jsonObj["linkInfoV2"]["path"]; } } catch { } - try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"] != null) { objectId = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"]; } } catch { } - try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"] != null) { targetCode = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"]; } } catch { } - try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"] != null) { communityId = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"]; } } catch { } - try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"] != null) { fullPath = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"]; } } catch { } - try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"] != null) { shortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"]; } } catch { } - try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"] != null) { objectType = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"]; } } catch { } - if(jsonObj["linkInfoV2"]["extensions"]["community"] != null) { Community = new Community(jsonObj["linkInfoV2"]["extensions"]["community"]); } - - json = _json.ToString(); - } } } diff --git a/Amino.NET/Objects/FromId.cs b/Amino.NET/Objects/FromId.cs deleted file mode 100644 index dc1c67a..0000000 --- a/Amino.NET/Objects/FromId.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Amino.Objects -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class FromId - { - public string path { get; } - public string objectId { get; } - public string shareURLShortCode { get; } - public int? targetCode { get; } - public int? communityId { get; } - public string fullPath { get; } - public string shortCode { get; } - public string shareURLFullPath { get; } - public int? objectType { get; } - public string json { get; } - - public FromId(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { path = (string)jsonObj["linkInfoV2"]["path"]; } catch { } - try { objectId = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"]; } catch { } - try { shareURLShortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shareURLShortCode"]; } catch { } - try { targetCode = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"]; } catch { } - try { communityId = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"]; } catch { } - try { fullPath = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"]; } catch { } - try { shortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"]; } catch { } - try { shareURLFullPath = (string)jsonObj["linKInfoV2"]["extensions"]["linkInfo"]["shareURLFullPath"]; } catch { } - try { objectType = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"]; } catch { } - json = _json.ToString(); - - } - } -} diff --git a/Amino.NET/Objects/FromInvite.cs b/Amino.NET/Objects/FromInvite.cs index 139d9c3..1839b54 100644 --- a/Amino.NET/Objects/FromInvite.cs +++ b/Amino.NET/Objects/FromInvite.cs @@ -1,540 +1,17 @@ using System.Collections.Generic; +using System.Text.Json.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class FromInvite { - public bool isCurrentUserJoined { get; } - public string path { get; } - public string invitationId { get; } - public _Community Community { get; } - public _CurrentUserInfo CurrentUserInfo { get; } - public _Invitation Invitation { get; } - public string json { get; } - - public FromInvite(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - if(jsonObj["isCurrentUserJoined"] != null) { isCurrentUserJoined = (bool)jsonObj["isCurrentUserJoined"]; } - path = (string)jsonObj["path"]; - if(jsonObj["invitationId"] != null) { invitationId = (string)jsonObj["invitationId"]; } - json = _json.ToString(); - if(jsonObj["invitation"] != null) { Invitation = new _Invitation(_json); } - if(jsonObj["currentUserInfo"] != null) { CurrentUserInfo = new _CurrentUserInfo(_json); } - if(jsonObj["community"] != null) { Community = new _Community(_json); } - - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Community - { - public string link { get; } - public string primaryLanguage { get; } - public string iconUrl { get; } - public string name { get; } - public int membersCount { get; } - public int probationStatus { get; } - public string content { get; } - public int templateId { get; } - public bool isStandaloneAppMonetizationEnabled { get; } - public string tagline { get; } - public int status { get; } - public string endpoint { get; } - public string createdTime { get; } - public bool isStandaloneAppDeprecated { get; } - public int listedStatus { get; } - public float communityHeat { get; } - public bool searchable { get; } - public int communityId { get; } - public int joinType { get; } - public string modifiedTime { get; } - public string updatedTime { get; } - public _AdvancedSettings AdvancedSettings { get; } - public _ThemePack ThemePack { get; } - public _Agent Agent { get; } - - public _Community(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - link = (string)jsonObj["community"]["link"]; - primaryLanguage = (string)jsonObj["community"]["primaryLanguage"]; - if(jsonObj["community"]["icon"] != null) { iconUrl = (string)jsonObj["community"]["icon"]; } - name = (string)jsonObj["community"]["name"]; - membersCount = (int)jsonObj["community"]["membersCount"]; - probationStatus = (int)jsonObj["community"]["probationStatus"]; - if(jsonObj["community"]["content"] != null) { content = (string)jsonObj["community"]["content"]; } - templateId = (int)jsonObj["community"]["templateId"]; - isStandaloneAppMonetizationEnabled = (bool)jsonObj["community"]["isStandaloneAppMonetizationEnabled"]; - if(jsonObj["community"]["tagline"] != null) { tagline = (string)jsonObj["community"]["tagline"]; } - status = (int)jsonObj["community"]["status"]; - endpoint = (string)jsonObj["community"]["endpoint"]; - createdTime = (string)jsonObj["community"]["createdTime"]; - isStandaloneAppDeprecated = (bool)jsonObj["community"]["isStandaloneAppDeprecated"]; - listedStatus = (int)jsonObj["community"]["listedStatus"]; - communityHeat = (float)jsonObj["community"]["communityHeat"]; - searchable = (bool)jsonObj["community"]["searchable"]; - communityId = (int)jsonObj["community"]["ndcId"]; - joinType = (int)jsonObj["community"]["joinType"]; - modifiedTime = (string)jsonObj["community"]["modifiedTime"]; - updatedTime = (string)jsonObj["community"]["updatedTime"]; - if(jsonObj["community"]["themePack"] != null) { ThemePack = new _ThemePack(_json); } - if(jsonObj["community"]["agent"] != null) { Agent = new _Agent(_json); } - if(jsonObj["community"]["advancedSettings"] != null) { AdvancedSettings = new _AdvancedSettings(_json); } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Agent - { - public int membershipStatus { get; } - public int accountMembershipStatus { get; } - public int membersCount { get; } - public bool isGlobal { get; } - public string userId { get; } - public int level { get; } - public bool isNicknameVerified { get; } - public int reputation { get; } - public int followingStatus { get; } - public string iconUrl { get; } - - public _Agent(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - membershipStatus = (int)jsonObj["community"]["agent"]["membershipStatus"]; - accountMembershipStatus = (int)jsonObj["community"]["agent"]["accountMembershipStatus"]; - membersCount = (int)jsonObj["community"]["agent"]["membersCount"]; - isGlobal = (bool)jsonObj["community"]["agent"]["isGlobal"]; - userId = (string)jsonObj["community"]["agent"]["uid"]; - level = (int)jsonObj["community"]["agent"]["level"]; - isNicknameVerified = (bool)jsonObj["community"]["agent"]["isNicknameVerified"]; - reputation = (int)jsonObj["community"]["agent"]["reputation"]; - followingStatus = (int)jsonObj["community"]["agent"]["followingStatus"]; - if(jsonObj["community"]["agent"]["icon"] != null) { iconUrl = (string)jsonObj["community"]["argent"]["icon"]; } - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _ThemePack - { - public int themePackRevision { get; } - public string themePackUrl { get; } - public string themeColor { get; } - public string themePackHash { get; } - - public _ThemePack(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - themePackRevision = (int)jsonObj["community"]["themePack"]["themePackRevision"]; - themePackUrl = (string)jsonObj["community"]["themePack"]["themePackUrl"]; - themeColor = (string)jsonObj["community"]["themePack"]["themeColor"]; - themePackHash = (string)jsonObj["community"]["themePack"]["themePackHash"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AdvancedSettings - { - public string welcomeMessageText { get; } - public int pollMinFullBarVoteCount { get; } - public int frontPageLayout { get; } - public bool hasPendingReviewRequest { get; } - public int defaultRankingTypeInLeaderboard { get; } - - public _AdvancedSettings(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - welcomeMessageText = (string)jsonObj["community"]["advancedSettings"]["welcomeMessageText"]; - pollMinFullBarVoteCount = (int)jsonObj["community"]["advancedSettings"]["pollMinFullBarVoteCount"]; - frontPageLayout = (int)jsonObj["community"]["advancedSettings"]["frontPageLayout"]; - hasPendingReviewRequest = (bool)jsonObj["community"]["advancedSettings"]["hasPendingReviewRequest"]; - defaultRankingTypeInLeaderboard = (int)jsonObj["community"]["advancedSettings"]["defaultRankingTypeInLeaderboard"]; - } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _CurrentUserInfo - { - public int notificationsCount { get; } - public _UserProfile UserProfile { get; } - - public _CurrentUserInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - notificationsCount = (int)jsonObj["currentUserInfo"]["notificationsCount"]; - UserProfile = new _UserProfile(_json); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _UserProfile - { - public string iconUrl { get; } - public string createdTime { get; } - public int commentsCount { get; } - public int followingStatus { get; } - public string nickname { get; } - public string userId { get; } - public string content { get; } - public int joinedCount { get; } - public int storiesCount { get; } - public int reputation { get; } - public int consecutiveCheckInDays { get; } - public int accountMembershipStatus { get; } - public int status { get; } - public int onlineStatus { get; } - public int postsCount { get; } - public int membershipStatus { get; } - public bool pushEnabled { get; } - public int level { get; } - public string modifiedTime { get; } - public bool isGlobal { get; } - public int communityId { get; } - public int itemsCount { get; } - public string moodSticker { get; } - public bool isNicknameVerified { get; } - public int role { get; } - public int notificationSubscriptionStatus { get; } - public string avatarFrameId { get; } - public int blogsCount { get; } - public int membersCount { get; } - public _Settings Settings { get; } - public List<_FanClubMember> FanClubList { get; } = new List<_FanClubMember>(); - public _InfluencerInfo InfluencerInfo { get; } - public _Extensions Extensions { get; } - public _AvatarFrame AvatarFrame { get; } - - public _UserProfile(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - iconUrl = (string)jsonObj["currentUserInfo"]["userProfile"]["icon"]; - createdTime = (string)jsonObj["currentUserInfo"]["userProfile"]["createdTime"]; - commentsCount = (int)jsonObj["currentUserInfo"]["userProfile"]["commentsCount"]; - followingStatus = (int)jsonObj["currentUserInfo"]["userProfile"]["followingStatus"]; - nickname = (string)jsonObj["currentUserInfo"]["userProfile"]["nickname"]; - userId = (string)jsonObj["currentUserInfo"]["userProfile"]["uid"]; - content = (string)jsonObj["currentUserInfo"]["userProfile"]["content"]; - joinedCount = (int)jsonObj["currentUserInfo"]["userProfile"]["joinedCount"]; - storiesCount = (int)jsonObj["currentUserInfo"]["userProfile"]["storiesCount"]; - reputation = (int)jsonObj["currentUserInfo"]["userProfile"]["reputation"]; - if (jsonObj["currentUserInfo"]["userProfile"]["consecutiveCheckInDays"] != null) { consecutiveCheckInDays = (int)jsonObj["currentUserInfo"]["userProfile"]["consecutiveCheckInDays"]; } - accountMembershipStatus = (int)jsonObj["currentUserInfo"]["userProfile"]["accountMembershipStatus"]; - status = (int)jsonObj["currentUserInfo"]["userProfile"]["status"]; - onlineStatus = (int)jsonObj["currentUserInfo"]["userProfile"]["onlineStatus"]; - postsCount = (int)jsonObj["currentUserInfo"]["userProfile"]["postsCount"]; - membershipStatus = (int)jsonObj["currentUserInfo"]["userProfile"]["membershipStatus"]; - pushEnabled = (bool)jsonObj["currentUserInfo"]["userProfile"]["pushEnabled"]; - level = (int)jsonObj["currentUserInfo"]["userProfile"]["level"]; - modifiedTime = (string)jsonObj["currentUserInfo"]["userProfile"]["modifiedTime"]; - isGlobal = (bool)jsonObj["currentUserInfo"]["userProfile"]["isGlobal"]; - communityId = (int)jsonObj["currentUserInfo"]["userProfile"]["ndcId"]; - itemsCount = (int)jsonObj["currentUserInfo"]["userProfile"]["itemsCount"]; - moodSticker = (string)jsonObj["currentUserInfo"]["userProfile"]["moodSticker"]; - isNicknameVerified = (bool)jsonObj["currentUserInfo"]["userProfile"]["isNicknameVerified"]; - role = (int)jsonObj["currentUserInfo"]["userProfile"]["role"]; - notificationSubscriptionStatus = (int)jsonObj["currentUserInfo"]["userProfile"]["notificationSubscriptionStatus"]; - if(jsonObj["currentUserInfo"]["userProfile"]["avatarFrameId"] != null) { avatarFrameId = (string)jsonObj["currentUserInfo"]["userProfile"]["avatarFrameId"]; } - blogsCount = (int)jsonObj["currentUserInfo"]["userProfile"]["blogsCount"]; - membersCount = (int)jsonObj["currentUserInfo"]["userProfile"]["membersCount"]; - - if (jsonObj["currentUserInfo"]["userProfile"]["settings"] != null) { Settings = new _Settings(_json); } - if(jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if(jsonObj["currentUserInfo"]["userProfile"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - if(jsonObj["currentUserInfo"]["userProfile"]["extensions"] != null) { Extensions = new _Extensions(_json); } - if(jsonObj["currentUserInfo"]["userProfile"]["fanClubList"] != null) - { - JArray _fanClubMemberArray = jsonObj["currentUserInfo"]["userProfile"]["fanClubList"]; - foreach(JObject fanClubMember in _fanClubMemberArray) - { - _FanClubMember _fanClubMember = new _FanClubMember(fanClubMember); - FanClubList.Add(_fanClubMember); - } - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public string frameId { get; } - public int status { get; } - public int ownershipStatus { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - frameId = (string)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["frameId"]; - status = (int)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["status"]; - if(jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["ownershipStatus"] != null) { ownershipStatus = (int)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["ownershipStatus"]; } - version = (int)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["currentUserInfo"]["userProfile"]["avatarFrame"]["frameType"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Extensions - { - public string defaultBubbleId { get; } - - public _Extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - if (jsonObj["currentUserInfo"]["userProfile"]["extensions"]["defaultBubbleId"] != null) { defaultBubbleId = jsonObj["currentUserInfo"]["userProfile"]["extensions"]["defaultBubbleId"]; } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int monthlyFee { get; } - public bool isPinned { get; } - public string createdTime { get; } - public int fansCount { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - monthlyFee = (int)jsonObj["currentUserInfo"]["userProfile"]["influencerInfo"]["monthlyFee"]; - isPinned = (bool)jsonObj["currentUserInfo"]["userProfile"]["influencerInfo"]["pinned"]; - createdTime = (string)jsonObj["currentUserInfo"]["userProfile"]["influencerInfo"]["createdTime"]; - fansCount = (int)jsonObj["currentUserInfo"]["userProfile"]["influencerInfo"]["fansCount"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Settings - { - public int onlineStatus { get; } - - public _Settings(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - onlineStatus = (int)jsonObj["currentUserInfo"]["userProfile"]["settings"]["onlineStatus"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _FanClubMember - { - public int fansStatus { get; } - public string createdTime { get; } - public string targetUserId { get; } - public string expiredTime { get; } - public _TargetUserProfile TargetUserProfile { get; } - - - public _FanClubMember(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansStatus = (int)jsonObj["fansStatus"]; - createdTime = (string)jsonObj["createdTime"]; - targetUserId = (string)jsonObj["targetUid"]; - expiredTime = (string)jsonObj["expiredTime"]; - TargetUserProfile = new _TargetUserProfile(_json); - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _TargetUserProfile - { - public int membershipStatus { get; } - public int accountMembershipStatus { get; } - public int status { get; } - public int followingStatus { get; } - public int reputation { get; } - public int communityId { get; } - public bool isNicknameVerified { get; } - public string iconUrl { get; } - public string userId { get; } - public int role { get; } - public bool isGlobal { get; } - public int level { get; } - public int membersCount { get; } - public string nickname { get; } - public _AvatarFrame AvatarFrame { get; } - - - public _TargetUserProfile(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - membershipStatus = (int)jsonObj["targetUserProfile"]["membershipStatus"]; - accountMembershipStatus = (int)jsonObj["targetUserProfile"]["accountMembershipStatus"]; - status = (int)jsonObj["targetUserProfile"]["status"]; - followingStatus = (int)jsonObj["targetUserProfile"]["followingStatus"]; - reputation = (int)jsonObj["targetUserProfile"]["reputation"]; - communityId = (int)jsonObj["targetUserProfile"]["ndcId"]; - isNicknameVerified = (bool)jsonObj["targetUserProfile"]["isNicknameVerified"]; - if(jsonObj["targetUserProfile"]["icon"] != null) { iconUrl = (string)jsonObj["targetUserProfile"]["icon"]; } - userId = (string)jsonObj["targetUserProfile"]["uid"]; - role = (int)jsonObj["targetUserProfile"]["role"]; - isGlobal = (bool)jsonObj["targetUserProfile"]["isGlobal"]; - level = (int)jsonObj["targetUserProfile"]["level"]; - membersCount = (int)jsonObj["targetUserProfile"]["membersCount"]; - nickname = (string)jsonObj["targetUserProfile"]["nickname"]; - if(jsonObj["targetUserProfile"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public string frameId { get; } - public int status { get; } - public int ownershipStatus { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - frameId = (string)jsonObj["targetUserProfile"]["avatarFrame"]["frameId"]; - status = (int)jsonObj["targetUserProfile"]["avatarFrame"]["status"]; - if(jsonObj["targetUserProfile"]["avatarFrame"]["ownershipStatus"] != null) { ownershipStatus = (int)jsonObj["targetUserProfile"]["avatarFrame"]["ownershipStatus"]; } - version = (int)jsonObj["targetUserProfile"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["targetUserProfile"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["targetUserProfile"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["targetUserProfile"]["avatarFrame"]["iconUrl"]; - frameType = (int)jsonObj["targetUserProfile"]["avatarFrame"]["frameType"]; - } - } - } - } - } - - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Invitation - { - public string link { get; } - public string modifiedTime { get; } - public string invitationId { get; } - public string createdTime { get; } - public int duration { get; } - public int status { get; } - public int communityId { get; } - public string inviteCode { get; } - public _Author Author { get; } - - public _Invitation(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - - link = (string)jsonObj["invitation"]["link"]; - modifiedTime = (string)jsonObj["invitation"]["modifiedTime"]; - invitationId = (string)jsonObj["invitation"]["invitationId"]; - createdTime = (string)jsonObj["invitation"]["createdTime"]; - duration = (int)jsonObj["invitation"]["duration"]; - status = (int)jsonObj["invitation"]["status"]; - communityId = (int)jsonObj["invitation"]["ndcId"]; - inviteCode = (string)jsonObj["invitation"]["inviteCode"]; - Author = new _Author(_json); - - } - - - public class _Author - { - public int reputation { get; } - public bool isGlobal { get; } - public int role { get; } - public string userId { get; } - public int followingStatus { get; } - public int level { get; } - public bool isNicknameVerified { get; } - public string avatarFrameId { get; } - public string nickname { get; } - public string iconUrl { get; } - public int membershipStatus { get; } - public int communityId { get; } - public int membersCount { get; } - public int accountMembershipStatus { get; } - public int status { get; } - public _InfluencerInfo InfluencerInfo { get; } - public _AvatarFrame AvatarFrame { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - reputation = (int)jsonObj["invitation"]["author"]["reputation"]; - isGlobal = (bool)jsonObj["invitation"]["author"]["isGlobal"]; - role = (int)jsonObj["invitation"]["author"]["role"]; - userId = (string)jsonObj["invitation"]["author"]["uid"]; - followingStatus = (int)jsonObj["invitation"]["author"]["followingStatus"]; - level = (int)jsonObj["invitation"]["author"]["level"]; - isNicknameVerified = (bool)jsonObj["invitation"]["author"]["isNicknameVerified"]; - if(jsonObj["invitation"]["author"]["avatarFrameId"] != null) { avatarFrameId = (string)jsonObj["invitation"]["author"]["avatarFrameId"]; } - if(jsonObj["invitation"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - nickname = (string)jsonObj["invitation"]["author"]["nickname"]; - iconUrl = (string)jsonObj["invitation"]["author"]["icon"]; - if(jsonObj["invitation"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - membershipStatus = (int)jsonObj["invitation"]["author"]["membershipStatus"]; - accountMembershipStatus = (int)jsonObj["invitation"]["author"]["accountMembershipStatus"]; - status = (int)jsonObj["invitation"]["author"]["status"]; - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public bool isPinned { get; } - public string createdTime { get; } - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - isPinned = (bool)jsonObj["invitation"]["author"]["influencerInfo"]["pinned"]; - createdTime = (string)jsonObj["invitation"]["author"]["influencerInfo"]["createdTime"]; - fansCount = (int)jsonObj["invitation"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["invitation"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - public int status { get; } - public int ownershipStatus { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - version = (int)jsonObj["invitation"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["invitation"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["invitation"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["invitation"]["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["invitation"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["invitation"]["author"]["avatarFrame"]["frameId"]; - status = (int)jsonObj["invitation"]["author"]["avatarFrame"]["status"]; - if(jsonObj["invitation"]["author"]["avatarFrame"]["ownershipStatus"] != null) { ownershipStatus = (int)jsonObj["invitation"]["author"]["avatarFrame"]["ownershipStatus"]; } - } - - } - } - } + [JsonPropertyName("isCurrentlyJoined")]public bool IsCurrentUserJoined { get; set; } + [JsonPropertyName("path")]public string Path { get; set; } + [JsonPropertyName("invitationId")]public string InvitationId { get; set; } + [JsonPropertyName("community")]public AdvancedCommunityInfo Community { get; set; } + [JsonPropertyName("currentUserInfo")]public CurrentUserInfo CurrentUserInfo { get; set; } + [JsonPropertyName("invitation")]public Invitation Invitation { get; set; } } } diff --git a/Amino.NET/Objects/GenericProfile.cs b/Amino.NET/Objects/GenericProfile.cs index 5229c27..4666a7b 100644 --- a/Amino.NET/Objects/GenericProfile.cs +++ b/Amino.NET/Objects/GenericProfile.cs @@ -4,47 +4,26 @@ namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class GenericProfile + public class GenericProfile // ROOT JSON ELEMENT: userProfile { - public int status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int membershipStatus { get; private set; } - public string avatarFrameId { get; private set; } - public int reputation { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - public int communityId { get; private set; } - public string json { get; private set; } + public string json { get; set; } // NEEDS TO BE SET AFTER + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("isNicknameVerified")]public bool IsNicknameVerified { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("level")]public int Level { get; set; } + [JsonPropertyName("followingStatus")]public int FollowingStatus { get; set; } + [JsonPropertyName("accountMembershipStatus")]public int AccountMembershipStatus { get; set; } + [JsonPropertyName("isGlobal")]public bool IsGlobal { get; set; } + [JsonPropertyName("membershipStatus")]public int MembershipStatus { get; set; } + [JsonPropertyName("avatarFrameId")]public string AvatarFrameId { get; set; } + [JsonPropertyName("reputation")]public int Reputation { get; set; } + [JsonPropertyName("membersCount")]public int MembersCount { get; set; } + [JsonPropertyName("nickname")]public string Nickname { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("avatarFrame")] public GenericAvatarFrame AvatarFrame { get; set; } [JsonPropertyName("influencerInfo")] public InfluencerPriceInfo InfluencerInfo { get; set; } - - public GenericProfile(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - - status = (int)jsonObj["userProfile"]["status"]; - isNicknameVerified = (bool)jsonObj["userProfile"]["isNicknameVerified"]; - userId = (string)jsonObj["userProfile"]["uid"]; - level = (int)jsonObj["userProfile"]["level"]; - followingStatus = (int)jsonObj["userProfile"]["followingStatus"]; - accountMembershipStatus = (int)jsonObj["userProfile"]["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["userProfile"]["isGlobal"]; - membershipStatus = (int)jsonObj["userProfile"]["membershipStatus"]; - avatarFrameId = (string)jsonObj["userProfile"]["avatarFrameId"]; - reputation = (int)jsonObj["userProfile"]["reputation"]; - membersCount = (int)jsonObj["userProfile"]["membersCount"]; - nickname = (string)jsonObj["userProfile"]["nickname"]; - iconUrl = (string)jsonObj["userProfile"]["icon"]; - communityId = (int)jsonObj["userProfile"]["ndcId"]; - json = _json.ToString(); - } } } diff --git a/Amino.NET/Objects/InfluencerFanClubMember.cs b/Amino.NET/Objects/InfluencerFanClubMember.cs new file mode 100644 index 0000000..bb5d07a --- /dev/null +++ b/Amino.NET/Objects/InfluencerFanClubMember.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class InfluencerFanClubMember + { + [JsonPropertyName("fansStatus")] public int FanStatus { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("targetUserId")] public string TargetUserId { get; set; } + [JsonPropertyName("expiredTime")] public string ExpiredTime { get; set; } + [JsonPropertyName("targetUserProfile")] public GenericProfile TargetUserProfile { get; set; } + } +} diff --git a/Amino.NET/Objects/InfluencerPriceInfo.cs b/Amino.NET/Objects/InfluencerPriceInfo.cs new file mode 100644 index 0000000..6823d5e --- /dev/null +++ b/Amino.NET/Objects/InfluencerPriceInfo.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class InfluencerPriceInfo + { + [JsonPropertyName("isPinned")] public bool IsPinned { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("fansCount")] public int FanCount { get; set; } + [JsonPropertyName("monthlyFee")] public int MonthlyFee { get; set; } + } +} diff --git a/Amino.NET/Objects/Invitation.cs b/Amino.NET/Objects/Invitation.cs new file mode 100644 index 0000000..cd6c0d4 --- /dev/null +++ b/Amino.NET/Objects/Invitation.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class Invitation + { + [JsonPropertyName("link")] public string Link { get; set; } + [JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; } + [JsonPropertyName("invitationId")] public string InvitationId { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("duration")] public int Duration { get; set; } + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("ndcId")] public int CommunityId { get; set; } + [JsonPropertyName("inviteCode")] public string InviteCode { get; set; } + [JsonPropertyName("author")] public GenericProfile Author { get; set; } + } +} diff --git a/Amino.NET/Objects/LinkInfo.cs b/Amino.NET/Objects/LinkInfo.cs new file mode 100644 index 0000000..729c024 --- /dev/null +++ b/Amino.NET/Objects/LinkInfo.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class LinkInfo + { + [JsonPropertyName("objectId")] public string ObjectId { get; set; } + [JsonPropertyName("targetCode")] public string TargetCode { get; set; } + [JsonPropertyName("ndcId")] public int CommunityId { get; set; } + [JsonPropertyName("fullPath")] public string FullPath { get; set; } + [JsonPropertyName("shortCode")] public string ShortCode { get; set; } + [JsonPropertyName("objectType")] public int ObjectType { get; set; } + /// + /// The shareable URL Shortcode of an Object + /// Available with + /// + [JsonPropertyName("shareURLShortCode")] public string ShareURLShortCode { get; set; } + /// + /// The full path URL of an Object + /// Availabe with + /// + [JsonPropertyName("shareURLFullPath")] public string ShareURLFullPath { get; set; } + } +} diff --git a/Amino.NET/Objects/LinkInfoExtensions.cs b/Amino.NET/Objects/LinkInfoExtensions.cs new file mode 100644 index 0000000..8715522 --- /dev/null +++ b/Amino.NET/Objects/LinkInfoExtensions.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class LinkInfoExtensions + { + [JsonPropertyName("community")] Community Community { get; set; } + [JsonPropertyName("linkInfo")] LinkInfo LinkInfo { get; set; } + } +} diff --git a/Amino.NET/Objects/UserProfile.cs b/Amino.NET/Objects/UserProfile.cs index df44a8a..3925097 100644 --- a/Amino.NET/Objects/UserProfile.cs +++ b/Amino.NET/Objects/UserProfile.cs @@ -1,5 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Amino.Objects { @@ -38,6 +40,8 @@ public class UserProfile public int blogsCount { get; } public string json { get; } public _Extensions Extensions { get; } + [JsonPropertyName("influencerInfo")]public InfluencerInfo InfluencerInfo { get; set; } + [JsonPropertyName("fanClubList")] public List FanClubList { get; set; } public UserProfile(JObject _json) { From 77a5540fa960472384cf77466bbd82825bea3d87 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Mon, 20 May 2024 18:04:26 +0200 Subject: [PATCH 10/19] refactored more objects --- Amino.NET/Objects/ImageMessage.cs | 131 +++-------------- Amino.NET/Objects/InfluencerInfo.cs | 198 +------------------------- Amino.NET/Objects/InviteCode.cs | 126 ++-------------- Amino.NET/Objects/JoinedChatMember.cs | 124 ++-------------- Amino.NET/Objects/Membership.cs | 21 +++ Amino.NET/Objects/MembershipInfo.cs | 44 +----- Amino.NET/Objects/UserProfile.cs | 1 - Amino.NET/Objects/globalProfile.cs | 131 +++++------------ 8 files changed, 106 insertions(+), 670 deletions(-) create mode 100644 Amino.NET/Objects/Membership.cs diff --git a/Amino.NET/Objects/ImageMessage.cs b/Amino.NET/Objects/ImageMessage.cs index 1a86e0f..de6cc61 100644 --- a/Amino.NET/Objects/ImageMessage.cs +++ b/Amino.NET/Objects/ImageMessage.cs @@ -1,123 +1,30 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { //MediaType: 100 - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class ImageMessage { - public int _type { get; } - public int communityId { get; } - public string mediaUrl { get; } - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string objectId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string chatBubbleId { get; } - public int chatBubbleVersion { get; } - public int alertOption { get; } - public int membershipStatus { get; } - public string json { get; } - public _Author Author { get; } - - public ImageMessage(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { _type = (int)jsonObj["t"]; } catch { } - try { communityId = (int)jsonObj["o"]["ndcId"]; } catch { } - try { mediaUrl = (string)jsonObj["o"]["chatMessage"]["mediaValue"]; } catch { } - try { chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; } catch { } - try { mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; } catch { } - try { clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; } catch { } - try { messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; } catch { } - try { objectId = (string)jsonObj["o"]["chatMessage"]["uid"]; } catch { } - try { createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; } catch { } - try { type = (int)jsonObj["o"]["chatMessage"]["type"]; } catch { } - try { isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; } catch { } - try { includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; } catch { } - try { chatBubbleId = (string)jsonObj["o"]["chatMessage"]["chatBubbleId"]; } catch { } - try { chatBubbleVersion = (int)jsonObj["o"]["chatMessage"]["chatBubbleVersion"]; } catch { } - try { alertOption = (int)jsonObj["o"]["alertOption"]; } catch { } - try { membershipStatus = (int)jsonObj["o"]["membershipStatus"]; } catch { } - json = _json.ToString(); - Author = new _Author(_json); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; } catch { } - try { status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; } catch { } - try { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } catch { } - try { reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; } catch { } - try { role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; } catch { } - try { nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; } catch { } - try { level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } } catch { } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; } catch { } - try { version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; } catch { } - try { resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; } catch { } - try { name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; } catch { } - try { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; } catch { } - try { frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; } catch { } - try { frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; } catch { } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; } catch { } - try { monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; } catch { } - } - - } - } + SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER + [JsonPropertyName("mediaValue")]public string MediaUrl { get; set; } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string ObjectId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + [JsonPropertyName("chatBubbleId")]public string ChatBubbleId { get; set; } + [JsonPropertyName("chatBubbleVersion")]public int ChatBubbleVersion { get; set; } + [JsonPropertyName("alertOption")]public int AlertOption { get; set; } + [JsonPropertyName("membershipStatus")]public int MembershipStatus { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } diff --git a/Amino.NET/Objects/InfluencerInfo.cs b/Amino.NET/Objects/InfluencerInfo.cs index 599ade6..c2965cb 100644 --- a/Amino.NET/Objects/InfluencerInfo.cs +++ b/Amino.NET/Objects/InfluencerInfo.cs @@ -1,204 +1,14 @@ using Newtonsoft.Json.Linq; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Amino.Objects { public class InfluencerInfo { - public _FanClubMember MyFanClub { get; } - public _FanClubUserProfile InfluencerUserProfile { get; } - public List<_FanClubMember> FanClubMembers { get; } = new(); - public string json { get; } - - public InfluencerInfo(JObject json) - { - this.json = json.ToString(); - try { MyFanClub = new(JObject.Parse((string)json["myFanClub"])); } catch { } - try { InfluencerUserProfile = new(JObject.Parse((string)json["influencerUserProfile"])); } catch { } - if (json["fanClubList"] != null) { foreach (JObject clubMember in json["fanClubList"]) { FanClubMembers.Add(new(clubMember)); } } - - } - - - - public class _FanClubMember - { - public string userId { get; } - public string lastThankedTime { get; } - public string expiredTime { get; } - public string createdTime { get; } - public int fansStatus { get; } = 0; - public _FanClubUserProfile FanUserProfile { get; } - - public _FanClubMember(JObject json) - { - try { userId = (string)json["uid"]; } catch { } - try { lastThankedTime = (string)json["lastThankedTime"]; } catch { } - try { expiredTime = (string)json["expiredTime"]; } catch { } - try { createdTime = (string)json["createdTime"]; } catch { } - try { fansStatus = (int)json["fansStatus"]; } catch { } - - try { FanUserProfile = new(JObject.Parse((string)json["fansUserProfile"])); } catch { } - } - - - - } - public class _FanClubUserProfile - { - public int status { get; } = 0; - public string moodSticker { get; } - public int itemsCount { get; } = 0; - public int consecutiveCheckInDays { get; } = 0; - public string userId { get; } - public string modifiedTime { get; } - public int followingStatus { get; } = 0; - public int onlineStatus { get; } = 0; - public int accountMembershipStatus { get; } = 0; - public bool isGlobal { get; } = false; - public string avatarFrameId { get; } - public int reputation { get; } = 0; - public int postsCount { get; } = 0; - public int membersCount { get; } = 0; - public string nickname { get; } - public string iconUrl { get; } - public bool isNicknameVerified { get; } = false; - public string mood { get; } - public int level { get; } = 0; - public int notificationSubscriptionStatus { get; } = 0; - public bool pushEnabled { get; } = false; - public int membershipStatus { get; } = 0; - public string content { get; } - public int joinedCount { get; } = 0; - public int role { get; } = 0; - public int commentsCount { get; } = 0; - public int communityId { get; } = 0; - public string createdTime { get; } - public int storiesCount { get; } = 0; - public int blogsCount { get; } = 0; - public _AvatarFrame AvatarFrame { get; } - public _Extensions Extensions { get; } - public _InfluencerInfo InfluencerInfo { get; } - - - public _FanClubUserProfile(JObject json) - { - try { status = (int)json["status"]; } catch { } - try { moodSticker = (string)json["moodSticker"]; } catch { } - try { itemsCount = (int)json["itemsCount"]; } catch { } - try { consecutiveCheckInDays = (int)json["consecutiveCheckInDays"]; } catch { } - try { userId = (string)json["uid"]; } catch { } - try { modifiedTime = (string)json["modifiedTime"]; } catch { } - try { followingStatus = (int)json["followingStatus"]; } catch { } - try { onlineStatus = (int)json["onlineStatus"]; } catch { } - try { accountMembershipStatus = (int)json["accountMembershipStatus"]; } catch { } - try { isGlobal = (bool)json["isGlobal"]; } catch { } - try { reputation = (int)json["reputation"]; } catch { } - try { postsCount = (int)json["postsCount"]; } catch { } - try { membersCount = (int)json["membersCount"]; } catch { } - try { nickname = (string)json["nickname"]; } catch { } - try { iconUrl = (string)json["icon"]; } catch { } - try { isNicknameVerified = (bool)json["isNicknameVerified"]; } catch { } - try { mood = (string)json["mood"]; } catch { } - try { level = (int)json["level"]; } catch { } - try { notificationSubscriptionStatus = (int)json["notificationSubscriptionStatus"]; } catch { } - try { pushEnabled = (bool)json["pushEnabled"]; } catch { } - try { membershipStatus = (int)json["membershipStatus"]; } catch { } - try { content = (string)json["content"]; } catch { } - try { joinedCount = (int)json["joinedCount"]; } catch { } - try { role = (int)json["role"]; } catch { } - try { commentsCount = (int)json["commentsCount"]; } catch { } - try { communityId = (int)json["ndcId"]; } catch { } - try { createdTime = (string)json["createdTime"]; } catch { } - try { storiesCount = (int)json["storiesCount"]; } catch { } - try { blogsCount = (int)json["blogsCount"]; } catch { } - - if (json["extensions"] != null) { Extensions = new(JObject.Parse((string)json["extensions"])); } - if (json["avatarFrame"] != null) { AvatarFrame = new(JObject.Parse((string)json["avatarFrame"])); } - if (json["influencerInfo"] != null) { InfluencerInfo = new(JObject.Parse((string)json["influencerInfo"])); } - } - - - - public class _AvatarFrame - { - public int status { get; } = 0; - public int ownershipStatus { get; } = 0; - public int version { get; } = 0; - public string resoureUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } = 0; - public string frameId { get; } - - public _AvatarFrame(JObject json) - { - try { status = (int)json["status"]; } catch { } - try { ownershipStatus = (int)json["ownershipStatus"]; } catch { } - try { version = (int)json["version"]; } catch { } - try { resoureUrl = (string)json["resourceUrl"]; } catch { } - try { name = (string)json["name"]; } catch { } - try { iconUrl = (string)json["icon"]; } catch { } - try { frameType = (int)json["frameType"]; } catch { } - try { frameId = (string)json["frameId"]; } catch { } - } - } - - public class _InfluencerInfo - { - public bool pinned { get; } = false; - public string createdTime { get; } - public int fansCount { get; } = 0; - public int monthlyFee { get; } = 0; - - public _InfluencerInfo(JObject json) - { - try { pinned = (bool)json["pinned"]; } catch { } - try { createdTime = (string)json["createdTime"]; } catch { } - try { fansCount = (int)json["fansCount"]; } catch { } - try { monthlyFee = (int)json["monthlyFee"]; } catch { } - } - } - - public class _Extensions - { - public string defaultBubbleId { get; } - public _Style Style { get; } - public List<_CustomTitle> CustomTitles { get; } = new List<_CustomTitle>(); - - public _Extensions(JObject json) - { - try { defaultBubbleId = (string)json["defaultBubbleId"]; } catch { } - if (json["style"] != null) { Style = new(JObject.Parse((string)json["style"])); } - if (json["customTitles"] != null) - { - foreach(JObject title in json["customTitles"]) { CustomTitles.Add(new(title)); } - } - } - - public class _CustomTitle - { - public string color { get; } - public string title { get; } - - public _CustomTitle(JObject json) - { - try { color = (string)json["color"]; } catch { } - try { title = (string)json["title"]; } catch { } - } - } - - public class _Style - { - public string backgroundColor { get; } - - public _Style(JObject json) - { - try { backgroundColor = (string)json["backgroundColor"]; } catch { } - } - } - } - } + [JsonPropertyName("myFanClub")]public InfluencerFanClubMember MyFanClub { get; set; } + [JsonPropertyName("influencerUserProfile")]public UserProfile InfluencerUserProfile { get; set; } + [JsonPropertyName("fanClubList")]public List FanClubMembers { get; set; } } } diff --git a/Amino.NET/Objects/InviteCode.cs b/Amino.NET/Objects/InviteCode.cs index 181b6ad..3ce636c 100644 --- a/Amino.NET/Objects/InviteCode.cs +++ b/Amino.NET/Objects/InviteCode.cs @@ -1,125 +1,17 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class InviteCode { - public int status { get; } - public int duration { get; } - public string invitationId { get; } - public string inviteUrl { get; } - public string modifiedTime { get; } - public int communityId { get; } - public string createdTime { get; } - public string json { get; } - public _Author Author { get; } - - - public InviteCode(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["status"]; - duration = (int)jsonObj["duration"]; - invitationId = (string)jsonObj["invitationId"]; - inviteUrl = (string)jsonObj["link"]; - modifiedTime = (string)jsonObj["modifiedTime"]; - communityId = (int)jsonObj["ndcId"]; - json = _json.ToString(); - Author = new _Author(_json); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public int status { get; } - public bool isNicknameVerified { get; } - public string userId { get; } - public int level { get; } - public int followingStatus { get; } - public int accountMembershipStatus { get; } - public bool isGlobal { get; } - public int membershipStatus { get; } - public string avatarFrameId { get; } - public int reputation { get; } - public int role { get; } - public int communityId { get; } - public int membersCount { get; } - public string nickname { get; } - public string iconUrl { get; } - public _InfluencerInfo InfluencerInfo { get; } - public _AvatarFrame AvatarFrame { get; } - - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["author"]["status"]; - isNicknameVerified = (bool)jsonObj["author"]["isNicknameVerified"]; - userId = (string)jsonObj["author"]["uid"]; - level = (int)jsonObj["author"]["level"]; - followingStatus = (int)jsonObj["author"]["followingStatus"]; - accountMembershipStatus = (int)jsonObj["author"]["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["author"]["isGlobal"]; - membershipStatus = (int)jsonObj["author"]["membershipStatus"]; - avatarFrameId = (string)jsonObj["author"]["avatarFrameId"]; - reputation = (int)jsonObj["author"]["reputation"]; - role = (int)jsonObj["author"]["role"]; - communityId = (int)jsonObj["author"]["ndcId"]; - membersCount = (int)jsonObj["author"]["membersCount"]; - nickname = (string)jsonObj["author"]["nickname"]; - if (jsonObj["author"]["icon"] != null) { iconUrl = (string)jsonObj["author"]["icon"]; } - if(jsonObj["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - if(jsonObj["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public bool pinned { get; } - public string createdTime { get; } - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - pinned = (bool)jsonObj["author"]["influencerInfo"]["pinned"]; - createdTime = (string)jsonObj["author"]["influencerInfo"]["createdTime"]; - fansCount = (int)jsonObj["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["author"]["influencerInfo"]["monthlyFee"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public string ownershipStatus { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["author"]["avatarFrame"]["status"]; - ownershipStatus = (string)jsonObj["author"]["avatarFrame"]["ownershipStatus"]; - version = (int)jsonObj["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["author"]["avatarFrame"]["icon"]; - frameId = (string)jsonObj["author"]["avatarFrame"]["frameId"]; - } - - - } - } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("duration")]public int Duration { get; set; } + [JsonPropertyName("invitationId")]public string InvitationId { get; set; } + [JsonPropertyName("link")]public string InviteUrl { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/JoinedChatMember.cs b/Amino.NET/Objects/JoinedChatMember.cs index eca3833..5bc2b28 100644 --- a/Amino.NET/Objects/JoinedChatMember.cs +++ b/Amino.NET/Objects/JoinedChatMember.cs @@ -1,118 +1,24 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class JoinedChatMember { - public int _type { get; } - public int alertOption { get; } - public int membershipStatus { get; } - public int communityId { get; } - - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - public _Author Author { get; } - - public JoinedChatMember(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - communityId = (int)jsonObj["o"]["ndcId"]; - - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - Author = new _Author(_json); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; - status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; - reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; - role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; - nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; - level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; - accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; - if(jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if(jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - } + public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/Membership.cs b/Amino.NET/Objects/Membership.cs new file mode 100644 index 0000000..6338901 --- /dev/null +++ b/Amino.NET/Objects/Membership.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class Membership + { + [JsonPropertyName("paymentType")] public int PaymentTime { get; set; } + [JsonPropertyName("expiredDate")] public string ExpiredDate { get; set; } + [JsonPropertyName("renewedTime")] public string RenewedTime { get; set; } + [JsonPropertyName("uid")] public string ObjectId { get; set; } + [JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; } + [JsonPropertyName("isAutoRenew")] public bool IsAutoRenew { get; set; } + [JsonPropertyName("membershipStatus")] public int MembershipStatus { get; set; } + + } +} diff --git a/Amino.NET/Objects/MembershipInfo.cs b/Amino.NET/Objects/MembershipInfo.cs index ee74809..8fec023 100644 --- a/Amino.NET/Objects/MembershipInfo.cs +++ b/Amino.NET/Objects/MembershipInfo.cs @@ -1,49 +1,15 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class MembershipInfo { - public bool accountMembershipEnabled { get; } - public bool hasAnyAppleSubscription { get; } - public bool hasAnyAndroidSubscription { get; } - public string json { get; } - public _Membership Membership { get; } + [JsonPropertyName("accountMembershipEnabled")] public bool AccountMembershipEnabled { get; set; } + [JsonPropertyName("hasAnyAppleSubscription")] public bool HasAnyAppleSubscription { get; set; } + [JsonPropertyName("hasAnyAndroidSubscription")]public bool HasAnyAndroidSubscription { get; set; } + [JsonPropertyName("membership")]public Membership Membership { get; set; } - - - public MembershipInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - accountMembershipEnabled = (bool)jsonObj["accountMembershipEnabled"]; - hasAnyAppleSubscription = (bool)jsonObj["hasAnyAppleSubscription"]; - hasAnyAndroidSubscription = (bool)jsonObj["hasAnyAndroidSubscriiption"]; - json = _json.ToString(); - if(jsonObj["membership"] != null) { Membership = new _Membership(_json); } - } - } - - public class _Membership - { - public int paymentType { get; } - public string expiredDate { get; } - public string renewedTime { get; } - public string userId { get; } - public string modifiedTime { get; } - public bool isAutoRenew { get; } - public int membershipStatus { get; } - public _Membership(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - paymentType = (int)jsonObj["membership"]["paymentType"]; - expiredDate = (string)jsonObj["membership"]["expiredTime"]; - renewedTime = (string)jsonObj["membership"]["renewedTime"]; - userId = (string)jsonObj["membership"]["uid"]; - modifiedTime = (string)jsonObj["membership"]["modifiedTime"]; - isAutoRenew = (bool)jsonObj["membership"]["isAutoRenew"]; - membershipStatus = (int)jsonObj["membership"]["membershipStatus"]; - } } } diff --git a/Amino.NET/Objects/UserProfile.cs b/Amino.NET/Objects/UserProfile.cs index 3925097..c1a8a60 100644 --- a/Amino.NET/Objects/UserProfile.cs +++ b/Amino.NET/Objects/UserProfile.cs @@ -6,7 +6,6 @@ namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class UserProfile { public int status { get; } diff --git a/Amino.NET/Objects/globalProfile.cs b/Amino.NET/Objects/globalProfile.cs index e42e17b..a970ea0 100644 --- a/Amino.NET/Objects/globalProfile.cs +++ b/Amino.NET/Objects/globalProfile.cs @@ -1,109 +1,44 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: userProfile public class GlobalProfile { - public int? status { get; private set; } = new int?(); - public int? itemsCount { get; private set; } = new int?(); - public string? userId { get; private set; } - public string? modifiedTime { get; private set; } - public int? followingStatus { get; private set; } = new int?(); - public int? onlineStatus { get; private set; } = new int?(); - public int? accountMembershipStatus { get; private set; } = new int?(); - public bool? isGlobal { get; private set; } - public string? avatarFrameId { get; private set; } - public int? reputation { get; private set; } = new int?(); - public int? postsCount { get; private set; } = new int?(); - public int? memberCount { get; private set; } = new int?(); - public string? nickname { get; private set; } - public string? iconUrl { get; private set; } - public bool? isNicknameVerified { get; private set; } - public int? visitorsCount { get; private set; } = new int?(); - public int? level { get; private set; } = new int?(); - public int? notificationSubscriptionStatus { get; private set; } = new int?(); - public bool? pushEnabled { get; private set; } - public int? membershipStatus { get; private set; } = new int?(); - public string? content { get; private set; } - public int? joinedCount { get; private set; } = new int?(); - public int? role { get; private set; } = new int?(); - public int? commentsCount { get; private set; } = new int?(); - public string? aminoId { get; private set; } - public string? communityId { get; private set; } - public string? createdTime { get; private set; } - public int? visitPrivacy { get; private set; } = new int?(); - public int? storiesCount { get; private set; } = new int?(); - public int? blogsCount { get; private set; } = new int?(); - public string? json { get; private set; } - public UserFrame? UserProfileFrame { get; } - - - - public GlobalProfile(JObject _json) - { - - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["userProfile"]["status"]; - itemsCount = (int)jsonObj["userProfile"]["itemsCount"]; - userId = (string)jsonObj["userProfile"]["uid"]; - modifiedTime = (string)jsonObj["userProfile"]["modifiedTime"]; - followingStatus = (int)jsonObj["userProfile"]["followingStatus"]; - onlineStatus = (int)jsonObj["userProfile"]["onlineStatus"]; - accountMembershipStatus = (int)jsonObj["userProfile"]["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["userProfile"]["isGlobal"]; - avatarFrameId = (string)jsonObj["userProfile"]["avatarFrameId"]; - reputation = (int)jsonObj["userProfile"]["reputation"]; - postsCount = (int)jsonObj["userProfile"]["postsCount"]; - memberCount = (int)jsonObj["userProfile"]["membersCount"]; - nickname = (string)jsonObj["userProfile"]["nickname"]; - iconUrl = (string)jsonObj["userProfile"]["icon"]; - isNicknameVerified = (bool)jsonObj["userProfile"]["isNicknameVerified"]; - visitorsCount = (int)jsonObj["userProfile"]["visitorsCount"]; - level = (int)jsonObj["userProfile"]["level"]; - notificationSubscriptionStatus = (int)jsonObj["userProfile"]["notificationSubscriptionStatus"]; - pushEnabled = (bool)jsonObj["userProfile"]["pushEnabled"]; - membershipStatus = (int)jsonObj["userProfile"]["membershipStatus"]; - content = (string)jsonObj["userProfile"]["content"]; - joinedCount = (int)jsonObj["userProfile"]["joinedCount"]; - role = (int)jsonObj["userProfile"]["role"]; - commentsCount = (int)jsonObj["userProfile"]["commentsCount"]; - aminoId = (string)jsonObj["userProfile"]["aminoId"]; - communityId = (string)jsonObj["userProfile"]["ndcId"]; - createdTime = (string)jsonObj["userProfile"]["createdTime"]; - visitPrivacy = (int)jsonObj["userProfile"]["visitPrivacy"]; - storiesCount = (int)jsonObj["userProfile"]["storiesCount"]; - blogsCount = (int)jsonObj["userProfile"]["blogsCount"]; - json = _json.ToString(); - UserProfileFrame = new UserFrame(_json); - - } - public class UserFrame - { - public int? status { get; private set; } = new int?(); - public int? ownershipStatus { get; private set; } = new int?(); - public int? version { get; private set; } = new int?(); - public string? resourceUrl { get; private set; } - public string? name { get; private set; } - public string? iconUrl { get; private set; } - public int? frameType { get; private set; } = new int?(); - public string? frameId { get; private set; } - - public UserFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["userProfile"]["avatarFrame"]["status"]; - ownershipStatus = (int)jsonObj["userProfile"]["avatarFrame"]["ownershipStatus"]; - version = (int)jsonObj["userProfile"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["userProfile"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["userProfile"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["userProfile"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["userProfile"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["userProfile"]["avatarFrame"]["frameId"]; - } - } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("itemsCount")]public int ItemsCount { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("followingStatus")]public int FollowingStatus { get; set; } + [JsonPropertyName("onlineStatus")]public int OnlineStatus { get; set; } + [JsonPropertyName("accountMembershipStatus")]public int AccountMembershipStatus { get; set; } + [JsonPropertyName("isGlobal")]public bool IsGlobal { get; set; } + [JsonPropertyName("avatarFrameId")]public string AvatarFrameId { get; set; } + [JsonPropertyName("reputation")]public int Reputation { get; set; } + [JsonPropertyName("postsCount")]public int PostsCount { get; set; } + [JsonPropertyName("membersCount")]public int MemberCount { get; set; } + [JsonPropertyName("nickname")]public string Nickname { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } + [JsonPropertyName("isNicknameVerified")]public bool IsNicknameVerified { get; set; } + [JsonPropertyName("visitorsCount")]public int VisitorsCount { get; set; } + [JsonPropertyName("level")]public int Level { get; set; } + [JsonPropertyName("notificationSubscriptionStatus")]public int NotificationSubscriptionStatus { get; set; } + [JsonPropertyName("pushEnabled")]public bool PushEnabled { get; set; } + [JsonPropertyName("membershipStatus")]public int MembershipStatus { get; set; } + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("joinedCount")]public int JoinedCount { get; set; } + [JsonPropertyName("role")]public int Role { get; set; } + [JsonPropertyName("commentsCount")]public int CommentsCount { get; set; } + [JsonPropertyName("aminoId")]public string AminoId { get; set; } + [JsonPropertyName("ndcId")]public string CommunityId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("visitPrivacy")]public int VisitPrivacy { get; set; } + [JsonPropertyName("storiesCount")]public int StoriesCount { get; set; } + [JsonPropertyName("blogsCount")]public int BlogsCount { get; set; } + [JsonPropertyName("avatarFrame")]public GenericAvatarFrame UserProfileFrame { get; set; } } From def723fd5310557d453102bf5eeec18507cd9faf Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Wed, 22 May 2024 02:27:54 +0200 Subject: [PATCH 11/19] refactored more objects --- Amino.NET/Client.cs | 2 +- Amino.NET/Objects/AdvancedCommunityInfo.cs | 2 +- Amino.NET/Objects/Blog.cs | 2 +- Amino.NET/Objects/Chat.cs | 2 +- Amino.NET/Objects/ChatAnnouncement.cs | 2 +- Amino.NET/Objects/ChatEvent.cs | 2 +- Amino.NET/Objects/ChatTip.cs | 2 +- Amino.NET/Objects/ChatTipToggle.cs | 2 +- Amino.NET/Objects/FromCode.cs | 2 +- Amino.NET/Objects/GenericMessage.cs | 27 ++++ Amino.NET/Objects/GenericMessageAuthor.cs | 18 +++ Amino.NET/Objects/GenericPostAuthor.cs | 20 +++ Amino.NET/Objects/GenericProfile.cs | 2 +- Amino.NET/Objects/LeftChatMember.cs | 49 ++----- Amino.NET/Objects/Message.cs | 53 ++------ Amino.NET/Objects/PagingInfo.cs | 15 ++ Amino.NET/Objects/Post.cs | 151 ++++----------------- Amino.NET/Objects/PostExtensions.cs | 15 ++ Amino.NET/Objects/SocketBase.cs | 1 + Amino.NET/Objects/TipInfo.cs | 18 +++ Amino.NET/Objects/chatMember.cs | 2 +- Amino.NET/Objects/messageCollection.cs | 121 +---------------- 22 files changed, 180 insertions(+), 330 deletions(-) create mode 100644 Amino.NET/Objects/GenericMessage.cs create mode 100644 Amino.NET/Objects/GenericMessageAuthor.cs create mode 100644 Amino.NET/Objects/GenericPostAuthor.cs create mode 100644 Amino.NET/Objects/PagingInfo.cs create mode 100644 Amino.NET/Objects/PostExtensions.cs create mode 100644 Amino.NET/Objects/TipInfo.cs diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 15bf303..8f2f980 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -970,7 +970,7 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } if (debug) { Trace.WriteLine(response.Content); } dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray chatMessageList = jsonObj["messageList"]; + JArray chatMessageList = jsonObj["messageList"]; // no need foreach (JObject chatMessage in chatMessageList) { Objects.MessageCollection message = new Objects.MessageCollection(chatMessage, JObject.Parse(response.Content)); diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs index 42ea6e8..846a074 100644 --- a/Amino.NET/Objects/AdvancedCommunityInfo.cs +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -14,7 +14,7 @@ public class AdvancedCommunityInfo // Base JSON key: community public bool IsCurrentUserJoined { get; set; } // MUST BE SET AFTER - public string json { get; set; } // MUST BE SET AFTER + public string Json { get; set; } // MUST BE SET AFTER [JsonPropertyName("searchable")] public bool Searchable { get; set; } [JsonPropertyName("isStandaloneAppDepricated")] public bool IsStandaloneAppDeprecated { get; set; } [JsonPropertyName("listedStatus")] public int ListedStatus { get; set; } diff --git a/Amino.NET/Objects/Blog.cs b/Amino.NET/Objects/Blog.cs index cc276e2..21a1a4f 100644 --- a/Amino.NET/Objects/Blog.cs +++ b/Amino.NET/Objects/Blog.cs @@ -11,7 +11,7 @@ namespace Amino.Objects { public class Blog { - public string json { get; set; } // NEEDS TO BE ADDED AFTER + public string Json { get; set; } // NEEDS TO BE ADDED AFTER [JsonPropertyName("globalVotesCount")]public int GlobalVotesCount { get; set; } = 0; [JsonPropertyName("globalVotedValue")]public int GlobalVotedValue { get; set; } = 0; [JsonPropertyName("votedValue")]public int VotedValue { get; set; } = 0; diff --git a/Amino.NET/Objects/Chat.cs b/Amino.NET/Objects/Chat.cs index badfd77..9e5a7ea 100644 --- a/Amino.NET/Objects/Chat.cs +++ b/Amino.NET/Objects/Chat.cs @@ -7,7 +7,7 @@ namespace Amino.Objects { public class Chat { - public string json { get; set; } // NEEDS TO BE ADDED LATER + public string Json { get; set; } // NEEDS TO BE ADDED LATER [JsonPropertyName("uid")]public string UserId { get; set; } [JsonPropertyName("membersQuota")]public int MembersQuota { get; set; } [JsonPropertyName("threadId")]public string ThreadId { get; set; } diff --git a/Amino.NET/Objects/ChatAnnouncement.cs b/Amino.NET/Objects/ChatAnnouncement.cs index e75aebe..9290b76 100644 --- a/Amino.NET/Objects/ChatAnnouncement.cs +++ b/Amino.NET/Objects/ChatAnnouncement.cs @@ -7,7 +7,7 @@ namespace Amino.Objects // ROOT JSON ELEMENT: o/chatMessage public class ChatAnnouncement { - public string json { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER [JsonPropertyName("threadId")]public string ChatId { get; set; } [JsonPropertyName("mediaType")]public int MediaType { get; set; } diff --git a/Amino.NET/Objects/ChatEvent.cs b/Amino.NET/Objects/ChatEvent.cs index 1eea757..f99febf 100644 --- a/Amino.NET/Objects/ChatEvent.cs +++ b/Amino.NET/Objects/ChatEvent.cs @@ -8,7 +8,7 @@ namespace Amino.Objects // ROOT JSON ELEMENT: o/chatMessage public class ChatEvent { - public string json { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER [JsonPropertyName("threadId")]public string ChatId { get; set; } diff --git a/Amino.NET/Objects/ChatTip.cs b/Amino.NET/Objects/ChatTip.cs index 000b341..6a4a43e 100644 --- a/Amino.NET/Objects/ChatTip.cs +++ b/Amino.NET/Objects/ChatTip.cs @@ -7,7 +7,7 @@ namespace Amino.Objects // ROOT JSON ELEMENT: o/chatMessage public class ChatTip { - public string json { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER [JsonPropertyName("threadId")]public string ChatId { get; set; } diff --git a/Amino.NET/Objects/ChatTipToggle.cs b/Amino.NET/Objects/ChatTipToggle.cs index 41e63e2..dbcdc40 100644 --- a/Amino.NET/Objects/ChatTipToggle.cs +++ b/Amino.NET/Objects/ChatTipToggle.cs @@ -8,7 +8,7 @@ namespace Amino.Objects // ROOT JSON ELEMENT: o/chatMessage public class ChatTipToggle { - public string json { get; set; } // NEEDS TO BE ADDED AFTER + public string Json { get; set; } // NEEDS TO BE ADDED AFTER public SocketBase SocketBase { get; set; } // NEEDS TO BE ADDED AFTER [JsonPropertyName("threadId")]public string ChatId { get; set; } diff --git a/Amino.NET/Objects/FromCode.cs b/Amino.NET/Objects/FromCode.cs index 520854c..d2cf870 100644 --- a/Amino.NET/Objects/FromCode.cs +++ b/Amino.NET/Objects/FromCode.cs @@ -8,7 +8,7 @@ namespace Amino.Objects // ROOT JSON ELEMENT: linkInfoV2 public class FromCode { - public string json { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER [JsonPropertyName("path")]public string Path { get; set; } [JsonPropertyName("extensions")]public LinkInfoExtensions Extensions { get; set; } diff --git a/Amino.NET/Objects/GenericMessage.cs b/Amino.NET/Objects/GenericMessage.cs new file mode 100644 index 0000000..845f3ba --- /dev/null +++ b/Amino.NET/Objects/GenericMessage.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + + public class GenericMessage + { + [JsonPropertyName("includedInSummary")] public bool IncludedInSummary { get; set; } + [JsonPropertyName("uid")] public string AuthorId { get; set; } + [JsonPropertyName("isHidden")] public bool IsHidden { get; set; } + [JsonPropertyName("messageId")] public string MessageId { get; set; } + [JsonPropertyName("mediaType")] public int MediaType { get; set; } + [JsonPropertyName("content")] public string Content { get; set; } + [JsonPropertyName("chatBubbleId")] public string ChatBubbleId { get; set; } + [JsonPropertyName("clientRefId")] public int ClientRefId { get; set; } + [JsonPropertyName("threadId")] public string ChatId { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("type")] public int Type { get; set; } + [JsonPropertyName("mediaUrl")] public string MediaUrl { get; set; } + [JsonPropertyName("author")] public GenericProfile Author { get; set; } + } +} diff --git a/Amino.NET/Objects/GenericMessageAuthor.cs b/Amino.NET/Objects/GenericMessageAuthor.cs new file mode 100644 index 0000000..cbb6c8c --- /dev/null +++ b/Amino.NET/Objects/GenericMessageAuthor.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class GenericMessageAuthor + { + [JsonPropertyName("nickname")] public string Nickname { get; set; } + [JsonPropertyName("uid")] public string UserId { get; set; } + [JsonPropertyName("level")] public int Level { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + [JsonPropertyName("reputation")] public int Reputation { get; set; } + } +} diff --git a/Amino.NET/Objects/GenericPostAuthor.cs b/Amino.NET/Objects/GenericPostAuthor.cs new file mode 100644 index 0000000..874b3e1 --- /dev/null +++ b/Amino.NET/Objects/GenericPostAuthor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class GenericPostAuthor + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("uid")] public string UserId { get; set; } + [JsonPropertyName("isGlobal")] public bool IsGlobal { get; set; } + [JsonPropertyName("role")] public int Role { get; set; } + [JsonPropertyName("isStaff")] public bool IsStaff { get; set; } + [JsonPropertyName("nickname")] public string Nickname { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + } +} diff --git a/Amino.NET/Objects/GenericProfile.cs b/Amino.NET/Objects/GenericProfile.cs index 4666a7b..902b243 100644 --- a/Amino.NET/Objects/GenericProfile.cs +++ b/Amino.NET/Objects/GenericProfile.cs @@ -6,7 +6,7 @@ namespace Amino.Objects { public class GenericProfile // ROOT JSON ELEMENT: userProfile { - public string json { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER [JsonPropertyName("status")]public int Status { get; set; } [JsonPropertyName("isNicknameVerified")]public bool IsNicknameVerified { get; set; } [JsonPropertyName("uid")]public string UserId { get; set; } diff --git a/Amino.NET/Objects/LeftChatMember.cs b/Amino.NET/Objects/LeftChatMember.cs index fb4200c..1346590 100644 --- a/Amino.NET/Objects/LeftChatMember.cs +++ b/Amino.NET/Objects/LeftChatMember.cs @@ -1,46 +1,23 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class LeftChatMember { - public int _type { get; } - public int alertOption { get; } - public int membershipStatus { get; } - public int communityId { get; } + public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER - public string chatId { get; } - public int mediaType { get; } - public int clientrefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - - public LeftChatMember(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - communityId = (int)jsonObj["o"]["ndcId"]; - - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientrefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - - } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } } } diff --git a/Amino.NET/Objects/Message.cs b/Amino.NET/Objects/Message.cs index 91df94d..591ea9c 100644 --- a/Amino.NET/Objects/Message.cs +++ b/Amino.NET/Objects/Message.cs @@ -1,56 +1,21 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { //MediaType: 0 - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class Message { - public string? content { get; private set; } - public string? messageId { get; private set; } - public string? chatId { get; private set; } - public string? objectId { get; private set; } - public string? json { get; private set; } - public int? communityId { get; private set; } - public string? chatBubbleId { get; private set; } - public _Author? Author { get; } - - public Message(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { Author = new _Author(_json); } catch { } - try { content = (string)jsonObj["o"]["chatMessage"]["content"]; } catch { } - try { messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; } catch { } - try { chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; }catch{ } - try { objectId = (string)jsonObj["o"]["chatMessage"]["uid"]; } catch { } - json = _json.ToString(); - try { communityId = (int)jsonObj["o"]["ndcId"]; } catch { } - try { chatBubbleId = (string)jsonObj["o"]["chatBubbleId"]; }catch{ } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string? userName { get; } - public string? userId { get; } - public int? userLevel { get; } - public string? iconUrl { get; } - public int? userReputation { get; } - public string? frameId { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { userName = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; } catch { } - try { userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; } catch { } - try { userLevel = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; } catch { } - try { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } catch { } - try { userReputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; } catch { } - try { frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; } catch { } - } - } + public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER + public string Json { get; set; } // NEEDS TO BE SET AFTER + [JsonPropertyName("content")] public string Content { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("uid")]public string ObjectId { get; set; } + [JsonPropertyName("author")]public GenericMessageAuthor Author { get; set; } } } diff --git a/Amino.NET/Objects/PagingInfo.cs b/Amino.NET/Objects/PagingInfo.cs new file mode 100644 index 0000000..dca422b --- /dev/null +++ b/Amino.NET/Objects/PagingInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class PagingInfo + { + [JsonPropertyName("nextPageToken")] public string NextPageToken { get; set; } + [JsonPropertyName("prevPageToken")] public string PrevPageToken { get; set; } + } +} diff --git a/Amino.NET/Objects/Post.cs b/Amino.NET/Objects/Post.cs index c792a08..1f1fca4 100644 --- a/Amino.NET/Objects/Post.cs +++ b/Amino.NET/Objects/Post.cs @@ -1,132 +1,39 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class Post { - public int globalVotesCount { get; } - public int globalVotedValue { get; } - public int votedValue { get; } - public string keywords { get; } - public bool isGlobalAnnouncement { get; } - public int style { get; } - public int totalQuizPlayCount { get; } - public string title { get; } - public int contentRating { get; } - public string content { get; } - public bool needHidden { get; } - public int guestVotesCount { get; } - public int type { get; } - public int status { get; } - public int globalCommentsCount { get; } - public string modifiedTime { get; } - public int totalPollVoteCount { get; } - public string postId { get; } - public string shareURLFullPath { get; } - public int viewCount { get; } - public int votesCount { get; } - public int communityId { get; } - public string createdTime { get; } - public string endTime { get; } - public int commentsCount { get; } - public string json { get; } - public _TipInfo TipInfo { get; } - public _Author Author { get; } - public _Extensions Extensions { get; } - - - public Post(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - globalVotesCount = (int)jsonObj["globalVotesCount"]; - globalVotedValue = (int)jsonObj["globalVotedValue"]; - votedValue = (int)jsonObj["votedValue"]; - if(jsonObj["keywords"] != null) { keywords = (string)jsonObj["keywords"]; } - isGlobalAnnouncement = (bool)jsonObj["isGlobalAnnouncement"]; - style = (int)jsonObj["style"]; - totalQuizPlayCount = (int)jsonObj["totalQuizPlayCount"]; - title = (string)jsonObj["title"]; - contentRating = (int)jsonObj["contentRating"]; - content = (string)jsonObj["content"]; - needHidden = (bool)jsonObj["needHidden"]; - guestVotesCount = (int)jsonObj["guestVotesCount"]; - type = (int)jsonObj["type"]; - status = (int)jsonObj["status"]; - globalCommentsCount = (int)jsonObj["globalCommentsCount"]; - modifiedTime = (string)jsonObj["modifiedTime"]; - totalPollVoteCount = (int)jsonObj["totalPollVoteCount"]; - postId = (string)jsonObj["blogId"]; - shareURLFullPath = (string)jsonObj["shareURLFullPath"]; - viewCount = (int)jsonObj["viewCount"]; - votesCount = (int)jsonObj["votesCount"]; - communityId = (int)jsonObj["ndcId"]; - createdTime = (string)jsonObj["createdTime"]; - if(jsonObj["endTime"] != null) { endTime = (string)jsonObj["endTime"]; } - commentsCount = (int)jsonObj["commentsCount"]; - json = _json.ToString(); - TipInfo = new _TipInfo(_json); - Author = new _Author(_json); - Extensions = new _Extensions(_json); - - } - - public class _TipInfo - { - public int tipMaxCoin { get; } - public int tippersCount { get; } - public bool tippable { get; } - public int tipMinCoin { get; } - public int tippedCoins { get; } - - public _TipInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - tipMaxCoin = (int)jsonObj["tipInfo"]["tipMaxCoin"]; - tippersCount = (int)jsonObj["tipInfo"]["tippersCount"]; - tippable = (bool)jsonObj["tipInfo"]["tippable"]; - System.Console.WriteLine("Check 5"); - tipMinCoin = (int)jsonObj["tipInfo"]["tipMinCoin"]; - tippedCoins = (int)jsonObj["tipInfo"]["tippedCoins"]; - } - } - - public class _Author - { - public int status { get; } - public string userId { get; } - public bool isGlobal { get; } - public int role { get; } - public bool isStaff { get; } - public string nickname { get; } - public string iconUrl { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["author"]["status"]; - userId = (string)jsonObj["author"]["uid"]; - isGlobal = (bool)jsonObj["author"]["isGlobal"]; - role = (int)jsonObj["author"]["role"]; - if (jsonObj["author"]["isStaff"] != null) { isStaff = (bool)jsonObj["author"]["isStaff"]; } - nickname = (string)jsonObj["author"]["nickname"]; - if(jsonObj["author"]["icon"] != null) { iconUrl = (string)jsonObj["author"]["icon"]; } - } - } - - public class _Extensions - { - public bool commentEnabled { get; } - public string author { get; } - - public _Extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - commentEnabled = (bool)jsonObj["extensions"]["commentEnabled"]; - author = (string)jsonObj["extensions"]["author"]; - } - } + [JsonPropertyName("globalVotesCount")]public int GlobalVotesCount { get; set; } + [JsonPropertyName("globalVotedValue")]public int GlobalVotedValue { get; set; } + [JsonPropertyName("votedValue")]public int VotedValue { get; set; } + [JsonPropertyName("keywords")]public string Keywords { get; set; } + [JsonPropertyName("isGlobalAnnouncement")]public bool IsGlobalAnnouncement { get; set; } + [JsonPropertyName("style")]public int Style { get; set; } + [JsonPropertyName("totalQuizPlayCount")]public int TotalQuizPlayCount { get; set; } + [JsonPropertyName("title")]public string Title { get; set; } + [JsonPropertyName("contentRating")]public int ContentRating { get; set; } + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("needHidden")]public bool NeedHidden { get; set; } + [JsonPropertyName("guestVotesCount")]public int GuestVotesCount { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("globalCommentsCount")]public int GlobalCommentsCount { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("totalPollVotesCount")]public int TotalPollVoteCount { get; set; } + [JsonPropertyName("blogId")]public string BlogId { get; set; } + [JsonPropertyName("shareURLFullPath")]public string ShareURLFullPath { get; set; } + [JsonPropertyName("viewCount")]public int ViewCount { get; set; } + [JsonPropertyName("votesCount")]public int VotesCount { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("endTime")]public string EndTime { get; set; } + [JsonPropertyName("commentsCount")]public int commentsCount { get; set; } + [JsonPropertyName("tipInfo")]public TipInfo TipInfo { get; set; } + [JsonPropertyName("author")]public GenericPostAuthor Author { get; set; } + [JsonPropertyName("extensions")]public PostExtensions Extensions { get; set; } } } diff --git a/Amino.NET/Objects/PostExtensions.cs b/Amino.NET/Objects/PostExtensions.cs new file mode 100644 index 0000000..9045361 --- /dev/null +++ b/Amino.NET/Objects/PostExtensions.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class PostExtensions + { + [JsonPropertyName("commentEnabled")] public bool CommentsEnabled { get; set; } + [JsonPropertyName("author")] public string Author { get; set; } + } +} diff --git a/Amino.NET/Objects/SocketBase.cs b/Amino.NET/Objects/SocketBase.cs index 8ae3fd8..f6c48d2 100644 --- a/Amino.NET/Objects/SocketBase.cs +++ b/Amino.NET/Objects/SocketBase.cs @@ -12,5 +12,6 @@ public class SocketBase [JsonPropertyName("alertOption")] public int AlertOption { get; set; } [JsonPropertyName("membershipStatus")] public int MembershipStatus { get; set; } [JsonPropertyName("ndcId")] public int CommunityId { get; set; } + [JsonPropertyName("chatBubbleId")] public string ChatBubbleId { get; set; } } } diff --git a/Amino.NET/Objects/TipInfo.cs b/Amino.NET/Objects/TipInfo.cs new file mode 100644 index 0000000..82c0158 --- /dev/null +++ b/Amino.NET/Objects/TipInfo.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class TipInfo + { + [JsonPropertyName("tipMaxCoin")] public int TipMaxCoin { get; set; } + [JsonPropertyName("tippersCount")] public int TipperCount { get; set; } + [JsonPropertyName("tippable")] public bool Tippable { get; set; } + [JsonPropertyName("tipMinCoin")] public int TipMinCoin { get; set; } + [JsonPropertyName("tippedCoins")] public int TippedCoins { get; set; } + } +} diff --git a/Amino.NET/Objects/chatMember.cs b/Amino.NET/Objects/chatMember.cs index 620d1bb..a7d9a71 100644 --- a/Amino.NET/Objects/chatMember.cs +++ b/Amino.NET/Objects/chatMember.cs @@ -11,7 +11,7 @@ namespace Amino.Objects { public class ChatMember { - public string json { get; set; } // NEEDS TO BE ADDED AFTER + public string Json { get; set; } // NEEDS TO BE ADDED AFTER [JsonPropertyName("status")]public int Status { get; set; } [JsonPropertyName("isNicknameVerified")]public bool IsNicknameVerified { get; set; } [JsonPropertyName("uid")]public string UserId { get; set; } diff --git a/Amino.NET/Objects/messageCollection.cs b/Amino.NET/Objects/messageCollection.cs index bf3afbf..c4db8ab 100644 --- a/Amino.NET/Objects/messageCollection.cs +++ b/Amino.NET/Objects/messageCollection.cs @@ -1,126 +1,13 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class MessageCollection { - public bool includedInSummary { get; private set; } - public string authorId { get; private set; } - public bool isHidden { get; private set; } - public string messageId { get; private set; } - public int mediaType { get; private set; } - public string content { get; private set; } - public string chatBubbleId { get; private set; } - public int clientRefId { get; private set; } - public string chatId { get; private set; } - public string createdTime { get; private set; } - public int type { get; private set; } - public string mediaUrl { get; private set; } - public string json { get; private set; } - public _Author? Author { get; } - public _Paging? Paging { get; } - - public MessageCollection(JObject _json, JObject _fullJson) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - includedInSummary = (bool)jsonObj["includedInSummary"]; - authorId = (string)jsonObj["uid"]; - isHidden = (bool)jsonObj["isHidden"]; - messageId = (string)jsonObj["messageId"]; - mediaType = (int)jsonObj["mediaType"]; - content = (string)jsonObj["content"]; - chatBubbleId = (string)jsonObj["chatBubbleId"]; - clientRefId = (int)jsonObj["clientRefId"]; - chatId = (string)jsonObj["threadId"]; - createdTime = (string)jsonObj["createdTime"]; - type = (int)jsonObj["type"]; - mediaUrl = (string)jsonObj["mediaValue"]; - json = _json.ToString(); - Paging = new _Paging(_fullJson); - Author = new _Author(_json); - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Paging - { - public string nextPageToken { get; private set; } - public string prevPageToken { get; private set; } - - public _Paging(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - - nextPageToken = (string)jsonObj["paging"]["nextPageToken"]; - prevPageToken = (string)jsonObj["paging"]["prevPageToken"]; - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public int status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int membershipStatus { get; private set; } - public string avatarFrameId { get; private set; } - public int reputation { get; private set; } - public int role { get; private set; } - public string aminoId { get; private set; } - public int communityId { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - public _avatarFrame AvatarFrame { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["author"]["status"]; - isNicknameVerified = (bool)jsonObj["author"]["isNicknameVerified"]; - userId = (string)jsonObj["author"]["uid"]; - level = (int)jsonObj["author"]["level"]; - followingStatus = (int)jsonObj["author"]["followingStatus"]; - accountMembershipStatus = (int)jsonObj["author"]["accountMembershipStatus"]; - avatarFrameId = (string)jsonObj["author"]["avatarFrameId"]; - reputation = (int)jsonObj["author"]["reputation"]; - role = (int)jsonObj["author"]["role"]; - aminoId = (string)jsonObj["author"]["aminoId"]; - communityId = (int)jsonObj["author"]["ndcId"]; - membersCount = (int)jsonObj["author"]["membersCount"]; - nickname = (string)jsonObj["author"]["nickname"]; - iconUrl = (string)jsonObj["author"]["icon"]; - if(jsonObj["author"]["avatarFrame"] != null) { AvatarFrame = new _avatarFrame(_json); } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _avatarFrame - { - public int status { get; private set; } - public int version { get; private set; } - public string resourceUrl { get; private set; } - public string name { get; private set; } - public string iconUrl { get; private set; } - public int frameType { get; private set; } - public string frameId { get; private set; } - - public _avatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["author"]["avatarFrame"]["frameId"]; - } - } - } + [JsonPropertyName("messageList")]public List Messages { get; set; } + [JsonPropertyName("paging")]public PagingInfo Paging { get; set; } } } From decfd27cc65dc73486a7cee3bca75035c8c84434 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Thu, 23 May 2024 09:19:57 +0200 Subject: [PATCH 12/19] refactored more objects --- Amino.NET/Events/EventHandler.cs | 6 +- Amino.NET/Objects/DeviceInfo.cs | 14 ++ Amino.NET/Objects/GenericAuthorExtensions.cs | 23 ++ Amino.NET/Objects/GenericProfile.cs | 1 + Amino.NET/Objects/SpecialChatEvent.cs | 128 ++--------- Amino.NET/Objects/Sticker.cs | 25 +++ Amino.NET/Objects/StickerCollectionSummary.cs | 23 ++ Amino.NET/Objects/StickerMessage.cs | 212 ++---------------- .../Objects/UserAccountAdvancedSettings.cs | 14 ++ Amino.NET/Objects/UserAccountExtensions.cs | 21 ++ Amino.NET/Objects/UserAchievements.cs | 14 +- Amino.NET/Objects/userAccount.cs | 48 ++-- 12 files changed, 184 insertions(+), 345 deletions(-) create mode 100644 Amino.NET/Objects/DeviceInfo.cs create mode 100644 Amino.NET/Objects/GenericAuthorExtensions.cs create mode 100644 Amino.NET/Objects/Sticker.cs create mode 100644 Amino.NET/Objects/StickerCollectionSummary.cs create mode 100644 Amino.NET/Objects/UserAccountAdvancedSettings.cs create mode 100644 Amino.NET/Objects/UserAccountExtensions.cs diff --git a/Amino.NET/Events/EventHandler.cs b/Amino.NET/Events/EventHandler.cs index c5c3d99..5d8cc11 100644 --- a/Amino.NET/Events/EventHandler.cs +++ b/Amino.NET/Events/EventHandler.cs @@ -28,12 +28,12 @@ public Task ReceiveEvent(JObject webSocketMessage, Client client) try { JsonElement root = JsonDocument.Parse(webSocketMessage.ToString()).RootElement; - SocketBase sBase = System.Text.Json.JsonSerializer.Deserialize(root.GetProperty("o")); dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(webSocketMessage.ToString()); if(jsonObj["o"]["chatMessage"]["mediaType"] != null) { - - switch((int)jsonObj["o"]["chatMessage"]["mediaType"]) + + SocketBase sBase = System.Text.Json.JsonSerializer.Deserialize(root.GetProperty("o")); + switch ((int)jsonObj["o"]["chatMessage"]["mediaType"]) { case 0: //TextMessage / MessageDeleted / ChatMember Left, ChatMember Joined / ChatBackground changed / ChatTitle changed / ChatContent chaaged / ChatAnnouncementPin / ChatAnnouncementUnpin / ChatViewOnlyOn / ChatViewOnlyOff / ChatTipEnabled / ChatTipDisabled / MessageForceRemoved / ChatTip switch((int)jsonObj["o"]["chatMessage"]["type"]) diff --git a/Amino.NET/Objects/DeviceInfo.cs b/Amino.NET/Objects/DeviceInfo.cs new file mode 100644 index 0000000..771e68e --- /dev/null +++ b/Amino.NET/Objects/DeviceInfo.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class DeviceInfo + { + [JsonPropertyName("lastClientType")] public int LastClientType { get; set; } + } +} diff --git a/Amino.NET/Objects/GenericAuthorExtensions.cs b/Amino.NET/Objects/GenericAuthorExtensions.cs new file mode 100644 index 0000000..51f4bb5 --- /dev/null +++ b/Amino.NET/Objects/GenericAuthorExtensions.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class GenericAuthorExtensions + { + /// + /// The ID of the original sticker + /// NOTE: this might only be availabe in the context of a + /// + [JsonPropertyName("originalStickerId")] public string OriginalStickerId { get; set; } + /// + /// The Sticker object related to this Extensions object + /// NOTE: this might only be availabe in the context of a + /// + [JsonPropertyName("sticker")] public Sticker Sticker { get; set; } + } +} diff --git a/Amino.NET/Objects/GenericProfile.cs b/Amino.NET/Objects/GenericProfile.cs index 902b243..d5ac7e9 100644 --- a/Amino.NET/Objects/GenericProfile.cs +++ b/Amino.NET/Objects/GenericProfile.cs @@ -24,6 +24,7 @@ public class GenericProfile // ROOT JSON ELEMENT: userProfile [JsonPropertyName("avatarFrame")] public GenericAvatarFrame AvatarFrame { get; set; } [JsonPropertyName("influencerInfo")] public InfluencerPriceInfo InfluencerInfo { get; set; } + [JsonPropertyName("extensions")] public GenericAuthorExtensions Extensions { get; set; } } } diff --git a/Amino.NET/Objects/SpecialChatEvent.cs b/Amino.NET/Objects/SpecialChatEvent.cs index 5c4a874..f35c09d 100644 --- a/Amino.NET/Objects/SpecialChatEvent.cs +++ b/Amino.NET/Objects/SpecialChatEvent.cs @@ -1,124 +1,26 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class SpecialChatEvent { - - public int _type { get; } - public int communityId { get; } - public int alertOption { get; } - public int membershipStatus { get; } - - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - public _Author Author { get; } - - public SpecialChatEvent(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - communityId = (int)jsonObj["o"]["ndcId"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - Author = new _Author(_json); - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; - status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; - if (jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } - reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; - role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; - nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; - level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; - accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; - if (jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if (jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - - - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - } - + public SocketBase SocketBase { get; set; } + public string Json { get; set; } + + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string ObjectId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } diff --git a/Amino.NET/Objects/Sticker.cs b/Amino.NET/Objects/Sticker.cs new file mode 100644 index 0000000..f728809 --- /dev/null +++ b/Amino.NET/Objects/Sticker.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class Sticker + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("iconV2")] public string IconV2Url { get; set; } + [JsonPropertyName("stickerId")] public string StickerId { get; set; } + [JsonPropertyName("smallIconV2")] public string SmallIconV2Url { get; set; } + [JsonPropertyName("smallIcon")] public string SmallIconUrl { get; set; } + [JsonPropertyName("stickerCollectionId")] public string StickerCollectionId { get; set; } + [JsonPropertyName("mediumIcon")] public string MediumIconUrl { get; set; } + [JsonPropertyName("usedCount")] public int UsedCount { get; set; } + [JsonPropertyName("mediumIconV2")] public string MediumIconV2Url { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + [JsonPropertyName("stickerCollectionSummary")] StickerCollectionSummary StickerCollectionSummary { get; set; } + } +} diff --git a/Amino.NET/Objects/StickerCollectionSummary.cs b/Amino.NET/Objects/StickerCollectionSummary.cs new file mode 100644 index 0000000..6f6423c --- /dev/null +++ b/Amino.NET/Objects/StickerCollectionSummary.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class StickerCollectionSummary + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("collectionType")] public int CollectionType { get; set; } + [JsonPropertyName("uid")] public string ObjectId { get; set; } + [JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; } + [JsonPropertyName("smallIcon")] public string SmallIconUrl { get; set; } + [JsonPropertyName("usedCount")] public int UsedCount { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + [JsonPropertyName("name")] public string Name { get; set; } + [JsonPropertyName("collectionId")] public string CollectionId { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + } +} diff --git a/Amino.NET/Objects/StickerMessage.cs b/Amino.NET/Objects/StickerMessage.cs index db70a29..7062fad 100644 --- a/Amino.NET/Objects/StickerMessage.cs +++ b/Amino.NET/Objects/StickerMessage.cs @@ -1,203 +1,27 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class StickerMessage { - public int _type { get; } - public int communityId { get; } - public int alertOption { get; } - public int membershipStatus { get; } - - public string mediaValue { get; } - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string chatBubbleId { get; } - public int chatBubbleVersion { get; } - public string json { get; } - public _Author Author { get; } - public _Extensions Extensions { get; } - - public StickerMessage(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - communityId = (int)jsonObj["o"]["ndcId"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - - - mediaValue = (string)jsonObj["o"]["chatMessage"]["mediaValue"]; - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - chatBubbleId = (string)jsonObj["o"]["chatMessage"]["chatBubbleId"]; - chatBubbleVersion = (int)jsonObj["o"]["chatMessage"]["chatBubbleVersion"]; - if (jsonObj["o"]["chatMessage"]["author"] != null) { Author = new _Author(_json); } - if (jsonObj["o"]["chatMessage"]["extensions"] != null) { Extensions = new _Extensions(_json); } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Extensions - { - public string originalStickerId { get; } - public _Sticker Sticker { get; } - - public _Extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - originalStickerId = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["originalStickerId"]; - Sticker = new _Sticker(_json); - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Sticker - { - public int status { get; } - public string iconV2Url { get; } - public string stickerId { get; } - public string smallIconV2Url { get; } - public string smallIconUrl { get; } - public string stickerCollectionId { get; } - public string mediumIconUrl { get; } - public int usedCount { get; } - public string mediumIconV2Url { get; } - public string createdTime { get; } - public string iconUrl { get; } - public _StickerCollectionSummary StickerCollectionSummary { get; } - - - public _Sticker(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["status"]; - iconV2Url = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["iconV2"]; - stickerId = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerId"]; - smallIconV2Url = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["smallIconV2"]; - smallIconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["smallIcon"]; - stickerCollectionId = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionId"]; - mediumIconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["mediumIcon"]; - usedCount = (int)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["usedCount"]; - mediumIconV2Url = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["mediumIconV2"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["createdTime"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["icon"]; - StickerCollectionSummary = new _StickerCollectionSummary(_json); - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _StickerCollectionSummary - { - public int status { get; } - public int collectionType { get; } - public string userId { get; } - public string modifiedTime { get; } - public string smallIconUrl { get; } - public int usedCount { get; } - public string iconUrl { get; } - public string name { get; } - public string collectionId { get; } - public string createdTime { get; } - - public _StickerCollectionSummary(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["status"]; - collectionType = (int)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["collectionType"]; - userId = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["uid"]; - modifiedTime = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["modifiedTime"]; - smallIconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["smallIcon"]; - usedCount = (int)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["usedCount"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["icon"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["name"]; - collectionId = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["collectionId"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["author"]["extensions"]["sticker"]["stickerCollectionSummary"]["createdTime"]; - } - } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; - status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; - if(jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } - reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; - role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; - nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; - level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; - accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; - if(jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if(jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; - - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - } + public SocketBase SocketBase { get; set; } + public string Json { get; set; } + + [JsonPropertyName("mediaValue")]public string MediaValue { get; set; } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + [JsonPropertyName("chatBubbleId")]public string ChatBubbleId { get; set; } + [JsonPropertyName("chatBubbleVersion")]public int ChatBubbleVersion { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/UserAccountAdvancedSettings.cs b/Amino.NET/Objects/UserAccountAdvancedSettings.cs new file mode 100644 index 0000000..c146e98 --- /dev/null +++ b/Amino.NET/Objects/UserAccountAdvancedSettings.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class UserAccountAdvancedSettings + { + [JsonPropertyName("analyticsEnabled")] public int AnalyticsEnabled { get; set; } + } +} diff --git a/Amino.NET/Objects/UserAccountExtensions.cs b/Amino.NET/Objects/UserAccountExtensions.cs new file mode 100644 index 0000000..e048320 --- /dev/null +++ b/Amino.NET/Objects/UserAccountExtensions.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + public class UserAccountExtensions + { + [JsonPropertyName("contentLanguage")] public string ContentLanguage { get; set; } + [JsonPropertyName("adsFlags")] public int AdsFlags { get; set; } + [JsonPropertyName("adsLevel")] public int AdsLevel { get; set; } + [JsonPropertyName("mediaLabAdsMigrationJuly2018")] public bool MediaLabAdsMigrationJuly2018 { get; set; } + [JsonPropertyName("avatarFrameId")] public string AvatarFrameId { get; set; } + [JsonPropertyName("mediaLabAdsMigrationAugust2020")] public bool MediaLabAdsMigrationAugust2020 { get; set; } + [JsonPropertyName("adsEnabled")] public bool AdsEnabled { get; set; } + [JsonPropertyName("deviceInfo")] DeviceInfo DeviceInfo { get; set; } + } +} diff --git a/Amino.NET/Objects/UserAchievements.cs b/Amino.NET/Objects/UserAchievements.cs index 866cf42..b147245 100644 --- a/Amino.NET/Objects/UserAchievements.cs +++ b/Amino.NET/Objects/UserAchievements.cs @@ -3,22 +3,14 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace Amino.Objects { public class UserAchievements { - public int numberOfMembersCount { get; } = 0; - public int numberOfPostsCreated { get; } = 0; - public string json { get; } - - public UserAchievements(JObject json) - { - this.json = json.ToString(); - - try { numberOfMembersCount = (int)json["numberOfMembersCount"]; } catch { } - try { numberOfPostsCreated = (int)json["numberOfPostsCreated"]; } catch { } - } + [JsonPropertyName("numberOfMembersCount")]public int NumberOfMembersCount { get; set; } + [JsonPropertyName("numberOfPostsCreated")]public int NumberOfPostsCreated { get; set; } } } diff --git a/Amino.NET/Objects/userAccount.cs b/Amino.NET/Objects/userAccount.cs index de6f2de..8faa13a 100644 --- a/Amino.NET/Objects/userAccount.cs +++ b/Amino.NET/Objects/userAccount.cs @@ -1,34 +1,34 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: account public class UserAccount { - public string userName { get; private set; } - public int? status { get; private set; } - public string userId { get; private set; } - public string modifiedTime { get; private set; } - public string twitterID { get; private set; } - public int? activation { get; private set; } - public int? phoneNumberActivation { get; private set; } - public int? emailActivation { get; private set; } - public string appleID { get; private set; } - public string facebookID { get; private set; } - public string nickName { get; private set; } - public string googleID { get; private set; } - public string iconUrl { get; private set; } - public int? securityLevel { get; private set; } - public string phoneNumber { get; private set; } - public int? role { get; private set; } - public bool aminoIdEditable { get; private set; } = false; - public string aminoId { get; private set; } - public string createdTime { get; private set; } - public string email { get; private set; } - public string json { get; private set; } - public _AdvancedSettings AdvancedSettings { get; } - public _Extensions Extensions { get; } + [JsonPropertyName("username")]public string Username { get; set; } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("twitterID")]public string TwitterId { get; set; } + [JsonPropertyName("activation")]public int Activation { get; set; } + [JsonPropertyName("phoneNumberActivation")]public int PhoneNumberActivation { get; set; } + [JsonPropertyName("emailActivation")]public int EmailActivation { get; set; } + [JsonPropertyName("appleID")]public string AppleId { get; set; } + [JsonPropertyName("facebookID")]public string FacebookId { get; set; } + [JsonPropertyName("nickname")]public string Nickname { get; set; } + [JsonPropertyName("googleID")]public string GoogleId { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } + [JsonPropertyName("securityLevel")]public int SecurityLevel { get; set; } + [JsonPropertyName("phoneNumber")]public string PhoneNumber { get; set; } + [JsonPropertyName("role")]public int Role { get; set; } + [JsonPropertyName("aminoIdEditable")]public bool AminoIdEditable { get; set; } + [JsonPropertyName("aminoId")]public string AminoId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("email")]public string Email { get; set; } + [JsonPropertyName("advancedSettings")]public UserAccountAdvancedSettings AdvancedSettings { get; set; } + [JsonPropertyName("extensions")]public UserAccountExtensions Extensions { get; set; } public UserAccount(JObject _json) { From 4857a812a6b8f8ed92258669546f672b8e19edbb Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Thu, 23 May 2024 12:06:08 +0200 Subject: [PATCH 13/19] finalized new objects --- Amino.NET/Objects/AdditionalItemBenefits.cs | 7 +- Amino.NET/Objects/AdvancedCommunityInfo.cs | 9 +- Amino.NET/Objects/AvatarFrame.cs | 4 +- Amino.NET/Objects/AvatarFrameConfig.cs | 7 +- Amino.NET/Objects/Blog.cs | 9 +- Amino.NET/Objects/Chat.cs | 4 +- Amino.NET/Objects/ChatAnnouncement.cs | 4 +- Amino.NET/Objects/ChatEvent.cs | 4 +- Amino.NET/Objects/ChatExtensions.cs | 7 +- Amino.NET/Objects/ChatTip.cs | 4 +- Amino.NET/Objects/ChatTipExtensions.cs | 7 +- Amino.NET/Objects/ChatTipToggle.cs | 4 +- Amino.NET/Objects/CoinHistoryEntry.cs | 4 +- Amino.NET/Objects/Comment.cs | 4 +- Amino.NET/Objects/Community.cs | 4 +- .../Objects/CommunityAdvancedSettings.cs | 6 +- Amino.NET/Objects/CommunityInfo.cs | 5 +- Amino.NET/Objects/CommunityNewsFeed.cs | 7 +- Amino.NET/Objects/CommunityRankingTable.cs | 7 +- Amino.NET/Objects/CommunityThemePack.cs | 8 +- Amino.NET/Objects/CurrentUserInfo.cs | 7 +- Amino.NET/Objects/DeletedMessage.cs | 4 +- Amino.NET/Objects/DeviceInfo.cs | 7 +- Amino.NET/Objects/FromCode.cs | 5 +- Amino.NET/Objects/FromInvite.cs | 5 +- Amino.NET/Objects/GenericAuthorExtensions.cs | 7 +- Amino.NET/Objects/GenericAvatarFrame.cs | 7 +- Amino.NET/Objects/GenericChatMember.cs | 7 +- Amino.NET/Objects/GenericMessage.cs | 7 +- Amino.NET/Objects/GenericMessageAuthor.cs | 7 +- Amino.NET/Objects/GenericPostAuthor.cs | 7 +- Amino.NET/Objects/GenericProfile.cs | 4 +- Amino.NET/Objects/GenericProfileExtensions.cs | 9 ++ Amino.NET/Objects/ImageMessage.cs | 4 +- Amino.NET/Objects/InfluencerFanClubMember.cs | 7 +- Amino.NET/Objects/InfluencerInfo.cs | 3 +- Amino.NET/Objects/InfluencerPriceInfo.cs | 7 +- Amino.NET/Objects/Invitation.cs | 7 +- Amino.NET/Objects/InviteCode.cs | 4 +- Amino.NET/Objects/ItemOwnershipInfo.cs | 8 +- Amino.NET/Objects/ItemRestrictionInfo.cs | 7 +- Amino.NET/Objects/JoinedChatMember.cs | 4 +- Amino.NET/Objects/LastChatMessageSummary.cs | 7 +- Amino.NET/Objects/LeftChatMember.cs | 4 +- Amino.NET/Objects/LinkInfo.cs | 7 +- Amino.NET/Objects/LinkInfoExtensions.cs | 7 +- Amino.NET/Objects/Membership.cs | 7 +- Amino.NET/Objects/MembershipInfo.cs | 4 +- Amino.NET/Objects/Message.cs | 4 +- Amino.NET/Objects/PagingInfo.cs | 7 +- Amino.NET/Objects/ParticipatedExperiments.cs | 7 +- Amino.NET/Objects/Post.cs | 4 +- Amino.NET/Objects/PostExtensions.cs | 7 +- Amino.NET/Objects/SocketBase.cs | 7 +- Amino.NET/Objects/SpecialChatEvent.cs | 4 +- Amino.NET/Objects/Sticker.cs | 7 +- Amino.NET/Objects/StickerCollectionSummary.cs | 7 +- Amino.NET/Objects/StickerMessage.cs | 4 +- Amino.NET/Objects/TipInfo.cs | 7 +- .../Objects/UserAccountAdvancedSettings.cs | 7 +- Amino.NET/Objects/UserAccountExtensions.cs | 7 +- Amino.NET/Objects/UserAchievements.cs | 8 +- Amino.NET/Objects/UserCheckins.cs | 27 +--- Amino.NET/Objects/UserFollowings.cs | 79 ---------- Amino.NET/Objects/UserProfile.cs | 116 ++++---------- Amino.NET/Objects/UserVisitor.cs | 72 +-------- Amino.NET/Objects/ViewMode.cs | 129 ++-------------- Amino.NET/Objects/VoiceMessage.cs | 145 ++---------------- Amino.NET/Objects/VoiceMessageExtensions.cs | 9 ++ Amino.NET/Objects/WalletHistoryExtraData.cs | 7 +- Amino.NET/Objects/WalletInfo.cs | 36 ++--- Amino.NET/Objects/Wiki.cs | 135 +++------------- Amino.NET/Objects/YouTubeMessage.cs | 135 +++------------- Amino.NET/Objects/chatMember.cs | 9 +- Amino.NET/Objects/eventLog.cs | 4 +- Amino.NET/Objects/globalProfile.cs | 4 +- Amino.NET/Objects/messageCollection.cs | 4 +- Amino.NET/Objects/userAccount.cs | 86 +---------- 78 files changed, 207 insertions(+), 1162 deletions(-) create mode 100644 Amino.NET/Objects/GenericProfileExtensions.cs delete mode 100644 Amino.NET/Objects/UserFollowings.cs create mode 100644 Amino.NET/Objects/VoiceMessageExtensions.cs diff --git a/Amino.NET/Objects/AdditionalItemBenefits.cs b/Amino.NET/Objects/AdditionalItemBenefits.cs index da394ea..ee86245 100644 --- a/Amino.NET/Objects/AdditionalItemBenefits.cs +++ b/Amino.NET/Objects/AdditionalItemBenefits.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs index 846a074..cc51728 100644 --- a/Amino.NET/Objects/AdvancedCommunityInfo.cs +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -1,11 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/AvatarFrame.cs b/Amino.NET/Objects/AvatarFrame.cs index d448864..a8e77e7 100644 --- a/Amino.NET/Objects/AvatarFrame.cs +++ b/Amino.NET/Objects/AvatarFrame.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/AvatarFrameConfig.cs b/Amino.NET/Objects/AvatarFrameConfig.cs index 3db7256..4758b2f 100644 --- a/Amino.NET/Objects/AvatarFrameConfig.cs +++ b/Amino.NET/Objects/AvatarFrameConfig.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Blog.cs b/Amino.NET/Objects/Blog.cs index 21a1a4f..2335482 100644 --- a/Amino.NET/Objects/Blog.cs +++ b/Amino.NET/Objects/Blog.cs @@ -1,11 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Chat.cs b/Amino.NET/Objects/Chat.cs index 9e5a7ea..658d663 100644 --- a/Amino.NET/Objects/Chat.cs +++ b/Amino.NET/Objects/Chat.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/ChatAnnouncement.cs b/Amino.NET/Objects/ChatAnnouncement.cs index 9290b76..96a2d2e 100644 --- a/Amino.NET/Objects/ChatAnnouncement.cs +++ b/Amino.NET/Objects/ChatAnnouncement.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/ChatEvent.cs b/Amino.NET/Objects/ChatEvent.cs index f99febf..48ca3fd 100644 --- a/Amino.NET/Objects/ChatEvent.cs +++ b/Amino.NET/Objects/ChatEvent.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/ChatExtensions.cs b/Amino.NET/Objects/ChatExtensions.cs index 1c1d1d4..8f9fc10 100644 --- a/Amino.NET/Objects/ChatExtensions.cs +++ b/Amino.NET/Objects/ChatExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/ChatTip.cs b/Amino.NET/Objects/ChatTip.cs index 6a4a43e..a16ef45 100644 --- a/Amino.NET/Objects/ChatTip.cs +++ b/Amino.NET/Objects/ChatTip.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/ChatTipExtensions.cs b/Amino.NET/Objects/ChatTipExtensions.cs index 2354830..4798142 100644 --- a/Amino.NET/Objects/ChatTipExtensions.cs +++ b/Amino.NET/Objects/ChatTipExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/ChatTipToggle.cs b/Amino.NET/Objects/ChatTipToggle.cs index dbcdc40..2130047 100644 --- a/Amino.NET/Objects/ChatTipToggle.cs +++ b/Amino.NET/Objects/ChatTipToggle.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/CoinHistoryEntry.cs b/Amino.NET/Objects/CoinHistoryEntry.cs index 88787d1..a7c6be9 100644 --- a/Amino.NET/Objects/CoinHistoryEntry.cs +++ b/Amino.NET/Objects/CoinHistoryEntry.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Comment.cs b/Amino.NET/Objects/Comment.cs index 5573e12..214d0f3 100644 --- a/Amino.NET/Objects/Comment.cs +++ b/Amino.NET/Objects/Comment.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/Community.cs b/Amino.NET/Objects/Community.cs index 649efeb..2bd8f46 100644 --- a/Amino.NET/Objects/Community.cs +++ b/Amino.NET/Objects/Community.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/CommunityAdvancedSettings.cs b/Amino.NET/Objects/CommunityAdvancedSettings.cs index 647fc93..80709d1 100644 --- a/Amino.NET/Objects/CommunityAdvancedSettings.cs +++ b/Amino.NET/Objects/CommunityAdvancedSettings.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace Amino.Objects { diff --git a/Amino.NET/Objects/CommunityInfo.cs b/Amino.NET/Objects/CommunityInfo.cs index 8fdb4b2..8c22d1c 100644 --- a/Amino.NET/Objects/CommunityInfo.cs +++ b/Amino.NET/Objects/CommunityInfo.cs @@ -1,10 +1,7 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class CommunityInfo { [JsonPropertyName("objectType")]public int ObjectType { get; set; } diff --git a/Amino.NET/Objects/CommunityNewsFeed.cs b/Amino.NET/Objects/CommunityNewsFeed.cs index 1a4d43d..7311862 100644 --- a/Amino.NET/Objects/CommunityNewsFeed.cs +++ b/Amino.NET/Objects/CommunityNewsFeed.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/CommunityRankingTable.cs b/Amino.NET/Objects/CommunityRankingTable.cs index 9f048f5..3a65644 100644 --- a/Amino.NET/Objects/CommunityRankingTable.cs +++ b/Amino.NET/Objects/CommunityRankingTable.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/CommunityThemePack.cs b/Amino.NET/Objects/CommunityThemePack.cs index 3022811..ef81f27 100644 --- a/Amino.NET/Objects/CommunityThemePack.cs +++ b/Amino.NET/Objects/CommunityThemePack.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/CurrentUserInfo.cs b/Amino.NET/Objects/CurrentUserInfo.cs index 73cd40a..4aedc0d 100644 --- a/Amino.NET/Objects/CurrentUserInfo.cs +++ b/Amino.NET/Objects/CurrentUserInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/DeletedMessage.cs b/Amino.NET/Objects/DeletedMessage.cs index 2be1dfe..333115b 100644 --- a/Amino.NET/Objects/DeletedMessage.cs +++ b/Amino.NET/Objects/DeletedMessage.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/DeviceInfo.cs b/Amino.NET/Objects/DeviceInfo.cs index 771e68e..3e762eb 100644 --- a/Amino.NET/Objects/DeviceInfo.cs +++ b/Amino.NET/Objects/DeviceInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/FromCode.cs b/Amino.NET/Objects/FromCode.cs index d2cf870..cf11264 100644 --- a/Amino.NET/Objects/FromCode.cs +++ b/Amino.NET/Objects/FromCode.cs @@ -1,7 +1,4 @@ - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/FromInvite.cs b/Amino.NET/Objects/FromInvite.cs index 1839b54..08a651b 100644 --- a/Amino.NET/Objects/FromInvite.cs +++ b/Amino.NET/Objects/FromInvite.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Text.Json.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericAuthorExtensions.cs b/Amino.NET/Objects/GenericAuthorExtensions.cs index 51f4bb5..52fc7b2 100644 --- a/Amino.NET/Objects/GenericAuthorExtensions.cs +++ b/Amino.NET/Objects/GenericAuthorExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericAvatarFrame.cs b/Amino.NET/Objects/GenericAvatarFrame.cs index 9914564..2a3922c 100644 --- a/Amino.NET/Objects/GenericAvatarFrame.cs +++ b/Amino.NET/Objects/GenericAvatarFrame.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericChatMember.cs b/Amino.NET/Objects/GenericChatMember.cs index 8c62be5..283a484 100644 --- a/Amino.NET/Objects/GenericChatMember.cs +++ b/Amino.NET/Objects/GenericChatMember.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericMessage.cs b/Amino.NET/Objects/GenericMessage.cs index 845f3ba..26184e0 100644 --- a/Amino.NET/Objects/GenericMessage.cs +++ b/Amino.NET/Objects/GenericMessage.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericMessageAuthor.cs b/Amino.NET/Objects/GenericMessageAuthor.cs index cbb6c8c..9258e66 100644 --- a/Amino.NET/Objects/GenericMessageAuthor.cs +++ b/Amino.NET/Objects/GenericMessageAuthor.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericPostAuthor.cs b/Amino.NET/Objects/GenericPostAuthor.cs index 874b3e1..f38dc8e 100644 --- a/Amino.NET/Objects/GenericPostAuthor.cs +++ b/Amino.NET/Objects/GenericPostAuthor.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericProfile.cs b/Amino.NET/Objects/GenericProfile.cs index d5ac7e9..835622f 100644 --- a/Amino.NET/Objects/GenericProfile.cs +++ b/Amino.NET/Objects/GenericProfile.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/GenericProfileExtensions.cs b/Amino.NET/Objects/GenericProfileExtensions.cs new file mode 100644 index 0000000..fb1b4e4 --- /dev/null +++ b/Amino.NET/Objects/GenericProfileExtensions.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class GenericProfileExtensions + { + [JsonPropertyName("defaultBubbleId")] public string DefaultBubbleId { get; set; } + } +} diff --git a/Amino.NET/Objects/ImageMessage.cs b/Amino.NET/Objects/ImageMessage.cs index de6cc61..3200e35 100644 --- a/Amino.NET/Objects/ImageMessage.cs +++ b/Amino.NET/Objects/ImageMessage.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/InfluencerFanClubMember.cs b/Amino.NET/Objects/InfluencerFanClubMember.cs index bb5d07a..855b7aa 100644 --- a/Amino.NET/Objects/InfluencerFanClubMember.cs +++ b/Amino.NET/Objects/InfluencerFanClubMember.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/InfluencerInfo.cs b/Amino.NET/Objects/InfluencerInfo.cs index c2965cb..541e2bb 100644 --- a/Amino.NET/Objects/InfluencerInfo.cs +++ b/Amino.NET/Objects/InfluencerInfo.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json.Linq; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/InfluencerPriceInfo.cs b/Amino.NET/Objects/InfluencerPriceInfo.cs index 6823d5e..11fe52d 100644 --- a/Amino.NET/Objects/InfluencerPriceInfo.cs +++ b/Amino.NET/Objects/InfluencerPriceInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Invitation.cs b/Amino.NET/Objects/Invitation.cs index cd6c0d4..8f2319a 100644 --- a/Amino.NET/Objects/Invitation.cs +++ b/Amino.NET/Objects/Invitation.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/InviteCode.cs b/Amino.NET/Objects/InviteCode.cs index 3ce636c..a0cdc8c 100644 --- a/Amino.NET/Objects/InviteCode.cs +++ b/Amino.NET/Objects/InviteCode.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { public class InviteCode diff --git a/Amino.NET/Objects/ItemOwnershipInfo.cs b/Amino.NET/Objects/ItemOwnershipInfo.cs index 275724f..94ff5e0 100644 --- a/Amino.NET/Objects/ItemOwnershipInfo.cs +++ b/Amino.NET/Objects/ItemOwnershipInfo.cs @@ -1,10 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/ItemRestrictionInfo.cs b/Amino.NET/Objects/ItemRestrictionInfo.cs index 8f75a53..4db009f 100644 --- a/Amino.NET/Objects/ItemRestrictionInfo.cs +++ b/Amino.NET/Objects/ItemRestrictionInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/JoinedChatMember.cs b/Amino.NET/Objects/JoinedChatMember.cs index 5bc2b28..2b2ddbd 100644 --- a/Amino.NET/Objects/JoinedChatMember.cs +++ b/Amino.NET/Objects/JoinedChatMember.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/LastChatMessageSummary.cs b/Amino.NET/Objects/LastChatMessageSummary.cs index c52c34f..3126401 100644 --- a/Amino.NET/Objects/LastChatMessageSummary.cs +++ b/Amino.NET/Objects/LastChatMessageSummary.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/LeftChatMember.cs b/Amino.NET/Objects/LeftChatMember.cs index 1346590..82d6271 100644 --- a/Amino.NET/Objects/LeftChatMember.cs +++ b/Amino.NET/Objects/LeftChatMember.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/LinkInfo.cs b/Amino.NET/Objects/LinkInfo.cs index 729c024..3444251 100644 --- a/Amino.NET/Objects/LinkInfo.cs +++ b/Amino.NET/Objects/LinkInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/LinkInfoExtensions.cs b/Amino.NET/Objects/LinkInfoExtensions.cs index 8715522..0423e30 100644 --- a/Amino.NET/Objects/LinkInfoExtensions.cs +++ b/Amino.NET/Objects/LinkInfoExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Membership.cs b/Amino.NET/Objects/Membership.cs index 6338901..8679c32 100644 --- a/Amino.NET/Objects/Membership.cs +++ b/Amino.NET/Objects/Membership.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/MembershipInfo.cs b/Amino.NET/Objects/MembershipInfo.cs index 8fec023..3f09a7e 100644 --- a/Amino.NET/Objects/MembershipInfo.cs +++ b/Amino.NET/Objects/MembershipInfo.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Message.cs b/Amino.NET/Objects/Message.cs index 591ea9c..bb4c19c 100644 --- a/Amino.NET/Objects/Message.cs +++ b/Amino.NET/Objects/Message.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/PagingInfo.cs b/Amino.NET/Objects/PagingInfo.cs index dca422b..a4d120c 100644 --- a/Amino.NET/Objects/PagingInfo.cs +++ b/Amino.NET/Objects/PagingInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/ParticipatedExperiments.cs b/Amino.NET/Objects/ParticipatedExperiments.cs index b1122d7..a55b6de 100644 --- a/Amino.NET/Objects/ParticipatedExperiments.cs +++ b/Amino.NET/Objects/ParticipatedExperiments.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Post.cs b/Amino.NET/Objects/Post.cs index 1f1fca4..294de47 100644 --- a/Amino.NET/Objects/Post.cs +++ b/Amino.NET/Objects/Post.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/PostExtensions.cs b/Amino.NET/Objects/PostExtensions.cs index 9045361..84a6454 100644 --- a/Amino.NET/Objects/PostExtensions.cs +++ b/Amino.NET/Objects/PostExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/SocketBase.cs b/Amino.NET/Objects/SocketBase.cs index f6c48d2..f3de8f6 100644 --- a/Amino.NET/Objects/SocketBase.cs +++ b/Amino.NET/Objects/SocketBase.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/SpecialChatEvent.cs b/Amino.NET/Objects/SpecialChatEvent.cs index f35c09d..f4e8f9b 100644 --- a/Amino.NET/Objects/SpecialChatEvent.cs +++ b/Amino.NET/Objects/SpecialChatEvent.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/Sticker.cs b/Amino.NET/Objects/Sticker.cs index f728809..5748532 100644 --- a/Amino.NET/Objects/Sticker.cs +++ b/Amino.NET/Objects/Sticker.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/StickerCollectionSummary.cs b/Amino.NET/Objects/StickerCollectionSummary.cs index 6f6423c..0eb5993 100644 --- a/Amino.NET/Objects/StickerCollectionSummary.cs +++ b/Amino.NET/Objects/StickerCollectionSummary.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/StickerMessage.cs b/Amino.NET/Objects/StickerMessage.cs index 7062fad..f64469e 100644 --- a/Amino.NET/Objects/StickerMessage.cs +++ b/Amino.NET/Objects/StickerMessage.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/TipInfo.cs b/Amino.NET/Objects/TipInfo.cs index 82c0158..7aba6e9 100644 --- a/Amino.NET/Objects/TipInfo.cs +++ b/Amino.NET/Objects/TipInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/UserAccountAdvancedSettings.cs b/Amino.NET/Objects/UserAccountAdvancedSettings.cs index c146e98..3236242 100644 --- a/Amino.NET/Objects/UserAccountAdvancedSettings.cs +++ b/Amino.NET/Objects/UserAccountAdvancedSettings.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/UserAccountExtensions.cs b/Amino.NET/Objects/UserAccountExtensions.cs index e048320..d399595 100644 --- a/Amino.NET/Objects/UserAccountExtensions.cs +++ b/Amino.NET/Objects/UserAccountExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/UserAchievements.cs b/Amino.NET/Objects/UserAchievements.cs index b147245..b8dcbd5 100644 --- a/Amino.NET/Objects/UserAchievements.cs +++ b/Amino.NET/Objects/UserAchievements.cs @@ -1,10 +1,4 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/UserCheckins.cs b/Amino.NET/Objects/UserCheckins.cs index dc73b73..11e6a2e 100644 --- a/Amino.NET/Objects/UserCheckins.cs +++ b/Amino.NET/Objects/UserCheckins.cs @@ -1,32 +1,13 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class UserCheckins { - public bool hasAnyCheckIn { get; } = false; - public int consecutiveCheckInDays { get; } = 0; - public int brokenStreaks { get; } = 0; - public string json { get; } - - - - public UserCheckins(JObject json) - { - this.json = json.ToString(); - - try { hasAnyCheckIn = (bool)json["hasAnyCheckIn"]; } catch { } - try { consecutiveCheckInDays = (int)json["consecutiveCheckInDays"]; } catch { } - try { brokenStreaks = (int)json["brokenStreaks"]; } catch { } - } + [JsonPropertyName("hasAnyCheckIn")]public bool HasAnyCheckIn { get; set; } + [JsonPropertyName("consecutiveCheckInDays")]public int ConsecutiveCheckInDays { get; set; } + [JsonPropertyName("brokenStreaks")]public int BrokenStreaks { get; set; } } } diff --git a/Amino.NET/Objects/UserFollowings.cs b/Amino.NET/Objects/UserFollowings.cs deleted file mode 100644 index 5fe6af7..0000000 --- a/Amino.NET/Objects/UserFollowings.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Amino.Objects -{ - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class UserFollowings - { - public int status { get; private set; } - public string moodSticker { get; private set; } - public int itemsCount { get; private set; } - public string consecutiveCheckInDays { get; private set; } - public string userId { get; private set; } - public string modifiedTime { get; private set; } - public int followingStatus { get; private set; } - public int onlineStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int reputation { get; private set; } - public int postsCount { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - public bool isNicknameVerified { get; private set; } - public string mood { get; private set; } - public int level { get; private set; } - public int notificationSubscriptionStatus { get; private set; } - public bool pushEnabled { get; private set; } - public int membershipStatus { get; private set; } - public int joinedCount { get; private set; } - public string content { get; private set; } - public int role { get; private set; } - public int commentsCount { get; private set; } - public string aminoId { get; private set; } - public int communityId { get; private set; } - public string createdTime { get; private set; } - public int storiesCount { get; private set; } - public int blogsCount { get; private set; } - public string json { get; private set; } - - - public UserFollowings(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { status = (int)jsonObj["status"]; } catch { } - try { moodSticker = (string)jsonObj["moodSticker"]; } catch { } - try { itemsCount = (int)jsonObj["itemsCount"]; } catch { } - try { consecutiveCheckInDays = (string)jsonObj["consecutiveCheckInDays"]; } catch { } - try { userId = (string)jsonObj["uid"]; } catch { } - try { modifiedTime = (string)jsonObj["modifiedTime"]; } catch { } - try { followingStatus = (int)jsonObj["followingStatus"]; } catch { } - try { onlineStatus = (int)jsonObj["onlineStatus"]; } catch { } - try { accountMembershipStatus = (int)jsonObj["accountMembershipStatus"]; } catch { } - try { isGlobal = (bool)jsonObj["isGlobal"]; } catch { } - try { reputation = (int)jsonObj["reputation"]; } catch { } - try { postsCount = (int)jsonObj["postsCount"]; } catch { } - try { membersCount = (int)jsonObj["membersCount"]; } catch { } - try { nickname = (string)jsonObj["nickname"]; } catch { } - try { iconUrl = (string)jsonObj["icon"]; } catch { } - try { isNicknameVerified = (bool)jsonObj["isNicknameVerified"]; } catch { } - try { mood = (string)jsonObj["mood"]; } catch { } - try { level = (int)jsonObj["level"]; } catch { } - try { notificationSubscriptionStatus = (int)jsonObj["notificationSubscriptionStatus"]; } catch { } - try { if (jsonObj["pushEnabled"] != null) { pushEnabled = (bool)jsonObj["pushEnabled"]; } } catch { } - try { membershipStatus = (int)jsonObj["membershipStatus"]; } catch { } - try { content = (string)jsonObj["content"]; } catch { } - try { joinedCount = (int)jsonObj["joinedCount"]; } catch { } - try { role = (int)jsonObj["role"]; } catch { } - try { commentsCount = (int)jsonObj["commentsCount"]; } catch { } - try { aminoId = (string)jsonObj["aminoId"]; } catch { } - try { communityId = (int)jsonObj["ndcId"]; } catch { } - try { createdTime = (string)jsonObj["createdTime"]; } catch { } - try { storiesCount = (int)jsonObj["storiesCount"]; } catch { } - try { blogsCount = (int)jsonObj["blogsCount"]; } catch { } - json = _json.ToString(); - } - } -} diff --git a/Amino.NET/Objects/UserProfile.cs b/Amino.NET/Objects/UserProfile.cs index c1a8a60..c7c8042 100644 --- a/Amino.NET/Objects/UserProfile.cs +++ b/Amino.NET/Objects/UserProfile.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; namespace Amino.Objects @@ -8,89 +6,37 @@ namespace Amino.Objects public class UserProfile { - public int status { get; } - public string moodSticker { get; } - public int itemsCount { get; } - public int consecutiveCheckInDays { get; } - public string userId { get; } - public string modifiedTime { get; } - public int followingStatus { get; } - public int onlineStatus { get; } - public int accountMembershipStatus { get; } - public bool isGlobal { get; } - public int reputation { get; } - public int postsCount { get; } - public int membersCount { get; } - public string nickname { get; } - public string iconUrl { get; } - public bool isNicknameVerified { get; } - public int level { get; } - public int notificationSubscriptionStatus { get; } - public bool pushEnabled { get; } - public int membershipStatus { get; } - public string content { get; } - public int joinedCount { get; } - public int role { get; } - public int commentsCount { get; } - public string aminoId { get; } - public int communityId { get; } - public string createdTime { get; } - public int storiesCount { get; } - public int blogsCount { get; } - public string json { get; } - public _Extensions Extensions { get; } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("moodSticker")]public string MoodSticker { get; set; } + [JsonPropertyName("itemsCount")]public int ItemsCount { get; set; } + [JsonPropertyName("consecutiveCheckInDays")]public int ConsecutiveCheckInDays { get; set; } + [JsonPropertyName("uid")]public string UserId { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("followingStatus")]public int FollowingStatus { get; set; } + [JsonPropertyName("onlineStatus")]public int OnlineStatus { get; set; } + [JsonPropertyName("accountMembership")]public int AccountMembershipStatus { get; set; } + [JsonPropertyName("isGlobal")]public bool IsGlobal { get; set; } + [JsonPropertyName("reputation")]public int Reputation { get; set; } + [JsonPropertyName("postsCount")]public int PostsCount { get; set; } + [JsonPropertyName("membersCount")]public int MembersCount { get; set; } + [JsonPropertyName("nickname")]public string Nickname { get; set; } + [JsonPropertyName("icon")]public string IconUrl { get; set; } + [JsonPropertyName("isNicknameVerified")]public bool IsNicknameVerified { get; set; } + [JsonPropertyName("level")]public int Level { get; set; } + [JsonPropertyName("notificationSubscriptionStatus")]public int notificationSubscriptionStatus { get; set; } + [JsonPropertyName("pushEnabled")]public bool PushEnabled { get; set; } + [JsonPropertyName("membershipStatus")]public int MembershipStatus { get; set; } + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("joinedCount")]public int JoinedCount { get; set; } + [JsonPropertyName("role")]public int Role { get; set; } + [JsonPropertyName("commentsCount")]public int CommentsCount { get; set; } + [JsonPropertyName("aminoId")]public string AminoId { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("storiesCount")]public int StoriesCount { get; set; } + [JsonPropertyName("blogsCount")]public int BlogsCount { get; set; } + [JsonPropertyName("extensions")]public GenericProfileExtensions Extensions { get; set; } [JsonPropertyName("influencerInfo")]public InfluencerInfo InfluencerInfo { get; set; } [JsonPropertyName("fanClubList")] public List FanClubList { get; set; } - - public UserProfile(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { status = (int)jsonObj["status"]; } catch { } - try { moodSticker = (string)jsonObj["moodSticker"]; } catch { } - try { itemsCount = (int)jsonObj["itemsCount"]; } catch { } - try { if (jsonObj["consecutiveCheckInDays"] != null) { consecutiveCheckInDays = (int)jsonObj["consecutiveCheckInDays"]; } } catch { } - try { userId = (string)jsonObj["uid"]; } catch{ } - try { modifiedTime = (string)jsonObj["modifiedTime"]; } catch { } - try { followingStatus = (int)jsonObj["followingStatus"]; } catch { } - try { onlineStatus = (int)jsonObj["onlineStatus"]; } catch { } - try { accountMembershipStatus = (int)jsonObj["accountMembershipStatus"]; } catch { } - try { isGlobal = (bool)jsonObj["isGlobal"]; } catch { } - try { reputation = (int)jsonObj["reputation"]; } catch { } - try { postsCount = (int)jsonObj["postsCount"]; } catch { } - try { membersCount = (int)jsonObj["membersCount"]; } catch { } - try { nickname = (string)jsonObj["nickname"]; } catch { } - try { iconUrl = (string)jsonObj["icon"]; } catch { } - try { isNicknameVerified = (bool)jsonObj["isNicknameVerified"]; } catch { } - try { level = (int)jsonObj["level"]; } catch { } - try { notificationSubscriptionStatus = (int)jsonObj["notificationSubscriptionStatus"]; } catch { } - try { pushEnabled = (bool)jsonObj["pushEnabled"]; } catch { } - try { membershipStatus = (int)jsonObj["membershipStatus"]; } catch { } - try { if (jsonObj["content"] != null) { content = (string)jsonObj["content"]; } } catch { } - try { joinedCount = (int)jsonObj["joinedCount"]; } catch { } - try { role = (int)jsonObj["role"]; } catch { } - try { commentsCount = (int)jsonObj["commentsCount"]; } catch { } - try { aminoId = (string)jsonObj["aminoId"]; } catch { } - try { communityId = (int)jsonObj["ndcId"]; } catch { } - try { createdTime = (string)jsonObj["createdTime"]; } catch { } - json = _json.ToString(); - - if(jsonObj["extensions"] != null) { Extensions = new _Extensions(_json); } - - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Extensions - { - public string defaultBubbleId { get; } - - public _Extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { defaultBubbleId = (string)jsonObj["extensions"]["defaultBubbleId"]; } catch { } - } - } - - } } \ No newline at end of file diff --git a/Amino.NET/Objects/UserVisitor.cs b/Amino.NET/Objects/UserVisitor.cs index b1dcbcf..bd6d687 100644 --- a/Amino.NET/Objects/UserVisitor.cs +++ b/Amino.NET/Objects/UserVisitor.cs @@ -1,72 +1,14 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class UserVisitor { - public int visitorsCount { get; private set; } - public int capacity { get; private set; } - public int visitorPrivacyMode { get; private set; } - public int ownerPrivacyMode { get; private set; } - public string visitTime { get; private set; } - public _Profile Profile { get; private set; } - - - public UserVisitor(JObject _profile, JObject _baseJson) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_baseJson.ToString()); - dynamic profileObj = (JObject)JsonConvert.DeserializeObject(_profile.ToString()); - visitorsCount = (int)jsonObj["visitorsCount"]; - capacity = (int)jsonObj["capacity"]; - visitorPrivacyMode = (int)profileObj["visitorPrivacyMode"]; - ownerPrivacyMode = (int)profileObj["ownerPrivacyMode"]; - visitTime = (string)profileObj["visitTime"]; - Profile = new _Profile(_profile); - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Profile - { - public int status { get; private set; } - public bool isNicknameVerified { get; private set; } - public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int accountMembershipStatus { get; private set; } - public bool isGlobal { get; private set; } - public int membershipStatus { get; private set; } - public string avatarFrameId { get; private set; } - public int reputation { get; private set; } - public int role { get; private set; } - public string aminoId { get; private set; } - public int communityId { get; private set; } - public int membersCount { get; private set; } - public string nickname { get; private set; } - public string iconUrl { get; private set; } - - public _Profile(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["profile"]["status"]; - isNicknameVerified = (bool)jsonObj["profile"]["isNicknameVerified"]; - userId = (string)jsonObj["profile"]["uid"]; - level = (int)jsonObj["profile"]["level"]; - followingStatus = (int)jsonObj["profile"]["followingStatus"]; - accountMembershipStatus = (int)jsonObj["profile"]["accountMembershipStatus"]; - isGlobal = (bool)jsonObj["profile"]["isGlobal"]; - membershipStatus = (int)jsonObj["profile"]["membershipStatus"]; - avatarFrameId = (string)jsonObj["profile"]["avatarFrameId"]; - reputation = (int)jsonObj["profile"]["reputation"]; - role = (int)jsonObj["profile"]["role"]; - aminoId = (string)jsonObj["profile"]["aminoId"]; - communityId = (int)jsonObj["profile"]["ndcId"]; - membersCount = (int)jsonObj["profile"]["membersCount"]; - nickname = (string)jsonObj["profile"]["nickname"]; - iconUrl = (string)jsonObj["profile"]["icon"]; - } - } + [JsonPropertyName("visitorsCount")] public int VisitorsCount { get; set; } + [JsonPropertyName("capacity")] public int Capacity { get; set; } + [JsonPropertyName("visitorPrivacyMode")] public int VisitorPrivacyMode { get; set; } + [JsonPropertyName("ownerPrivacyMode")]public int OwnerPrivacyMode { get; set; } + [JsonPropertyName("visitTime")]public string VisitTime { get; set; } + [JsonPropertyName("profile")]public UserProfile Profile { get; private set; } } } diff --git a/Amino.NET/Objects/ViewMode.cs b/Amino.NET/Objects/ViewMode.cs index f9dd99d..2385332 100644 --- a/Amino.NET/Objects/ViewMode.cs +++ b/Amino.NET/Objects/ViewMode.cs @@ -1,122 +1,21 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class ViewMode { - public int _type { get; } - public int communityId { get; } - public int alertOption { get; } - public int membershipStatus { get; } - - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - public _Author Author { get; } - - public ViewMode(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - _type = (int)jsonObj["t"]; - communityId = (int)jsonObj["o"]["ndcId"]; - alertOption = (int)jsonObj["o"]["alertOption"]; - membershipStatus = (int)jsonObj["o"]["membershipStatus"]; - - chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; - mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; - clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; - messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; - userId = (string)jsonObj["o"]["chatMessage"]["uid"]; - createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; - type = (int)jsonObj["o"]["chatMessage"]["type"]; - isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; - includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; - json = _json.ToString(); - Author = new _Author(_json); - - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; - status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; - if(jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } - reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; - role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; - nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; - level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; - accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; - if(jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } - if(jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } - - - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; - version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; - resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; - name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; - iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; - frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; - frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; - monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; - } - } - } + public SocketBase SocketBase { get; set; } + public string Json { get; set; } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string ObjectId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/VoiceMessage.cs b/Amino.NET/Objects/VoiceMessage.cs index 1a7b2bb..2b1b64e 100644 --- a/Amino.NET/Objects/VoiceMessage.cs +++ b/Amino.NET/Objects/VoiceMessage.cs @@ -1,135 +1,24 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class VoiceMessage { - public int _type { get; } - public int communityId { get; } - public int alertOption { get; } - public int membershipStatus { get; } - - public string mediaValue { get; } - public string chatId { get; } - public int mediaType { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string json { get; } - public _Author Author { get; } - public _Extensions Extensions { get; } - - public VoiceMessage(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { _type = (int)jsonObj["t"]; } catch { } - try { communityId = (int)jsonObj["o"]["ndcId"]; } catch { } - try { alertOption = (int)jsonObj["o"]["alertOption"]; } catch { } - try { membershipStatus = (int)jsonObj["o"]["membershipStatus"]; } catch { } - - try { mediaValue = (string)jsonObj["o"]["chatMessage"]["mediaValue"]; }catch{ } - try { chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; } catch { } - try { mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; } catch { } - try { clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; } catch { } - try { messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; } catch { } - try { userId = (string)jsonObj["o"]["chatMessage"]["uid"]; } catch { } - try { createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; } catch { } - try { type = (int)jsonObj["o"]["chatMessage"]["type"]; } catch { } - try { isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; } catch { } - try { includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; } catch { } - json = _json.ToString(); - try { if (jsonObj["o"]["chatMessage"]["extensions"] != null) { Extensions = new _Extensions(_json); } } catch { } - try { Author = new _Author(_json); } catch { } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputation { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public string avatarFrameId { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; } catch { } - try { status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } } catch { } - try { reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; } catch { } - try { role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; } catch { } - try { nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; } catch { } - try { level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; } catch { } - try { accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; } catch { } - try { avatarFrameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrameId"]; } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } } catch { } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; } catch { } - try { version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; } catch { } - try { resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; } catch { } - try { name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; } catch { } - try { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; } catch { } - try { frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; } catch { } - try { frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; } catch { } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; } catch { } - try { monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; } catch { } - } - } - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Extensions - { - public float duration { get; } - - public _Extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { duration = (float)jsonObj["o"]["chatMessage"]["extensions"]["duration"]; } catch { } - } - } + public SocketBase SocketBase { get; set; } + public string Json { get; set; } + + [JsonPropertyName("mediaValue")]public string MediaValue { get; set; } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int mediaType { get; set; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string ObjectId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } + [JsonPropertyName("extensions")]public VoiceMessageExtensions Extensions { get; set; } } } diff --git a/Amino.NET/Objects/VoiceMessageExtensions.cs b/Amino.NET/Objects/VoiceMessageExtensions.cs new file mode 100644 index 0000000..e6f1696 --- /dev/null +++ b/Amino.NET/Objects/VoiceMessageExtensions.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class VoiceMessageExtensions + { + [JsonPropertyName("duration")] public float Duration { get; set; } + } +} diff --git a/Amino.NET/Objects/WalletHistoryExtraData.cs b/Amino.NET/Objects/WalletHistoryExtraData.cs index 4c5eaeb..340a0ad 100644 --- a/Amino.NET/Objects/WalletHistoryExtraData.cs +++ b/Amino.NET/Objects/WalletHistoryExtraData.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/WalletInfo.cs b/Amino.NET/Objects/WalletInfo.cs index 6e3c647..1c950d3 100644 --- a/Amino.NET/Objects/WalletInfo.cs +++ b/Amino.NET/Objects/WalletInfo.cs @@ -1,34 +1,18 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: wallet public class WalletInfo { - public float totalCoinsFloat { get; } - public bool adsEnabled { get; } - public string adsVideoStats { get; } - public string adsFlag { get; } - public int totalCoins { get; } - public bool businessCoinsEnabled { get; } - public int totalBusinessCoins { get; } - public float totalBusinessCoinsFloat { get; } - public string json { get; } - - public WalletInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - totalCoinsFloat = (float)jsonObj["wallet"]["totalCoinsFloat"]; - adsEnabled = (bool)jsonObj["wallet"]["adsEnabled"]; - adsVideoStats = (string)jsonObj["wallet"]["adsVideoStats"]; - adsFlag = (string)jsonObj["wallet"]["adsFlag"]; - totalCoins = (int)jsonObj["wallet"]["totalCoins"]; - businessCoinsEnabled = (bool)jsonObj["wallet"]["businessCoinsEnabled"]; - totalBusinessCoins = (int)jsonObj["wallet"]["totalBusinessCoins"]; - totalBusinessCoinsFloat = (float)jsonObj["wallet"]["totalBusinessCoinsFloat"]; - json = _json.ToString(); - } + [JsonPropertyName("totalCoinsFloat")]public float TotalCoinsFloat { get; set; } + [JsonPropertyName("adsEnabled")]public bool AdsEnabled { get; set; } + [JsonPropertyName("adsVideoStats")]public string AdsVideoStats { get; set; } + [JsonPropertyName("adsFlag")]public string AdsFlag { get; set; } + [JsonPropertyName("totalCoins")]public int TotalCoins { get; set; } + [JsonPropertyName("businessCoinsEnabled")]public bool BusinessCoinsEnabled { get; set; } + [JsonPropertyName("totalBusinessCoins")]public int TotalBusinessCoins { get; set; } + [JsonPropertyName("totalBusinessCoinsFloat")]public float TotalBusinessCoinsFloat { get; set; } } } diff --git a/Amino.NET/Objects/Wiki.cs b/Amino.NET/Objects/Wiki.cs index a0ebc38..b384b45 100644 --- a/Amino.NET/Objects/Wiki.cs +++ b/Amino.NET/Objects/Wiki.cs @@ -1,122 +1,27 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class Wiki { - public string itemId { get; } - public int status { get; } = 0; - public int style { get; } = 0; - public int globalCommentsCount { get; } = 0; - public string modifiedTime { get; } - public int votedValue { get; } = 0; - public int globalVotesCount { get; } = 0; - public int globalVotedValue { get; } = 0; - public int contentRating { get; } = 0; - public string label { get; } - public string content { get; } = ""; - public string keywords { get; } - public bool needHidden { get; } = false; - public int guestVotesCount { get; } = 0; - public int votesCount { get; } = 0; - public int communityId { get; } = 0; - public string createdTime { get; } - public int commentsCount { get; } = 0; - public string json { get; } - public _Author Author { get; } - - public Wiki(JObject json) - { - this.json = json.ToString(); - try { itemId = (string)json["itemId"]; } catch { } - try { status = (int)json["status"]; } catch { } - try { style = (int)json["style"]; } catch { } - try { globalCommentsCount = (int)json["globalCommentsCount"]; } catch { } - try { modifiedTime = (string)json["modifiedTime"]; } catch { } - try { votedValue = (int)json["votedValue"]; } catch { } - try { globalVotesCount = (int)json["globalVotesCount"]; } catch { } - try { globalVotedValue = (int)json["globalVotedValue"]; } catch { } - try { contentRating = (int)json["contentRating"]; } catch { } - try { label = (string)json["label"]; } catch { } - try { content = (string)json["content"]; } catch { } - try { keywords = (string)json["keywords"]; } catch { } - try { needHidden = (bool)json["needHidden"]; } catch { } - try { guestVotesCount = (int)json["guestVotesCount"]; } catch { } - try { votesCount = (int)json["votesCount"]; } catch { } - try { communityId = (int)json["ndcId"]; } catch { } - try { createdTime = (string)json["createdTime"]; } catch { } - try { commentsCount = (int)json["commentsCount"]; } catch { } - - try { Author = new(JObject.Parse((string)json["author"])); } catch { } - - } - - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public int status { get; } = 0; - public bool isNicknameVerified { get; } = false; - public int level { get; } = 0; - public int followingStatus { get; } = 0; - public string userId { get; } - public int accountMembershipStatus { get; } - public bool isGlobal { get; } = false; - public int membershipStatus { get; } = 0; - public string avatarFrameId { get; } - public int reputation { get; } = 0; - public int role { get; } = 0; - public int communityId { get; } = 0; - public int membersCount { get; } = 0; - public string nickname { get; } - public string iconUrl { get; } - public _AvatarFrame AvatarFrame { get; } - - public _Author(JObject json) - { - try { status = (int)json["status"]; } catch { } - try { isNicknameVerified = (bool)json["isNicknameVerified"]; } catch { } - try { level = (int)json["level"]; } catch { } - try { userId = (string)json["uid"]; } catch { } - try { accountMembershipStatus = (int)json["accountMembershipStatus"]; } catch { } - try { isGlobal = (bool)json["isGlobal"]; } catch { } - try { followingStatus = (int)json["followingStatus"]; } catch { } - try { membershipStatus = (int)json["membershipStatus"]; } catch { } - try { avatarFrameId = (string)json["avatarFrameId"]; } catch { } - try { reputation = (int)json["reputation"]; } catch { } - try { role = (int)json["role"]; } catch { } - try { communityId = (int)json["ndcId"]; } catch { } - try { membersCount = (int)json["membersCount"]; } catch { } - try { nickname = (string)json["nickname"]; } catch { } - try { iconUrl = (string)json["icon"]; } catch { } - try { AvatarFrame = new(JObject.Parse((string)json["avatarFrame"])); } catch { } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } = 0; - public int version { get; } = 0; - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject json) - { - try { status = (int)json["status"]; } catch { } - try { version = (int)json["version"]; } catch { } - try { resourceUrl = (string)json["resourceUrl"]; } catch { } - try { name = (string)json["name"]; } catch { } - try { iconUrl = (string)json["icon"]; } catch { } - try { frameType = (int)json["frameType"]; } catch { } - try { frameId = (string)json["frameId"]; } catch { } - } - } - } + [JsonPropertyName("itemId")]public string ItemId { get; set; } + [JsonPropertyName("status")]public int Status { get; set; } + [JsonPropertyName("style")]public int Style { get; set; } + [JsonPropertyName("globalCommentsCount")]public int GlobalCommentsCount { get; set; } + [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } + [JsonPropertyName("votedValue")]public int VotedValue { get; set; } + [JsonPropertyName("globalVotesCount")]public int GlobalVotesCount { get; set; } + [JsonPropertyName("globalVotedValue")]public int GlobalVotedValue { get; set; } + [JsonPropertyName("contentRating")]public int ContentRating { get; set; } + [JsonPropertyName("label")]public string Label { get; set; } + [JsonPropertyName("content")]public string Content { get; set; } + [JsonPropertyName("keywords")]public string Keywords { get; set; } + [JsonPropertyName("needHidden")]public bool NeedHidden { get; set; } + [JsonPropertyName("guestVotesCount")]public int GuestVotesCount { get; set; } + [JsonPropertyName("votesCount")]public int VotesCount { get; set; } + [JsonPropertyName("ndcId")]public int CommunityId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("commentsCount")]public int CommentsCount { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/YouTubeMessage.cs b/Amino.NET/Objects/YouTubeMessage.cs index cdc4427..c2edacd 100644 --- a/Amino.NET/Objects/YouTubeMessage.cs +++ b/Amino.NET/Objects/YouTubeMessage.cs @@ -1,123 +1,26 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace Amino.Objects { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + // ROOT JSON ELEMENT: o/chatMessage public class YouTubeMessage { - public int _type { get; } - public int alertOption { get; } - public int membershipStatus { get; } - public int communityId { get; } - - public string mediaValue { get; } - public string chatId { get; } - public int mediaType { get; } - public string videoTitle { get; } - public int clientRefId { get; } - public string messageId { get; } - public string userId { get; } - public string createdTime { get; } - public int type { get; } - public bool isHidden { get; } - public bool includedInSummary { get; } - public string chatBubbleId { get; } - public int chatBubbleVersion { get; } - public string json { get; } - public _Author Author { get; } - - - public YouTubeMessage(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { _type = (int)jsonObj["t"]; } catch { } - try { communityId = (int)jsonObj["o"]["ndcId"]; } catch { } - try { alertOption = (int)jsonObj["o"]["alertOption"]; } catch { } - try { membershipStatus = (int)jsonObj["o"]["membershipStatus"]; } catch { } - try { mediaValue = (string)jsonObj["o"]["chatMessage"]["mediaValue"]; } catch { } - try { chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; } catch { } - try { videoTitle = (string)jsonObj["o"]["chatMessage"]["content"]; } catch { } - try { clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; } catch { } - try { messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; } catch { } - try { userId = (string)jsonObj["o"]["chatMessage"]["userId"]; } catch { } - try { createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; } catch { } - try { type = (int)jsonObj["o"]["chatMessage"]["type"]; } catch { } - try { isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; } catch { } - try { includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; } catch { } - try { chatBubbleId = (string)jsonObj["o"]["chatMessage"]["chatBubbleId"]; } catch { } - try { chatBubbleVersion = (int)jsonObj["o"]["chatMessage"]["chatBubbleVersion"]; } catch { } - Author = new _Author(_json); - json = _json.ToString(); - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Author - { - public string userId { get; } - public int status { get; } - public string iconUrl { get; } - public int reputationn { get; } - public int role { get; } - public string nickname { get; } - public int level { get; } - public int accountMembershipStatus { get; } - public _AvatarFrame AvatarFrame { get; } - public _InfluencerInfo InfluencerInfo { get; } - - public _Author(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; } catch { } - try { status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } } catch { } - try { reputationn = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; } catch { } - try { role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; } catch { } - try { nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; } catch { } - try { level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; } catch { } - try { accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"]; } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } } catch { } - try { if (jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } } catch { } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AvatarFrame - { - public int status { get; } - public int version { get; } - public string resourceUrl { get; } - public string name { get; } - public string iconUrl { get; } - public int frameType { get; } - public string frameId { get; } - - public _AvatarFrame(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; } catch { } - try { version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; } catch { } - try { resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; } catch { } - try { name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; } catch { } - try { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; } catch { } - try { frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; } catch { } - try { frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; } catch { } - } - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _InfluencerInfo - { - public int fansCount { get; } - public int monthlyFee { get; } - - public _InfluencerInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - try { fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; } catch { } - try { monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; } catch { } - } - } - } + public SocketBase SocketBase { get; set; } + public string Json { get; set; } + + [JsonPropertyName("mediaValue")]public string MediaValue { get; set; } + [JsonPropertyName("threadId")]public string ChatId { get; set; } + [JsonPropertyName("mediaType")]public int MediaType { get; set; } + [JsonPropertyName("content")]public string VideoTitle { get; } + [JsonPropertyName("clientRefId")]public int ClientRefId { get; set; } + [JsonPropertyName("messageId")]public string MessageId { get; set; } + [JsonPropertyName("uid")]public string ObjectId { get; set; } + [JsonPropertyName("createdTime")]public string CreatedTime { get; set; } + [JsonPropertyName("type")]public int Type { get; set; } + [JsonPropertyName("isHidden")]public bool IsHidden { get; set; } + [JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; } + [JsonPropertyName("chatBubbleId")]public string ChatBubbleId { get; set; } + [JsonPropertyName("chatBubbleVersion")]public int ChatBubbleVersion { get; set; } + [JsonPropertyName("author")]public GenericProfile Author { get; set; } } } diff --git a/Amino.NET/Objects/chatMember.cs b/Amino.NET/Objects/chatMember.cs index a7d9a71..0436ade 100644 --- a/Amino.NET/Objects/chatMember.cs +++ b/Amino.NET/Objects/chatMember.cs @@ -1,11 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/eventLog.cs b/Amino.NET/Objects/eventLog.cs index 25ca901..a52b6c5 100644 --- a/Amino.NET/Objects/eventLog.cs +++ b/Amino.NET/Objects/eventLog.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/globalProfile.cs b/Amino.NET/Objects/globalProfile.cs index a970ea0..6a78324 100644 --- a/Amino.NET/Objects/globalProfile.cs +++ b/Amino.NET/Objects/globalProfile.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/messageCollection.cs b/Amino.NET/Objects/messageCollection.cs index c4db8ab..e3d5b3a 100644 --- a/Amino.NET/Objects/messageCollection.cs +++ b/Amino.NET/Objects/messageCollection.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; namespace Amino.Objects diff --git a/Amino.NET/Objects/userAccount.cs b/Amino.NET/Objects/userAccount.cs index 8faa13a..80306e7 100644 --- a/Amino.NET/Objects/userAccount.cs +++ b/Amino.NET/Objects/userAccount.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Amino.Objects { @@ -29,87 +27,5 @@ public class UserAccount [JsonPropertyName("email")]public string Email { get; set; } [JsonPropertyName("advancedSettings")]public UserAccountAdvancedSettings AdvancedSettings { get; set; } [JsonPropertyName("extensions")]public UserAccountExtensions Extensions { get; set; } - - public UserAccount(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - AdvancedSettings = new _AdvancedSettings(_json); - Extensions = new _Extensions(_json); - json = _json.ToString(); - userName = (string)jsonObj["account"]["username"]; - status = (int)jsonObj["account"]["status"]; - userId = (string)jsonObj["account"]["uid"]; - modifiedTime = (string)jsonObj["account"]["modifiedTime"]; - twitterID = (string)jsonObj["account"]["twitterID"]; - activation = (int)jsonObj["account"]["activation"]; - phoneNumberActivation = (int)jsonObj["account"]["phoneNumberActivation"]; - emailActivation = (int)jsonObj["account"]["emailActivation"]; - appleID = (string)jsonObj["account"]["appleID"]; - facebookID = (string)jsonObj["account"]["facebookID"]; - nickName = (string)jsonObj["account"]["nickname"]; - googleID = (string)jsonObj["account"]["googleID"]; - iconUrl = (string)jsonObj["account"]["icon"]; - securityLevel = (int)jsonObj["account"]["securityLevel"]; - phoneNumber = (string)jsonObj["account"]["phoneNumber"]; - role = (int)jsonObj["account"]["role"]; - aminoIdEditable = (bool)jsonObj["account"]["aminoIdEditable"]; - aminoId = (string)jsonObj["account"]["aminoId"]; - createdTime = (string)jsonObj["account"]["createdTime"]; - email = (string)jsonObj["account"]["email"]; - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _AdvancedSettings - { - public int? analyticsEnabled { get; private set; } - - public _AdvancedSettings(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - analyticsEnabled = (int)jsonObj["account"]["advancedSettings"]["analyticsEnabled"]; - - } - } - - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _Extensions - { - public string contentLanguage { get; private set; } - public int? adsFlags { get; private set; } - public int? adsLevel { get; private set; } - public bool mediaLabAdsMigrationJuly2020 { get; private set; } - public string avatarFrameId { get; private set; } - public bool mediaLabAdsMigrationAugust2020 { get; private set; } - public bool adsEnabled { get; private set; } - public _DeviceInfo DeviceInfo { get; } - - public _Extensions(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - DeviceInfo = new _DeviceInfo(_json); - contentLanguage = (string)jsonObj["account"]["extensions"]["contentLanguage"]; - adsFlags = (int)jsonObj["account"]["extensions"]["adsFlags"]; - mediaLabAdsMigrationJuly2020 = (bool)jsonObj["account"]["extensions"]["mediaLabAdsMigrationJuly2020"]; - avatarFrameId = (string)jsonObj["account"]["extensions"]["avatarFrameId"]; - mediaLabAdsMigrationAugust2020 = (bool)jsonObj["account"]["extensions"]["mediaLabAdsMigrationAugust2020"]; - adsEnabled = (bool)jsonObj["account"]["extensions"]["adsEnabled"]; - - } - - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class _DeviceInfo - { - public int? lastClientType { get; private set; } - - public _DeviceInfo(JObject _json) - { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - lastClientType = (int)jsonObj["account"]["extensions"]["deviceInfo"]["lastClientType"]; - - } - } - } } } From 8cd9ba28f69763e4a056f8163fbfbd1d77643c67 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Thu, 23 May 2024 13:00:33 +0200 Subject: [PATCH 14/19] started to adapt EventHandler --- Amino.NET/Client.cs | 4 +-- Amino.NET/Events/EventHandler.cs | 51 +++++++++++++++++++------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 8f2f980..3728be6 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -2548,11 +2548,11 @@ public void callMessageEvent(Amino.Client _client, object _sender, Amino.Objects } } - public void callWebSocketMessageEvent(Amino.Client _client, JObject _webSocketMessage) + public void callWebSocketMessageEvent(Amino.Client _client, string _webSocketMessage) { if (_client.onWebSocketMessage != null) { - _client.onWebSocketMessage.Invoke(_webSocketMessage.ToString()); + _client.onWebSocketMessage.Invoke(_webSocketMessage); } } diff --git a/Amino.NET/Events/EventHandler.cs b/Amino.NET/Events/EventHandler.cs index 5d8cc11..454705e 100644 --- a/Amino.NET/Events/EventHandler.cs +++ b/Amino.NET/Events/EventHandler.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; +using System.Text.Json; using System.Threading.Tasks; using Amino.Objects; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; + namespace Amino.Events { @@ -21,49 +16,63 @@ public class EventHandler /// /// /// - public Task ReceiveEvent(JObject webSocketMessage, Client client) + public Task ReceiveEvent(string webSocketMessage, Client client) { Client.Events eventCall = new Client.Events(); eventCall.callWebSocketMessageEvent(client, webSocketMessage); try { JsonElement root = JsonDocument.Parse(webSocketMessage.ToString()).RootElement; - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(webSocketMessage.ToString()); - if(jsonObj["o"]["chatMessage"]["mediaType"] != null) + if(root.GetProperty("o").GetProperty("chatMessage").GetProperty("mediaType").ValueKind != JsonValueKind.Null) { - - SocketBase sBase = System.Text.Json.JsonSerializer.Deserialize(root.GetProperty("o")); - switch ((int)jsonObj["o"]["chatMessage"]["mediaType"]) + SocketBase _socketBase = JsonSerializer.Deserialize(root.GetProperty("o").GetRawText()); + string element = root.GetProperty("o").GetProperty("chatMessage").GetRawText(); + switch (root.GetProperty("o").GetProperty("chatMessage").GetProperty("mediaType").GetInt32()) { case 0: //TextMessage / MessageDeleted / ChatMember Left, ChatMember Joined / ChatBackground changed / ChatTitle changed / ChatContent chaaged / ChatAnnouncementPin / ChatAnnouncementUnpin / ChatViewOnlyOn / ChatViewOnlyOff / ChatTipEnabled / ChatTipDisabled / MessageForceRemoved / ChatTip - switch((int)jsonObj["o"]["chatMessage"]["type"]) + switch(root.GetProperty("o").GetProperty("chatMessage").GetProperty("type").GetInt32()) { case 0: //Textmessage recevied - Amino.Objects.Message _message = new Amino.Objects.Message(webSocketMessage); + Objects.Message _message = JsonSerializer.Deserialize(element); + _message.Json = webSocketMessage; + _message.SocketBase = _socketBase; + eventCall.callMessageEvent(client, this, _message); break; case 100: // Textmessage deleted - Amino.Objects.DeletedMessage _deletedMessage = new Objects.DeletedMessage(webSocketMessage); + Amino.Objects.DeletedMessage _deletedMessage = JsonSerializer.Deserialize(element); + _deletedMessage.SocketBase = _socketBase; + _deletedMessage.Json = webSocketMessage; eventCall.callMessageDeletedEvent(client, _deletedMessage); break; case 101: // ChatMember Joined - Amino.Objects.JoinedChatMember _joinedMember = new Objects.JoinedChatMember(webSocketMessage); + Amino.Objects.JoinedChatMember _joinedMember = JsonSerializer.Deserialize(element); + _joinedMember.Json = webSocketMessage; + _joinedMember.SocketBase = _socketBase; eventCall.callChatMemberJoinEvent(client, _joinedMember); break; case 102: // ChatMember Left - Amino.Objects.LeftChatMember _leftMember = new Objects.LeftChatMember(webSocketMessage); + Amino.Objects.LeftChatMember _leftMember = JsonSerializer.Deserialize(element); + _leftMember.Json = webSocketMessage; + _leftMember.SocketBase = _socketBase; eventCall.callChatMemberLeaveEvent(client, _leftMember); break; case 104: // ChatBackground changed - Amino.Objects.ChatEvent _chatBackgroundChanged = new Objects.ChatEvent(webSocketMessage); + Amino.Objects.ChatEvent _chatBackgroundChanged = JsonSerializer.Deserialize(element); + _chatBackgroundChanged.SocketBase = _socketBase; + _chatBackgroundChanged.Json = webSocketMessage; eventCall.callChatBackgroundChangedEvent(client, _chatBackgroundChanged); break; case 105: // ChatTitle changed - Amino.Objects.ChatEvent _chatTitleChanged = new Objects.ChatEvent(webSocketMessage); + Amino.Objects.ChatEvent _chatTitleChanged = JsonSerializer.Deserialize(element); + _chatTitleChanged.SocketBase = _socketBase; + _chatTitleChanged.Json = webSocketMessage; eventCall.callChatTitleChangedEvent(client, _chatTitleChanged); break; case 113: // ChatContent Changed - Amino.Objects.ChatEvent _chatContentChanged = new Objects.ChatEvent(webSocketMessage); + Amino.Objects.ChatEvent _chatContentChanged = JsonSerializer.Deserialize(element); + _chatContentChanged.Json = webSocketMessage; + _chatContentChanged.SocketBase = _socketBase; eventCall.callChatContentChangedEvent(client, _chatContentChanged); break; case 119: // MessageForceRemovedByAdmin From 948ae515128eab3cfe830ffe6198d3f33687fe78 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Fri, 24 May 2024 00:48:24 +0200 Subject: [PATCH 15/19] reworked EventHandler --- Amino.NET/Events/EventHandler.cs | 48 +++++++++++++++++++++++-------- Amino.NET/Objects/ImageMessage.cs | 2 +- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/Amino.NET/Events/EventHandler.cs b/Amino.NET/Events/EventHandler.cs index 454705e..e28202a 100644 --- a/Amino.NET/Events/EventHandler.cs +++ b/Amino.NET/Events/EventHandler.cs @@ -76,35 +76,51 @@ public Task ReceiveEvent(string webSocketMessage, Client client) eventCall.callChatContentChangedEvent(client, _chatContentChanged); break; case 119: // MessageForceRemovedByAdmin - Amino.Objects.SpecialChatEvent _messageForceRemovedByAdmin = new Objects.SpecialChatEvent(webSocketMessage); + Amino.Objects.SpecialChatEvent _messageForceRemovedByAdmin = JsonSerializer.Deserialize(element); + _messageForceRemovedByAdmin.Json = webSocketMessage; + _messageForceRemovedByAdmin.SocketBase = _socketBase; eventCall.callMessageForceRemovedByAdminEvent(client, _messageForceRemovedByAdmin); break; case 120: // ChatTip - Amino.Objects.ChatTip _chatTip = new Objects.ChatTip(webSocketMessage); + Amino.Objects.ChatTip _chatTip = JsonSerializer.Deserialize(element); + _chatTip.Json = webSocketMessage; + _chatTip.SocketBase = _socketBase; eventCall.callChatTipEvent(client, _chatTip); break; case 121: // ChatAnnouncementPin - Amino.Objects.ChatAnnouncement _chatAnnouncementPinEvent = new Objects.ChatAnnouncement(webSocketMessage); + Amino.Objects.ChatAnnouncement _chatAnnouncementPinEvent = JsonSerializer.Deserialize(element); + _chatAnnouncementPinEvent.Json = webSocketMessage; + _chatAnnouncementPinEvent.SocketBase = _socketBase; eventCall.callChatPinAnnouncementEvent(client, _chatAnnouncementPinEvent); break; case 125: // ChatViewModeOn - Amino.Objects.ViewMode _viewModeOn = new Objects.ViewMode(webSocketMessage); + Amino.Objects.ViewMode _viewModeOn = JsonSerializer.Deserialize(element); + _viewModeOn.Json = webSocketMessage; + _viewModeOn.SocketBase = _socketBase; eventCall.callChatViewModeOnEvent(client, _viewModeOn); break; case 126: // ChatViewModeOff - Amino.Objects.ViewMode _viewModeOff = new Objects.ViewMode(webSocketMessage); + Amino.Objects.ViewMode _viewModeOff = JsonSerializer.Deserialize(element); + _viewModeOff.Json = webSocketMessage; + _viewModeOff.SocketBase = _socketBase; eventCall.callChatViewModeOffEvent(client, _viewModeOff); break; case 127: // ChatAnnouncementUnPin - Amino.Objects.ChatEvent _chatAnnouncementUnPin = new Objects.ChatEvent(webSocketMessage); + Amino.Objects.ChatEvent _chatAnnouncementUnPin = JsonSerializer.Deserialize(element); + _chatAnnouncementUnPin.Json = webSocketMessage; + _chatAnnouncementUnPin.SocketBase = _socketBase; eventCall.callChatUnpinAnnouncementEvent(client, _chatAnnouncementUnPin); break; case 128: // ChatTipEnabled - Amino.Objects.ChatTipToggle _chatTipEnabled = new Objects.ChatTipToggle(webSocketMessage); + Amino.Objects.ChatTipToggle _chatTipEnabled = JsonSerializer.Deserialize(element); + _chatTipEnabled.Json = webSocketMessage; + _chatTipEnabled.SocketBase = _socketBase; eventCall.callChatTipEnabledEvent(client, _chatTipEnabled); break; case 129: // ChatTipDisabled - Amino.Objects.ChatTipToggle _chatTipDisabled = new Objects.ChatTipToggle(webSocketMessage); + Amino.Objects.ChatTipToggle _chatTipDisabled = JsonSerializer.Deserialize(element); + _chatTipDisabled.Json = webSocketMessage; + _chatTipDisabled.SocketBase = _socketBase; eventCall.callChatTipDisabledEvent(client, _chatTipDisabled); break; @@ -112,19 +128,27 @@ public Task ReceiveEvent(string webSocketMessage, Client client) break; case 100: //ImageMessage - Amino.Objects.ImageMessage _imageMessage = new Amino.Objects.ImageMessage(webSocketMessage); + Amino.Objects.ImageMessage _imageMessage = JsonSerializer.Deserialize(element); + _imageMessage.Json = webSocketMessage; + _imageMessage.SocketBase = _socketBase; eventCall.callImageMessageEvent(client, _imageMessage); break; case 103: //YouTubeMessage - Amino.Objects.YouTubeMessage _youtubeMessage = new Objects.YouTubeMessage(webSocketMessage); + Amino.Objects.YouTubeMessage _youtubeMessage = JsonSerializer.Deserialize(element); + _youtubeMessage.Json = webSocketMessage; + _youtubeMessage.SocketBase = _socketBase; eventCall.callYouTubeMessageEvent(client, _youtubeMessage); break; case 110: //VoiceMessage - Amino.Objects.VoiceMessage _voiceMessage = new Objects.VoiceMessage(webSocketMessage); + Amino.Objects.VoiceMessage _voiceMessage = JsonSerializer.Deserialize(element); + _voiceMessage.Json = webSocketMessage; + _voiceMessage.SocketBase = _socketBase; eventCall.callVoiceMessageEvent(client, _voiceMessage); break; case 113: //StickerMessage - Amino.Objects.StickerMessage _stickerMessage = new Objects.StickerMessage(webSocketMessage); + Amino.Objects.StickerMessage _stickerMessage = JsonSerializer.Deserialize(element); + _stickerMessage.Json = webSocketMessage; + _stickerMessage.SocketBase = _socketBase; eventCall.callStickerMessageEvent(client, _stickerMessage); break; } diff --git a/Amino.NET/Objects/ImageMessage.cs b/Amino.NET/Objects/ImageMessage.cs index 3200e35..d69d46d 100644 --- a/Amino.NET/Objects/ImageMessage.cs +++ b/Amino.NET/Objects/ImageMessage.cs @@ -6,7 +6,7 @@ namespace Amino.Objects // ROOT JSON ELEMENT: o/chatMessage public class ImageMessage { - SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER + public SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER public string Json { get; set; } // NEEDS TO BE SET AFTER [JsonPropertyName("mediaValue")]public string MediaUrl { get; set; } [JsonPropertyName("threadId")]public string ChatId { get; set; } From 35c70f397f61ec91a2f1ade717837a4e64dbc29d Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Fri, 24 May 2024 01:33:37 +0200 Subject: [PATCH 16/19] started refactoring Client --- Amino.NET/Client.cs | 264 +++++++++++++++------------------- Amino.NET/Types.cs | 14 +- Amino.NET/WebSocketHandler.cs | 2 +- 3 files changed, 126 insertions(+), 154 deletions(-) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 3728be6..013fec3 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -6,8 +6,10 @@ using System.Linq; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Amino.Objects; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RestSharp; @@ -22,71 +24,71 @@ public class Client /// /// Represents the current device ID used by the current Client /// - public string deviceID { get; private set; } + public string DeviceId { get; private set; } /// /// Represents the current Session ID of the current Client / Amino account instance /// - public string sessionID { get; private set; } + public string SessionId { get; private set; } /// /// Represents the Login Secret of the current Amino account /// - public string secret { get; private set; } + public string Secret { get; private set; } /// /// Represents the current user ID (object ID) of the current Amino account /// - public string userID { get; private set; } + public string UserId { get; private set; } /// /// Represents the full JSON response of the current Amino account /// - public string json { get; private set; } + public string Json { get; private set; } /// /// Represents the google ID of the current Amino account /// - public string googleID { get; private set; } + public string GoogleId { get; private set; } /// /// Represents the apple ID of the current Amino account /// - public string appleID { get; private set; } + public string AppleId { get; private set; } /// /// Represents the facebook ID of the current Amino account /// - public string facebookID { get; private set; } + public string FacebookId { get; private set; } /// /// Represents the twitter ID of the current Amino account /// - public string twitterID { get; private set; } + public string TwitterId { get; private set; } /// /// Represents the Icon image URL of the current Amino account /// - public string iconURL { get; private set; } + public string IconUrl { get; private set; } /// /// Represents the amino ID of the current Amino account /// - public string aminoID { get; private set; } + public string AminoId { get; private set; } /// /// Represents the email address of the current Amino account /// - public string email { get; private set; } + public string Email { get; private set; } /// /// Represents the phone number of the current Amino account /// - public string phoneNumber { get; private set; } + public string PhoneNumber { get; private set; } /// /// Represents the nickname of the current Amino account /// - public string nickname { get; private set; } + public string Nickname { get; private set; } /// /// Represents if the current Amino accounts profile is profile or not /// - public bool is_Global { get; private set; } + public bool IsGlobal { get; private set; } /// /// Represents the current Clients debug state, if put to true, all API responses and webSocket messages get printed to Trace /// - public bool debug { get; set; } = false; + public bool Debug { get; set; } = false; private SubClient subClient = null; - private string UserAgent; + private string userAgent; //The value to access the websocket manager @@ -180,15 +182,15 @@ public class Client private Task headerBuilder() { headers.Clear(); - headers.Add("NDCDEVICEID", deviceID); + headers.Add("NDCDEVICEID", DeviceId); headers.Add("Accept-Language", "en-US"); headers.Add("Content-Type", "application/json; charset=utf-8"); headers.Add("Host", "service.aminoapps.com"); headers.Add("Accept-Encoding", "gzip"); headers.Add("Connection", "Keep-Alive"); - headers.Add("User-Agent", UserAgent); - headers.Add("AUID", userID); - if (sessionID != null) { headers.Add("NDCAUTH", $"sid={sessionID}"); } + headers.Add("User-Agent", userAgent); + headers.Add("AUID", UserId); + if (SessionId != null) { headers.Add("NDCAUTH", $"sid={SessionId}"); } return Task.CompletedTask; } @@ -201,9 +203,9 @@ private Task headerBuilder() /// The User Agent of your client, default: latest compatible public Client(string _deviceID = null, string userAgent = "Apple iPhone13,4 iOS v15.6.1 Main/3.12.9", string auid = null) { - this.deviceID = (_deviceID == null) ? helpers.generate_device_id() : _deviceID; - this.userID = auid == null ? Guid.NewGuid().ToString() : auid; - this.UserAgent = userAgent; + this.DeviceId = (_deviceID == null) ? helpers.generate_device_id() : _deviceID; + this.UserId = auid == null ? Guid.NewGuid().ToString() : auid; + this.userAgent = userAgent; headerBuilder(); } @@ -223,7 +225,7 @@ public Task request_verify_code(string email, bool resetPassword = false) JObject data = new JObject() { { "identity", email }, - { "deviceID", this.deviceID }, + { "deviceID", this.DeviceId }, { "type", 1 } }; if (resetPassword) @@ -262,7 +264,7 @@ public Task login(string _email, string _password = null, string _secret = null, { "email", _email }, { "v", 2 }, { "secret", (_secret == null) ? $"0 {_password}" : _secret }, - { "deviceID", deviceID }, + { "deviceID", DeviceId }, { "clientType", 100 }, { "action", "normal" }, { "timestamp", helpers.GetTimestamp() * 1000 } @@ -274,28 +276,28 @@ public Task login(string _email, string _password = null, string _secret = null, request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - json = response.Content; - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(json); - sessionID = (string)jsonObj["sid"]; - this.secret = (string)jsonObj["secret"]; - userID = (string)jsonObj["account"]["uid"]; - googleID = (string)jsonObj["account"]["googleID"]; - appleID = (string)jsonObj["account"]["appleID"]; - facebookID = (string)jsonObj["account"]["facebookID"]; - twitterID = (string)jsonObj["account"]["twitterID"]; - iconURL = (string)jsonObj["userProfile"]["icon"]; - aminoID = (string)jsonObj["account"]["aminoId"]; - email = (string)jsonObj["account"]["email"]; - phoneNumber = (string)jsonObj["account"]["phoneNumber"]; - nickname = (string)jsonObj["userProfile"]["nickname"]; - is_Global = (bool)jsonObj["userProfile"]["isGlobal"]; + Json = response.Content; + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(Json); + SessionId = (string)jsonObj["sid"]; + this.Secret = (string)jsonObj["secret"]; + UserId = (string)jsonObj["account"]["uid"]; + GoogleId = (string)jsonObj["account"]["googleID"]; + AppleId = (string)jsonObj["account"]["appleID"]; + FacebookId = (string)jsonObj["account"]["facebookID"]; + TwitterId = (string)jsonObj["account"]["twitterID"]; + IconUrl = (string)jsonObj["userProfile"]["icon"]; + AminoId = (string)jsonObj["account"]["aminoId"]; + Email = (string)jsonObj["account"]["email"]; + PhoneNumber = (string)jsonObj["account"]["phoneNumber"]; + Nickname = (string)jsonObj["userProfile"]["nickname"]; + IsGlobal = (bool)jsonObj["userProfile"]["isGlobal"]; headerBuilder(); if (connectSocket) { Amino.WebSocketHandler _webSocket = new WebSocketHandler(this); this.webSocket = _webSocket; } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -306,12 +308,12 @@ public Task login(string _email, string _password = null, string _secret = null, /// public Task logout() { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } try { JObject data = new JObject() { - { "deviceID", this.deviceID }, + { "deviceID", this.DeviceId }, { "clientType", 100 }, { "timestamp", helpers.GetTimestamp() * 1000 } }; @@ -322,21 +324,21 @@ public Task logout() request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - sessionID = null; - secret = null; - userID = null; - json = null; - googleID = null; - appleID = null; - facebookID = null; - twitterID = null; - iconURL = null; - aminoID = null; - email = null; - phoneNumber = null; - nickname = null; - is_Global = false; + if (Debug) { Trace.WriteLine(response.Content); } + SessionId = null; + Secret = null; + UserId = null; + Json = null; + GoogleId = null; + AppleId = null; + FacebookId = null; + TwitterId = null; + IconUrl = null; + AminoId = null; + Email = null; + PhoneNumber = null; + Nickname = null; + IsGlobal = false; headerBuilder(); _ = webSocket.DisconnectSocket(); if (subClient != null) @@ -360,22 +362,22 @@ public Task logout() /// public Task login_sid(string sessionId, bool fetchProfile = true, bool connectSocket = true) { - this.sessionID = sessionId; + this.SessionId = sessionId; if (fetchProfile) { Objects.UserAccount currentAccount = get_account_info(); - this.userID = currentAccount.userId; - this.googleID = currentAccount.googleID; - this.appleID = currentAccount.appleID; - this.twitterID = currentAccount.twitterID; - this.iconURL = currentAccount.iconUrl; - this.aminoID = currentAccount.aminoId; - this.email = currentAccount.email; - this.phoneNumber = currentAccount.phoneNumber; - this.nickname = currentAccount.nickName; - this.is_Global = true; + this.UserId = currentAccount.UserId; + this.GoogleId = currentAccount.GoogleId; + this.AppleId = currentAccount.AppleId; + this.TwitterId = currentAccount.TwitterId; + this.IconUrl = currentAccount.IconUrl; + this.AminoId = currentAccount.AminoId; + this.Email = currentAccount.Email; + this.PhoneNumber = currentAccount.PhoneNumber; + this.Nickname = currentAccount.Nickname; + this.IsGlobal = true; } headerBuilder(); @@ -423,7 +425,7 @@ public Task register_google(string nickname, string googleToken, string password var response = client.ExecutePost(request); if((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if(debug) { Trace.WriteLine(response.Content); } + if(Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -442,7 +444,7 @@ public Task register_google(string nickname, string googleToken, string password /// public Task register(string _name, string _email, string _password, string _verificationCode, string _deviceID = null) { - if (_deviceID == null) { if (deviceID != null) { _deviceID = deviceID; } else { _deviceID = helpers.generate_device_id(); } } + if (_deviceID == null) { if (DeviceId != null) { _deviceID = DeviceId; } else { _deviceID = helpers.generate_device_id(); } } JObject data = new JObject() { { "secret", $"0 {_password}" }, @@ -472,7 +474,7 @@ public Task register(string _name, string _email, string _password, string _veri request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -502,7 +504,7 @@ public Task restore_account(string _email, string _password, string _deviceID = request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } catch (Exception e) { throw new Exception(e.Message); } @@ -516,7 +518,7 @@ public Task restore_account(string _email, string _password, string _deviceID = /// public Task delete_account(string _password) { - JObject data = new JObject() { { "deviceID", deviceID }, { "secret", $"0 {_password}" } }; + JObject data = new JObject() { { "deviceID", DeviceId }, { "secret", $"0 {_password}" } }; RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/account/delete-request"); request.AddHeaders(headers); @@ -524,21 +526,21 @@ public Task delete_account(string _password) request.AddJsonBody(data); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - sessionID = null; - secret = null; - userID = null; - json = null; - googleID = null; - appleID = null; - facebookID = null; - twitterID = null; - iconURL = null; - aminoID = null; - email = null; - phoneNumber = null; - nickname = null; - is_Global = false; + if (Debug) { Trace.WriteLine(response.Content); } + SessionId = null; + Secret = null; + UserId = null; + Json = null; + GoogleId = null; + AppleId = null; + FacebookId = null; + TwitterId = null; + IconUrl = null; + AminoId = null; + Email = null; + PhoneNumber = null; + Nickname = null; + IsGlobal = false; headerBuilder(); _ = webSocket.DisconnectSocket(); return Task.CompletedTask; @@ -554,7 +556,7 @@ public Task delete_account(string _password) /// public Task activate_account(string _email, string _verificationCode, string _deviceID = null) { - if (_deviceID == null) { if (deviceID != null) { _deviceID = deviceID; } else { _deviceID = helpers.generate_device_id(); } } + if (_deviceID == null) { if (DeviceId != null) { _deviceID = DeviceId; } else { _deviceID = helpers.generate_device_id(); } } JObject data = new JObject() { @@ -570,7 +572,7 @@ public Task activate_account(string _email, string _verificationCode, string _de request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -582,7 +584,7 @@ public Task activate_account(string _email, string _verificationCode, string _de /// public Task configure_account(Types.account_gender _gender = Types.account_gender.Non_Binary, int _age = 18) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (_age <= 12) { throw new Exception("The given account age is too low"); } JObject data = new JObject() { @@ -598,7 +600,7 @@ public Task configure_account(Types.account_gender _gender = Types.account_gende request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -611,7 +613,7 @@ public Task configure_account(Types.account_gender _gender = Types.account_gende /// public Task change_password(string _email, string _password, string _verificationCode) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject() { { "updateSecret", $"0 {_password}" }, @@ -621,11 +623,11 @@ public Task change_password(string _email, string _password, string _verificatio { "type", 1 }, { "identity", _email }, { "level", 2 }, - { "deviceID", this.deviceID } + { "deviceID", this.DeviceId } } }, { "phoneNumberValidationContext", String.Empty }, - { "deviceID", this.deviceID } + { "deviceID", this.DeviceId } }; try @@ -637,7 +639,7 @@ public Task change_password(string _email, string _password, string _verificatio request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } catch (Exception e) { throw new Exception(e.Message); } @@ -655,8 +657,8 @@ public Amino.Objects.GlobalProfile get_user_info(string _userId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - Amino.Objects.GlobalProfile profile = new Amino.Objects.GlobalProfile((JObject)JObject.Parse(response.Content)); + if (Debug) { Trace.WriteLine(response.Content); } + Amino.Objects.GlobalProfile profile = System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("userAccount").GetRawText()); return profile; } @@ -689,7 +691,7 @@ public bool check_device(string _deviceId) request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { return false; } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return true; } catch (Exception e) { throw new Exception(e.Message); } @@ -701,14 +703,14 @@ public bool check_device(string _deviceId) /// Object : Amino.Objects.EventLog public Amino.Objects.EventLog get_event_log() { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/eventlog/profile?language=en"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - Amino.Objects.EventLog eventLog = new Amino.Objects.EventLog(JObject.Parse(response.Content)); + if (Debug) { Trace.WriteLine(response.Content); } + Amino.Objects.EventLog eventLog = System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); return eventLog; } @@ -722,25 +724,17 @@ public Amino.Objects.EventLog get_event_log() /// List : Amino.Objects.Community public List get_subClient_communities(int start = 0, int size = 25) { - List communityList = new List(); - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/community/joined?v=1&start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray _jsonArray = jsonObj["communityList"]; - foreach (JObject _communityJson in _jsonArray) - { - Amino.Objects.Community community = new Objects.Community(_communityJson); - communityList.Add(community); - } - return communityList; + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("communityList").GetRawText()); } /// @@ -751,27 +745,16 @@ public Amino.Objects.EventLog get_event_log() /// List : Amino.Objects.CommunityProfile public List get_subClient_profiles(int start = 0, int size = 25) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List profileList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/community/joined?v=1&start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - var profiles = ((JObject)JObject.Parse(response.Content)["userInfoInCommunities"]) - .Properties() - .Select(x => x.Value) - .Cast() - .ToList(); - foreach (var profile in profiles) - { - Objects.GenericProfile C_Profile = new Objects.GenericProfile(profile); - profileList.Add(C_Profile); - } + if (Debug) { Trace.WriteLine(response.Content); } - return profileList; + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userInfoInCommunities").GetRawText()); } /// @@ -780,15 +763,14 @@ public Amino.Objects.EventLog get_event_log() /// Object : Amino.Objects.UserAccount public Objects.UserAccount get_account_info() { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/account"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - Objects.UserAccount account = new Objects.UserAccount(JObject.Parse(response.Content)); - return account; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -799,27 +781,17 @@ public Objects.UserAccount get_account_info() /// List : Amino.Objects.Chat public List get_chat_threads(int start = 0, int size = 25) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } - - List chatList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/chat/thread?type=joined-me&start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray _chatList = jsonObj["threadList"]; - foreach (JObject chatJson in _chatList) - { - Objects.Chat chat = new Objects.Chat(chatJson); - - chatList.Add(chat); - } - return chatList; + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("threadList").GetRawText()); } diff --git a/Amino.NET/Types.cs b/Amino.NET/Types.cs index b6293a3..e39aec1 100644 --- a/Amino.NET/Types.cs +++ b/Amino.NET/Types.cs @@ -240,13 +240,13 @@ public enum Comment_Types public enum Supported_Languages { - english, - spanish, - portuguese, - arabic, - russian, - french, - german + English, + Spanish, + Portuguese, + Arabic, + Russian, + French, + German } public enum Wallet_Config_Levels diff --git a/Amino.NET/WebSocketHandler.cs b/Amino.NET/WebSocketHandler.cs index 6252106..7ffa880 100644 --- a/Amino.NET/WebSocketHandler.cs +++ b/Amino.NET/WebSocketHandler.cs @@ -76,7 +76,7 @@ private async Task StartWebSocket(Amino.Client _client) { Trace.WriteLine($"WebSocket: Received Message: {msg.Text}"); } - eventHandler.ReceiveEvent(JObject.Parse(msg.Text), _client); + eventHandler.ReceiveEvent(msg.Text, _client); }); await ws_client.Start(); From b870078cd9e51c8dbaa091ad633c590ddb39035f Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 26 May 2024 03:42:51 +0200 Subject: [PATCH 17/19] refactored Client return types --- Amino.NET/Client.cs | 412 ++++++++------------- Amino.NET/Objects/AdvancedCommunityInfo.cs | 3 +- Amino.NET/Objects/UserProfile.cs | 2 +- Amino.NET/helpers.cs | 4 +- 4 files changed, 149 insertions(+), 272 deletions(-) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 013fec3..b94daa0 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -237,7 +237,7 @@ public Task request_verify_code(string email, bool resetPassword = false) request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -802,17 +802,15 @@ public Objects.UserAccount get_account_info() /// Object : Amino.Objects.Chat public Objects.Chat get_chat_thread(string chatId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - Objects.Chat chat = new Objects.Chat(jsonObj["thread"]); - return chat; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("thread").GetRawText()); } /// @@ -824,23 +822,15 @@ public Objects.Chat get_chat_thread(string chatId) /// List : Amino.Objects.ChatMember public List get_chat_users(string chatId, int start = 0, int size = 25) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List chatMembers = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/member?start={start}&size={size}&type=default&cv=1.2"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray chatUserList = jsonObj["memberList"]; - foreach (JObject chatUser in chatUserList) - { - Objects.ChatMember member = new Objects.ChatMember(chatUser); - chatMembers.Add(member); - } - return chatMembers; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("memberList").GetRawText()); } /// /// Allows you to join a chat with the current Amino account @@ -849,13 +839,13 @@ public Objects.Chat get_chat_thread(string chatId) /// public Task join_chat(string chatId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/member/{userID}"); + RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/member/{UserId}"); request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -866,14 +856,14 @@ public Task join_chat(string chatId) /// public Task leave_chat(string chatId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/member/{userID}"); + RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/member/{UserId}"); request.AddHeaders(headers); request.Method = Method.Delete; var response = client.Execute(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -885,7 +875,7 @@ public Task leave_chat(string chatId) /// public Task invite_to_chat(string[] userIds, string chatId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject(); data.Add("timestamp", (Math.Round(helpers.GetTimestamp())) * 1000); data.Add("uids", JToken.FromObject(new { userIds })); @@ -897,7 +887,7 @@ public Task invite_to_chat(string[] userIds, string chatId) var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -911,14 +901,14 @@ public Task invite_to_chat(string[] userIds, string chatId) public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true) { int _allowRejoin; - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (allowRejoin) { _allowRejoin = 1; } else { _allowRejoin = 0; } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/member/{userId}?allowRejoin={_allowRejoin}"); request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -931,48 +921,32 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true /// List : Amino.Objects.MessageCollection public List get_chat_messages(string chatId, int size = 25, string pageToken = null) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } string endPoint; if (!string.IsNullOrEmpty(pageToken) || !string.IsNullOrWhiteSpace(pageToken)) { endPoint = $"/g/s/chat/thread/{chatId}/message?v=2&pagingType=t&pageToken={pageToken}&size={size}"; } else { endPoint = $"/g/s/chat/thread/{chatId}/message?v=2&pagingType=t&size={size}"; } - List messageCollection = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest(endPoint); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray chatMessageList = jsonObj["messageList"]; // no need - foreach (JObject chatMessage in chatMessageList) - { - Objects.MessageCollection message = new Objects.MessageCollection(chatMessage, JObject.Parse(response.Content)); - messageCollection.Add(message); - } - return messageCollection; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// - /// Allows you to search a community based on its ID (aminoId not objectId) and get information about it + /// Allows you to search a community based on its ID (aminoId not objectId) and get information about it"/> /// /// /// List : Amino.Objects.CommunityInfo public List search_community(string aminoId) { - List communityInfoList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/search/amino-id-and-link?q={aminoId}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray communityInfo = jsonObj["resultList"]; - foreach (JObject community in communityInfo) - { - Objects.CommunityInfo com = new Objects.CommunityInfo(community); - communityInfoList.Add(com); - } - return communityInfoList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("resultList").GetRawText()); } /// @@ -982,24 +956,16 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true /// /// /// List : Amino.Objects.UserFollowings - public List get_user_following(string userId, int start = 0, int size = 25) + public List get_user_following(string userId, int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List userFollowingsList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/user-profile/{userId}/joined?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray userFollowings = jsonObj["userProfileList"]; - foreach (JObject following in userFollowings) - { - Objects.UserFollowings _following = new Objects.UserFollowings(following); - userFollowingsList.Add(_following); - } - return userFollowingsList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } /// @@ -1009,24 +975,16 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true /// /// /// List : Amino.Obejcts.UserFollowings - public List get_user_followers(string userId, int start = 0, int size = 25) + public List get_user_followers(string userId, int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List userFollowerList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/user-profile/{userId}/member?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray userFollowers = jsonObj["userProfileList"]; - foreach (JObject follower in userFollowers) - { - Objects.UserFollowings _follower = new Objects.UserFollowings(follower); - userFollowerList.Add(_follower); - } - return userFollowerList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } @@ -1040,21 +998,13 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true public List get_user_visitors(string userId, int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List userVisitorList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/user-profile/{userId}/visitors?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray userVisitors = jsonObj["visitors"]; - foreach (JObject visitor in userVisitors) - { - Objects.UserVisitor _visitor = new Objects.UserVisitor(visitor, jsonObj); - userVisitorList.Add(_visitor); - } - return userVisitorList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("visitors").GetRawText()); } /// @@ -1063,25 +1013,17 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true /// /// /// List : Amino.Objects.BlockedUser - public List get_blocked_users(int start = 0, int size = 25) + public List get_blocked_users(int start = 0, int size = 25) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List blockedUserList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/block?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.StatusCode); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray blockedUsers = jsonObj["userProfileList"]; - foreach (JObject user in blockedUsers) - { - Objects.BlockedUser _blockedUser = new Objects.BlockedUser(user); - blockedUserList.Add(_blockedUser); - } - return blockedUserList; + if (Debug) { Trace.WriteLine(response.StatusCode); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } /// @@ -1092,7 +1034,7 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true /// List : string public List get_blocker_users(int start = 0, int size = 25) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } List blockerUserList = new List(); RestClient client = new RestClient(helpers.BaseUrl); @@ -1100,14 +1042,9 @@ public List get_blocker_users(int start = 0, int size = 25) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray blockerUsers = jsonObj["blockerUidList"]; - foreach (var user in blockerUsers) - { - blockerUserList.Add(user.ToString()); - } - return blockerUserList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("blockedUidList").GetRawText()); + } /// @@ -1143,15 +1080,8 @@ public List get_blocker_users(int start = 0, int size = 25) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray comments = jsonObj["commentList"]; - foreach (JObject comment in comments) - { - Objects.Comment _comment = new Objects.Comment(comment); - commentList.Add(_comment); - } - return commentList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("commentList").GetRawText()); } /// @@ -1165,7 +1095,7 @@ public List get_blocker_users(int start = 0, int size = 25) /// public Task flag(string reason, Types.Flag_Types flagType, Types.Flag_Targets targetType, string targetId, bool asGuest) { - if (!asGuest) { if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } } + if (!asGuest) { if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } } string _flag = asGuest ? "g-flag" : "flag"; RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/{_flag}"); @@ -1182,7 +1112,7 @@ public Task flag(string reason, Types.Flag_Types flagType, Types.Flag_Targets ta request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1196,7 +1126,7 @@ public Task flag(string reason, Types.Flag_Types flagType, Types.Flag_Targets ta /// public Task delete_message(string chatId, string messageId, bool asStaff = false, string reason = null) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject() { { "adminOpName", 102 }, @@ -1211,7 +1141,7 @@ public Task delete_message(string chatId, string messageId, bool asStaff = false request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } /// @@ -1222,7 +1152,7 @@ public Task delete_message(string chatId, string messageId, bool asStaff = false /// public Task mark_as_read(string _chatId, string _messageId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject() { { "messageId", _messageId }, @@ -1235,7 +1165,7 @@ public Task mark_as_read(string _chatId, string _messageId) request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1251,7 +1181,7 @@ public Task visit(string userId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1262,13 +1192,13 @@ public Task visit(string userId) /// public Task follow_user(string userId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/user-profile/{userId}/member"); request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1279,13 +1209,13 @@ public Task follow_user(string userId) /// public Task unfollow_user(string _userId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/g/s/user-profile/{_userId}/member/{userID}"); + RestRequest request = new RestRequest($"/g/s/user-profile/{_userId}/member/{UserId}"); request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } /// @@ -1295,13 +1225,13 @@ public Task unfollow_user(string _userId) /// public Task block_user(string _userId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/block/{_userId}"); request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1312,13 +1242,13 @@ public Task block_user(string _userId) /// public Task unblock_user(string _userId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/block/{_userId}"); request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1330,7 +1260,7 @@ public Task unblock_user(string _userId) /// public Task join_community(string communityId, string invitationCode = null) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject(); data.Add("timestamp", helpers.GetTimestamp() * 1000); if (invitationCode != null) { data.Add("invitationId", invitationCode); } @@ -1341,7 +1271,7 @@ public Task join_community(string communityId, string invitationCode = null) request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1353,7 +1283,7 @@ public Task join_community(string communityId, string invitationCode = null) /// public Task join_community_request(string communityId, string message = null) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/community/membership-request"); var data = new JObject() @@ -1366,7 +1296,7 @@ public Task join_community_request(string communityId, string message = null) request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1377,13 +1307,13 @@ public Task join_community_request(string communityId, string message = null) /// public Task leave_community(string communityId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/s/community/leave"); request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1397,7 +1327,7 @@ public Task leave_community(string communityId) /// public Task flag_community(string communityId, string reason, Types.Flag_Types flagType, bool asGuest = false) { - if (!asGuest) { if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } } + if (!asGuest) { if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } } int _flagType; string _flag = asGuest ? "g-flag" : "flag"; JObject data = new JObject() @@ -1415,7 +1345,7 @@ public Task flag_community(string communityId, string reason, Types.Flag_Types f request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1444,7 +1374,7 @@ public string upload_media(string filePath, Types.upload_File_Types type) /// string : The URL to the media file you just uploaded public string upload_media(byte[] file, Types.upload_File_Types type) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } string _fileType; switch (type) { @@ -1469,7 +1399,7 @@ public string upload_media(byte[] file, Types.upload_File_Types type) request.AddBody(file, _fileType); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); return jsonObj["mediaValue"]; @@ -1486,7 +1416,7 @@ public string upload_media(byte[] file, Types.upload_File_Types type) /// public Task edit_profile(string nickname = null, string content = null, byte[] icon = null, string backgroundColor = null, string backgroundMediaUrl = null, string defaultChatbubbleId = null) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject(); data.Add("address", null); data.Add("latitude", 0); @@ -1539,13 +1469,13 @@ public Task edit_profile(string nickname = null, string content = null, byte[] i } RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"g/s/user-profile/{userID}"); + RestRequest request = new RestRequest($"g/s/user-profile/{UserId}"); request.AddHeaders(headers); request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data.ToString()))); request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1557,7 +1487,7 @@ public Task edit_profile(string nickname = null, string content = null, byte[] i /// public Task set_privacy_status(bool isAnonymous = false, bool getNotifications = true) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } int _privacyMode = isAnonymous ? 2 : 1; int _notificationStatus = getNotifications ? 2 : 1; JObject data = new JObject() @@ -1573,7 +1503,7 @@ public Task set_privacy_status(bool isAnonymous = false, bool getNotifications = request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1584,7 +1514,7 @@ public Task set_privacy_status(bool isAnonymous = false, bool getNotifications = /// public Task set_amino_id(string aminoId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject() { { "timestamp", helpers.GetTimestamp() * 1000 }, @@ -1597,7 +1527,7 @@ public Task set_amino_id(string aminoId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1608,13 +1538,13 @@ public Task set_amino_id(string aminoId) /// public Task add_linked_community(int communityId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/g/s/user-profile/{userID}/linked-community/{communityId}"); + RestRequest request = new RestRequest($"/g/s/user-profile/{UserId}/linked-community/{communityId}"); request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1625,13 +1555,13 @@ public Task add_linked_community(int communityId) /// public Task remove_linked_community(int communityId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/g/s/user-profile/{userID}/linked-community/{communityId}"); + RestRequest request = new RestRequest($"/g/s/user-profile/{UserId}/linked-community/{communityId}"); request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1644,7 +1574,7 @@ public Task remove_linked_community(int communityId) /// public Task comment(string message, Types.Comment_Types type, string objectId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } string _eventSource; bool _isReply = false; RestClient client = new RestClient(helpers.BaseUrl); @@ -1685,7 +1615,7 @@ public Task comment(string message, Types.Comment_Types type, string objectId) request.AddJsonBody(data); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1698,7 +1628,7 @@ public Task comment(string message, Types.Comment_Types type, string objectId) /// public Task delete_comment(string commentId, Types.Comment_Types type, string objectId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(); RestRequest request = new RestRequest(); switch (type) @@ -1719,7 +1649,7 @@ public Task delete_comment(string commentId, Types.Comment_Types type, string ob request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1731,7 +1661,7 @@ public Task delete_comment(string commentId, Types.Comment_Types type, string ob /// public Task like_post(string objectId, Types.Post_Types type) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } string _eventSource; RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest(); @@ -1761,7 +1691,7 @@ public Task like_post(string objectId, Types.Post_Types type) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1773,7 +1703,7 @@ public Task like_post(string objectId, Types.Post_Types type) /// public Task unlike_post(string objectId, Types.Post_Types type) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest(); request.AddHeaders(headers); @@ -1792,7 +1722,7 @@ public Task unlike_post(string objectId, Types.Post_Types type) } var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1802,15 +1732,14 @@ public Task unlike_post(string objectId, Types.Post_Types type) /// Object : Amino.Objects.MembershipInfo public Objects.MembershipInfo get_membership_info() { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/membership?force=true"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - Objects.MembershipInfo membershipInfo = new Objects.MembershipInfo(JObject.Parse(response.Content)); - return membershipInfo; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -1820,31 +1749,31 @@ public Objects.MembershipInfo get_membership_info() /// /// /// List : Obejcts.Amino.Post - public List get_ta_announcements(Types.Supported_Languages language = Types.Supported_Languages.english, int start = 0, int size = 25) + public List get_ta_announcements(Types.Supported_Languages language = Types.Supported_Languages.English, int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } string _language; switch (language) { - case Types.Supported_Languages.english: + case Types.Supported_Languages.English: _language = "en"; break; - case Types.Supported_Languages.spanish: + case Types.Supported_Languages.Spanish: _language = "es"; break; - case Types.Supported_Languages.portuguese: + case Types.Supported_Languages.Portuguese: _language = "pt"; break; - case Types.Supported_Languages.arabic: + case Types.Supported_Languages.Arabic: _language = "ar"; break; - case Types.Supported_Languages.russian: + case Types.Supported_Languages.Russian: _language = "ru"; break; - case Types.Supported_Languages.french: + case Types.Supported_Languages.French: _language = "fr"; break; - case Types.Supported_Languages.german: + case Types.Supported_Languages.German: _language = "de"; break; default: @@ -1856,16 +1785,8 @@ public Objects.MembershipInfo get_membership_info() request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray announcements = jsonObj["blogList"]; - List ta_announcements = new List(); - foreach (JObject post in announcements) - { - Objects.Post _post = new Objects.Post(post); - ta_announcements.Add(_post); - } - return ta_announcements; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("blogList").GetRawText()); } /// @@ -1874,16 +1795,14 @@ public Objects.MembershipInfo get_membership_info() /// Object : Objects.WalletInfo public Objects.WalletInfo get_wallet_info() { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/wallet"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - JObject jsonObj = JObject.Parse(response.Content); - Objects.WalletInfo _walletInfo = new Objects.WalletInfo(jsonObj); - return _walletInfo; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -1894,23 +1813,15 @@ public Objects.WalletInfo get_wallet_info() /// List : Amino.Objects.CoinHistoryEntry public List get_wallet_history(int start = 0, int size = 25) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/wallet/coin/history?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray historyEntry = jsonObj["coinHistoryList"]; - List coinHistoryList = new List(); - foreach (JObject entry in historyEntry) - { - Objects.CoinHistoryEntry _entry = new Objects.CoinHistoryEntry(entry); - coinHistoryList.Add(_entry); - } - return coinHistoryList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("coinHistoryList").GetRawText()); } /// @@ -1925,10 +1836,8 @@ public string get_from_deviceId(string deviceId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - Console.WriteLine(response.Content); - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - return jsonObj["auid"]; + if (Debug) { Trace.WriteLine(response.Content); } + return JsonDocument.Parse(response.Content).RootElement.GetProperty("auid").GetString(); } /// @@ -1943,10 +1852,8 @@ public Objects.FromCode get_from_code(string aminoUrl) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - Amino.Objects.FromCode fromCode = new Objects.FromCode(jsonObj); - return fromCode; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -1956,9 +1863,9 @@ public Objects.FromCode get_from_code(string aminoUrl) /// /// /// Object : Amino.Objects.FromId - public Objects.FromId get_from_id(string objectId, Amino.Types.Object_Types type, string communityId = null) + public Objects.FromCode get_from_id(string objectId, Amino.Types.Object_Types type, string communityId = null) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject() { { "objectId", objectId }, @@ -1978,10 +1885,8 @@ public Objects.FromId get_from_id(string objectId, Amino.Types.Object_Types type request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - Amino.Objects.FromId fromId = new Objects.FromId(jsonObj); - return fromId; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -1995,16 +1900,8 @@ public string[] get_supported_languages() request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - Console.WriteLine(response.Content); - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray languageArray = jsonObj["supportedLanguages"]; - List langList = new List(); - foreach (JObject language in languageArray) - { - langList.Add(language.ToString()); - } - return langList.ToArray(); + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("suppotedLanguages").GetRawText()).ToArray(); } /// @@ -2013,13 +1910,13 @@ public string[] get_supported_languages() /// public Task claim_new_user_coupon() { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/coupon/new-user-coupon/claim"); request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -2033,21 +1930,13 @@ public Task claim_new_user_coupon() public List get_all_users(int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List userList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/user-profile?type=recent&start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray userArray = jsonObj["userProfileList"]; - foreach (JObject user in userArray) - { - Objects.UserProfile _user = new Objects.UserProfile(user); - userList.Add(_user); - } - return userList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } /// @@ -2063,10 +1952,8 @@ public Objects.AdvancedCommunityInfo get_community_info(string communityId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - Objects.AdvancedCommunityInfo community = new Objects.AdvancedCommunityInfo(jsonObj); - return community; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("community").GetRawText()); } /// @@ -2088,7 +1975,7 @@ public Objects.AdvancedCommunityInfo get_community_info(int communityId) /// public Task accept_host(string chatId, string requestId) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/transfer-organizer/{requestId}/accept"); request.AddHeaders(headers); @@ -2097,7 +1984,7 @@ public Task accept_host(string chatId, string requestId) request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -2127,10 +2014,9 @@ public Amino.Objects.FromInvite link_identify(string inviteCode) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } JObject json = JObject.Parse(response.Content); - Objects.FromInvite fromInvite = new Objects.FromInvite(json); - return fromInvite; + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -2140,7 +2026,7 @@ public Amino.Objects.FromInvite link_identify(string inviteCode) /// public Task wallet_config(Types.Wallet_Config_Levels walletLevel) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } JObject data = new JObject() { { "adsLevel", (int)walletLevel }, @@ -2153,7 +2039,7 @@ public Task wallet_config(Types.Wallet_Config_Levels walletLevel) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -2165,23 +2051,15 @@ public Task wallet_config(Types.Wallet_Config_Levels walletLevel) /// List : Amino.Object.AvatarFrame public List get_avatar_frames(int start = 0, int size = 25) { - if (sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List _avataFrameList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s/avatar-frame?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray avatarFrameArrray = jsonObj["avatarFrameList"]; - foreach (JObject avatarFrame in avatarFrameArrray) - { - Objects.AvatarFrame _avatarFrame = new Objects.AvatarFrame(avatarFrame); - _avataFrameList.Add(_avatarFrame); - } - return _avataFrameList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("avatarFrameList").GetRawText()); } /// @@ -2208,7 +2086,7 @@ public Task invite_to_vc(string chatId, string userId) var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -2251,8 +2129,8 @@ public Objects.Message send_message(string message, string chatId, Types.Message request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - return new Objects.Message(JObject.Parse(response.Content)); + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -2299,7 +2177,7 @@ public Task send_file_message(string chatId, byte[] file, Types.upload_File_Type request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -2353,7 +2231,7 @@ public Task send_embed(string chatId, string content = null, string embedId = nu request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -2403,7 +2281,7 @@ public Task send_sticker(string chatId, string stickerId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -2420,8 +2298,8 @@ public Objects.Blog get_blog_info(string blogId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if(debug) { Trace.WriteLine(response.Content); } - return new Objects.Blog(JObject.Parse(response.Content)); + if(Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } @@ -2438,8 +2316,8 @@ public Objects.Wiki get_wiki_info(string wikiId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if(debug) { Trace.WriteLine(response.Content); } - return new Objects.Wiki(JObject.Parse(response.Content)); + if(Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -2456,8 +2334,8 @@ public Objects.Message get_message_info(string chatId, string messageId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if(debug) { Trace.WriteLine(response.Content); } - return new Objects.Message(JObject.Parse(response.Content)); + if(Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } /// @@ -2489,7 +2367,7 @@ public Objects.Message get_message_info(string chatId, string messageId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if(debug) { Trace.WriteLine(response.Content); } + if(Debug) { Trace.WriteLine(response.Content); } return null; // FINISH LATER diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs index cc51728..744f747 100644 --- a/Amino.NET/Objects/AdvancedCommunityInfo.cs +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -1,4 +1,5 @@ -using System.Text.Json.Serialization; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Amino.Objects { diff --git a/Amino.NET/Objects/UserProfile.cs b/Amino.NET/Objects/UserProfile.cs index c7c8042..9732fac 100644 --- a/Amino.NET/Objects/UserProfile.cs +++ b/Amino.NET/Objects/UserProfile.cs @@ -14,7 +14,7 @@ public class UserProfile [JsonPropertyName("modifiedTime")]public string ModifiedTime { get; set; } [JsonPropertyName("followingStatus")]public int FollowingStatus { get; set; } [JsonPropertyName("onlineStatus")]public int OnlineStatus { get; set; } - [JsonPropertyName("accountMembership")]public int AccountMembershipStatus { get; set; } + [JsonPropertyName("accountMembershipStatus")]public int AccountMembershipStatus { get; set; } [JsonPropertyName("isGlobal")]public bool IsGlobal { get; set; } [JsonPropertyName("reputation")]public int Reputation { get; set; } [JsonPropertyName("postsCount")]public int PostsCount { get; set; } diff --git a/Amino.NET/helpers.cs b/Amino.NET/helpers.cs index 757cf09..666c23a 100644 --- a/Amino.NET/helpers.cs +++ b/Amino.NET/helpers.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using System.Text.Json; @@ -257,8 +258,5 @@ public static dynamic DecodeSid(string session) public static string sid_to_ip_address(string session) { return DecodeSid(session)["4"]; } public static string sid_created_time(string session) { return DecodeSid(session)["5"]; } public static string sid_to_client_type(string session) { return DecodeSid(session)["6"]; } - - - } } From f154cfca58eb6419ea295709e2cdd0089a6ca9dc Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 26 May 2024 03:59:40 +0200 Subject: [PATCH 18/19] stated refactoring of SubClient --- Amino.NET/SubClient.cs | 201 +++++++++++++++++------------------------ 1 file changed, 82 insertions(+), 119 deletions(-) diff --git a/Amino.NET/SubClient.cs b/Amino.NET/SubClient.cs index 673bb28..cce815c 100644 --- a/Amino.NET/SubClient.cs +++ b/Amino.NET/SubClient.cs @@ -1,4 +1,5 @@ using Amino.NET.Builders; +using Amino.Objects; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RestSharp; @@ -11,6 +12,7 @@ using System.Reactive.Subjects; using System.Runtime.Serialization.Formatters; using System.Text; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -20,7 +22,7 @@ public class SubClient { private Amino.Client client; - public bool debug { get; set; } + public bool Debug { get; set; } private string communityId; @@ -32,15 +34,15 @@ public class SubClient private Task headerBuilder() { headers.Clear(); - headers.Add("NDCDEVICEID", client.deviceID); + headers.Add("NDCDEVICEID", client.DeviceId); headers.Add("Accept-Language", "en-US"); headers.Add("Content-Type", "application/json; charset=utf-8"); headers.Add("Host", "service.aminoapps.com"); headers.Add("Accept-Encoding", "gzip"); headers.Add("Connection", "Keep-Alive"); headers.Add("User-Agent", "Apple iPhone13,4 iOS v15.6.1 Main/3.12.9"); - headers.Add("AUID", this.client.userID); - if (client.sessionID != null) { headers.Add("NDCAUTH", $"sid={client.sessionID}"); } + headers.Add("AUID", this.client.UserId); + if (client.SessionId != null) { headers.Add("NDCAUTH", $"sid={client.SessionId}"); } return Task.CompletedTask; } @@ -51,9 +53,9 @@ private Task headerBuilder() /// public SubClient(Amino.Client _client, string _communityId) { - if (_client.sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (_client.SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } client = _client; - debug = client.debug; + Debug = client.Debug; communityId = _communityId; headerBuilder(); } @@ -65,9 +67,9 @@ public SubClient(Amino.Client _client, string _communityId) /// public SubClient(Amino.Client _client, int _communityId) { - if (_client.sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + if (_client.SessionId == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } client = _client; - debug = client.debug; + Debug = client.Debug; communityId = _communityId.ToString(); headerBuilder(); } @@ -82,22 +84,13 @@ public SubClient(Amino.Client _client, int _communityId) /// public List get_invite_codes(string status = "normal", int start = 0, int size = 25) { - List inviteCodeList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s-x{communityId}/community/invitation?status={status}&start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray inviteCodesJson = jsonObj["communityInvitationList"]; - foreach (JObject code in inviteCodesJson) - { - Amino.Objects.InviteCode invCode = new Objects.InviteCode(code); - inviteCodeList.Add(invCode); - } - Console.WriteLine(response.Content); - return inviteCodeList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("communityInvitationList").GetRawText()); } @@ -120,7 +113,7 @@ public Task generate_invite_code(int duration = 0, bool force = true) request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -136,7 +129,7 @@ public Task delete_invite_code(string inviteId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -188,7 +181,7 @@ public Task post_blog(string title, string content, IEnumerable imageLis request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -255,7 +248,7 @@ public Task post_wiki(string title, string content, IEnumerable imageLis request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -308,7 +301,7 @@ public Task edit_blog(string blogId, string title = null, string content = null, request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -325,7 +318,7 @@ public Task delete_blog(string blogId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -341,7 +334,7 @@ public Task delete_wiki(string wikiId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -367,7 +360,7 @@ public Task repost_blog(string postId, Types.Repost_Types type, string content = request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -390,7 +383,7 @@ public Task check_in(int? timezone = null) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -411,7 +404,7 @@ public Task repair_check_in(Types.Repair_Types repairType) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -434,7 +427,7 @@ public Task lottery(int? timezone = null) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -481,13 +474,13 @@ public Task edit_profile(string nickname = null, string content = null, byte[] i if (icon != null) { data.Add("icon", this.client.upload_media(icon, Types.upload_File_Types.Image)); } RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.userID}"); + RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.UserId}"); request.AddHeaders(headers); request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) throw new Exception(response.Content); - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -510,7 +503,7 @@ public Task vote_poll(string postId, string optionId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -558,7 +551,7 @@ public Task comment(string message, Amino.Types.Comment_Types type, string targe request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -593,7 +586,7 @@ public Task delete_comment(string commentId, Amino.Types.Comment_Types type, str request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -619,7 +612,7 @@ public Task like_post(string postId, bool isWiki = false) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -639,7 +632,7 @@ public Task unlike_post(string postId, bool isWiki = false) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -669,7 +662,7 @@ public Task like_comment(string commentId, string targetId, Types.Comment_Types request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -694,7 +687,7 @@ public Task unlike_comment(string commentId, string targetId, Amino.Types.Commen request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -718,7 +711,7 @@ public Task upvote_comment(string commentId, string postId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -742,7 +735,7 @@ public Task downvote_comment(string commentId, string postId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -758,7 +751,7 @@ public Task unvote_comment(string commentId, string postId) RestRequest request = new RestRequest($"/x{communityId}/s/blog/{postId}/comment/{commentId}/vote?eventSource=PostDetailView"); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -786,7 +779,7 @@ public Task reply_wall(string userId, string commentId, string message) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -803,13 +796,13 @@ public Task set_activity_status(Types.Activity_Status_Types status) data.Add("timestamp", helpers.GetTimestamp() * 1000); RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.userID}/online-status"); + RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.UserId}/online-status"); request.AddHeaders(headers); request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -824,7 +817,7 @@ public Task check_notification() request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -840,7 +833,7 @@ public Task delete_notification(string notificationId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -855,7 +848,7 @@ public Task clear_notifications() request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -891,7 +884,7 @@ public Task send_activity_time() request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; @@ -926,7 +919,7 @@ public Task start_chat(List userIds, string message, string title = null request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -965,7 +958,7 @@ public Task invite_to_chat(List userIds, string chatId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -993,7 +986,7 @@ public Task add_to_favorites(string userId) request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1038,7 +1031,7 @@ public Task send_coins(string targetId, int coins, Types.Send_Coin_Targets type, request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1048,7 +1041,7 @@ public Task thank_tip(string chatId, string userId) RestRequest request = new RestRequest($"/x{communityId}/s/chat/thread/{chatId}/tipping/tipped-users/{userId}/thank"); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1058,13 +1051,13 @@ public Task follow(List userIds) data.Add("timestamp", helpers.GetTimestamp() * 1000); data.Add("targetUidList", new JArray(userIds)); RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.userID}/joined"); + RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.UserId}/joined"); request.AddHeaders(headers); request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1077,11 +1070,11 @@ public Task follow(string userId) public Task unfollow(string userId) { RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.userID}/joined/{userId}"); + RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.UserId}/joined/{userId}"); request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1092,7 +1085,7 @@ public Task block(string userId) request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1103,7 +1096,7 @@ public Task unblock(string userId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1114,7 +1107,7 @@ public Task visit(string userId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1136,7 +1129,7 @@ public Task flag(string targetId, string reason, Types.Flag_Types flagType, Type request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1169,8 +1162,8 @@ public Objects.Message send_message(string message, string chatId, Types.Message request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - return new Objects.Message(JObject.Parse(response.Content)); + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } public Task send_file_message(string chatId, byte[] file, Types.upload_File_Types fileType) @@ -1209,7 +1202,7 @@ public Task send_file_message(string chatId, byte[] file, Types.upload_File_Type request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1252,7 +1245,7 @@ public Task send_embed(string chatId, string content = null, string embedId = nu request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1281,7 +1274,7 @@ public Task send_sticker(string chatId, string stickerId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1303,13 +1296,13 @@ public Task delete_message(string chatId, string messageId, bool asStaff = false request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } } else { var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } } return Task.CompletedTask; } @@ -1327,7 +1320,7 @@ public Task mark_as_read(string chatId, string messageId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1344,7 +1337,7 @@ public Task transfer_host(string chatId, List userIds) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1363,7 +1356,7 @@ public Task accept_host(string chatId, string requestId) request.AddJsonBody(JsonConvert.SerializeObject(data)); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1374,7 +1367,7 @@ public Task join_chat(string chatId) request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1385,48 +1378,32 @@ public Task leave_chat(string chatId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } - public List get_user_following(string userId, int start = 0, int size = 25) + public List get_user_following(string userId, int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List userFollowingsList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{userId}/joined?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray userFollowings = jsonObj["userProfileList"]; - foreach (JObject following in userFollowings) - { - Objects.UserFollowings _following = new Objects.UserFollowings(following); - userFollowingsList.Add(_following); - } - return userFollowingsList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } - public List get_user_followers(string userId, int start = 0, int size = 25) + public List get_user_followers(string userId, int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List userFollowerList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{userId}/member?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray userFollowers = jsonObj["userProfileList"]; - foreach (JObject follower in userFollowers) - { - Objects.UserFollowings _follower = new Objects.UserFollowings(follower); - userFollowerList.Add(_follower); - } - return userFollowerList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } public Objects.UserProfile get_user_info(string userId) @@ -1436,9 +1413,8 @@ public Objects.UserProfile get_user_info(string userId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - Amino.Objects.UserProfile profile = new Amino.Objects.UserProfile((JObject)JObject.Parse(response.Content)["userProfile"]); - return profile; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfile").GetRawText()); } public Task comment(string message, Types.Comment_Types type, string objectId) @@ -1483,27 +1459,19 @@ public Task comment(string message, Types.Comment_Types type, string objectId) request.AddJsonBody(data); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } public List get_user_visitors(string userId, int start = 0, int size = 25) { if (start < 0) { throw new Exception("start cannot be lower than 0"); } - List userVisitorList = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{userId}/visitors?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray userVisitors = jsonObj["visitors"]; - foreach (JObject visitor in userVisitors) - { - Objects.UserVisitor _visitor = new Objects.UserVisitor(visitor, jsonObj); - userVisitorList.Add(_visitor); - } - return userVisitorList; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("visitors").GetRawText()); } public Objects.UserCheckins get_user_checkins(string userId) @@ -1513,24 +1481,19 @@ public Objects.UserCheckins get_user_checkins(string userId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - return new Objects.UserCheckins(JObject.Parse(response.Content)); + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } public List get_user_blogs(string userId, int start = 0, int size = 25) { - List blogs = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/blog?type=user&q={userId}&start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - foreach (JObject blog in JObject.Parse(response.Content)["blogList"]) - { - blogs.Add(new Objects.Blog(blog)); - } - return blogs; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("blogList").GetRawText()); } public List get_user_wikis(string userId, int start = 0, int size = 25) From c08c580c38a675ffff3d2f8c4f3ddfee30426ff6 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Sun, 26 May 2024 23:13:42 +0200 Subject: [PATCH 19/19] finished up object rework --- Amino.NET/SubClient.cs | 62 ++++++++++++++--------------------- Amino.NET/WebSocketHandler.cs | 14 ++++---- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/Amino.NET/SubClient.cs b/Amino.NET/SubClient.cs index cce815c..5d5960a 100644 --- a/Amino.NET/SubClient.cs +++ b/Amino.NET/SubClient.cs @@ -1363,7 +1363,7 @@ public Task accept_host(string chatId, string requestId) public Task join_chat(string chatId) { RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/x{communityId}/s/chat/thread/{chatId}/member/{this.client.userID}"); + RestRequest request = new RestRequest($"/x{communityId}/s/chat/thread/{chatId}/member/{this.client.UserId}"); request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } @@ -1374,7 +1374,7 @@ public Task join_chat(string chatId) public Task leave_chat(string chatId) { RestClient client = new RestClient(helpers.BaseUrl); - RestRequest request = new RestRequest($"/x{communityId}/s/chat/thread/{chatId}/member/{this.client.userID}"); + RestRequest request = new RestRequest($"/x{communityId}/s/chat/thread/{chatId}/member/{this.client.UserId}"); request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } @@ -1498,18 +1498,13 @@ public Objects.UserCheckins get_user_checkins(string userId) public List get_user_wikis(string userId, int start = 0, int size = 25) { - List wikis = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/item?type=user-all&start={start}&size={size}&cv=1.2&uid={userId}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - foreach (JObject wiki in JObject.Parse(response.Content)["itemList"]) - { - wikis.Add(new Objects.Wiki(wiki)); - } - return wikis; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("itemList").GetRawText()); } public Objects.UserAchievements get_user_achievements(string userId) @@ -1519,8 +1514,8 @@ public Objects.UserAchievements get_user_achievements(string userId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - return new Objects.UserAchievements((JObject)JObject.Parse(response.Content)["achievements"]); + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("achievements").GetRawText()); } public Objects.InfluencerInfo get_influencer_info(string userId, int start = 0, int size = 25) @@ -1530,8 +1525,8 @@ public Objects.InfluencerInfo get_influencer_info(string userId, int start = 0, request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - return new(JObject.Parse(response.Content)); + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetRawText()); } @@ -1549,7 +1544,7 @@ public Task add_influencer(string userId, int monthlyFee) request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } public Task remove_influencer(string userId) @@ -1559,7 +1554,7 @@ public Task remove_influencer(string userId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1582,50 +1577,41 @@ public Task subscribe(string userId, bool autoRenew = false, string transactionI request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } - public List get_blocked_users(int start = 0, int size = 25) + public List get_blocked_users(int start = 0, int size = 25) { - List blocked = new List(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/block?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - foreach (JObject user in JObject.Parse(response.Content)["userProfileList"]) - { - blocked.Add(new(user)); - } - return blocked; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } public List get_blocker_users(int start = 0, int size = 25) { - List blockers = new(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/x{communityId}/s/block?start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - foreach (string blocker in JObject.Parse(response.Content)["blockerUidList"]) { blockers.Add(blocker); } - return blockers; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("blockerUidList").GetRawText()); } public List get_leaderboard_info(Types.Leaderboard_Ranking_Types type, int start = 0, int size = 25) { - List leaderboard = new(); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest($"/g/s-x{communityId}/community/leaderboard?rankingType={(int)type}&start={start}&size={size}"); request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - foreach (JObject user in JObject.Parse(response.Content)["userProfileList"]) { leaderboard.Add(new(user)); } - return leaderboard; + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); } @@ -1636,8 +1622,8 @@ public Objects.Wiki get_wiki_info(string wikiId) request.AddHeaders(headers); var response = client.ExecuteGet(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } - return new((JObject)JObject.Parse(response.Content)["item"]); + if (Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("item").GetRawText()); } public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true) @@ -1649,7 +1635,7 @@ public Task kick_from_chat(string userId, string chatId, bool allowRejoin = true var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1660,7 +1646,7 @@ public Task delete_chat(string chatId) request.AddHeaders(headers); var response = client.Delete(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1673,7 +1659,7 @@ public Task handle_promotion(string noticeId, bool accept = true) request.AddHeaders(headers); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } @@ -1709,7 +1695,7 @@ public Task play_quiz(string quizId, List questionIdList, List a request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } diff --git a/Amino.NET/WebSocketHandler.cs b/Amino.NET/WebSocketHandler.cs index 7ffa880..63acdec 100644 --- a/Amino.NET/WebSocketHandler.cs +++ b/Amino.NET/WebSocketHandler.cs @@ -24,7 +24,7 @@ public WebSocketHandler(Amino.Client client) private async Task StartWebSocket(Amino.Client _client) { - var final = $"{_client.deviceID}|{(Math.Round(helpers.GetTimestamp())) * 1000}"; + var final = $"{_client.DeviceId}|{(Math.Round(helpers.GetTimestamp())) * 1000}"; WebSocketURL += $"/?signbody={final.Replace("|", "%7C")}"; var factory = new Func(() => @@ -36,8 +36,8 @@ private async Task StartWebSocket(Amino.Client _client) KeepAliveInterval = TimeSpan.FromSeconds(30) } }; - client.Options.SetRequestHeader("NDCDEVICEID", _client.deviceID); - client.Options.SetRequestHeader("NDCAUTH", $"sid={_client.sessionID}"); + client.Options.SetRequestHeader("NDCDEVICEID", _client.DeviceId); + client.Options.SetRequestHeader("NDCAUTH", $"sid={_client.SessionId}"); client.Options.SetRequestHeader("NDC-MSG-SIG", helpers.generate_signiture(final)); client.Options.SetRequestHeader("Upgrade", "websocket"); client.Options.SetRequestHeader("Connection", "Upgrade"); @@ -53,7 +53,7 @@ private async Task StartWebSocket(Amino.Client _client) ws_client.ReconnectTimeout = TimeSpan.FromSeconds(45); ws_client.DisconnectionHappened.Subscribe(info => { - if (_client.debug) + if (_client.Debug) { Trace.WriteLine($"WebSocket: Disconnected\nReason: {info.CloseStatusDescription}"); // Attempt reconnection only if the disconnection wasn't triggered by the user @@ -65,14 +65,14 @@ private async Task StartWebSocket(Amino.Client _client) }); ws_client.ReconnectionHappened.Subscribe(info => { - if (_client.debug) + if (_client.Debug) { Trace.WriteLine($"WebSocket: Reconnected\nMessage: {info.Type}"); } }); ws_client.MessageReceived.Subscribe(msg => { - if (_client.debug) + if (_client.Debug) { Trace.WriteLine($"WebSocket: Received Message: {msg.Text}"); } @@ -100,7 +100,7 @@ public async Task DisconnectSocket() { await ws_client.Stop(WebSocketCloseStatus.NormalClosure, "WebSocket closed successfully"); ws_client.Dispose(); - if (_client.debug) + if (_client.Debug) { Trace.WriteLine("WebSocket closed successfully."); }