diff --git a/.github/workflows/dev-autopublish.yml b/.github/workflows/dev-autopublish.yml index 049dbce..b8a0e5e 100644 --- a/.github/workflows/dev-autopublish.yml +++ b/.github/workflows/dev-autopublish.yml @@ -26,7 +26,7 @@ jobs: - name: Determine version id: version - run: echo "::set-output name=version::0.$((${GITHUB_RUN_NUMBER} / 10)).$((${GITHUB_RUN_NUMBER} % 10))" + run: echo "::set-output name=version::$((GITHUB_RUN_NUMBER / 100)).$(((GITHUB_RUN_NUMBER % 100) / 10)).$((GITHUB_RUN_NUMBER % 10))" - name: Get Project Version id: base_version diff --git a/Amino.NET/ACMClient.cs b/Amino.NET/ACMClient.cs new file mode 100644 index 0000000..1abf67a --- /dev/null +++ b/Amino.NET/ACMClient.cs @@ -0,0 +1,467 @@ +using Amino.Objects; +using Newtonsoft.Json.Linq; +using RestSharp; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection.Metadata.Ecma335; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; + +namespace Amino +{ + public class ACMClient + { + + public Amino.Client Client { get; } + public int CommunityId { get; } + + private RestClient RClient { get; } + + public ACMClient(Amino.Client client, string communityId) + { + this.Client = client; + this.CommunityId = Convert.ToInt32(communityId); + RClient = new RestClient(helpers.BaseUrl); + RClient.AddDefaultHeaders(Client.headers); + } + public ACMClient(Amino.Client client, int communityId) + { + this.Client = client; + this.CommunityId = communityId; + RClient = new RestClient(helpers.BaseUrl); + RClient.AddDefaultHeaders(Client.headers); + } + + public ACMClient(Amino.SubClient client) + { + this.Client = client.GetClient(); + this.CommunityId = Convert.ToInt32(client.GetCurrentCommunityId()); + RClient = new RestClient(helpers.BaseUrl); + RClient.AddDefaultHeaders(Client.headers); + } + + public Task create_community(string name, string tagline, byte[] icon, string themeColor, Types.Join_Types joinType = Types.Join_Types.Open, Types.Supported_Languages primaryLanguage = Types.Supported_Languages.English) + { + string _lang = "en"; + switch (primaryLanguage) + { + case Types.Supported_Languages.English: + _lang = "en"; + break; + case Types.Supported_Languages.Spanish: + _lang = "es"; + break; + case Types.Supported_Languages.Portuguese: + _lang = "pt"; + break; + case Types.Supported_Languages.Arabic: + _lang = "ar"; + break; + case Types.Supported_Languages.Russian: + _lang = "ru"; + break; + case Types.Supported_Languages.French: + _lang = "fr"; + break; + case Types.Supported_Languages.German: + _lang = "de"; + break; + } + JObject data = new JObject() + { + { "icon", new JObject() { + { "height", 512.0 }, + { "path", this.Client.upload_media(icon, Types.upload_File_Types.Image) }, + { "width", 512.0 }, + { "x", 0.0 }, + { "y", 0.0 }, + { "imageMatrix", new JArray() { 1.6875, 0.0, 108.0, 0.0, 1.6875, 497.0, 0.0, 0.0, 1.0} } + } }, + { "joinType", (int)joinType }, + { "name", name }, + { "primaryLanguage", _lang }, + { "tagline", tagline }, + { "templateId", 9 }, + { "themeColor", themeColor }, + { "timestamp", helpers.GetTimestamp() * 1000 } + }; + RestRequest request = new RestRequest("/g/s/community"); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data))); + request.AddJsonBody(JsonSerializer.Serialize(data)); + + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + + } + + public Task delete_community(string email, string password, string verificationCode) + { + JObject data = new JObject() + { + { "secret", $"0 {password}" }, + { "validationContext", new JObject() { + { "data", new JObject() { "code", verificationCode } } + }}, + { "type", 1 }, + { "identity", email }, + { "deviceId", this.Client.DeviceId }, + { "timestamp", helpers.GetTimestamp() * 1000 } + }; + RestRequest request = new RestRequest($"/g/s-x{CommunityId}/community/delete-request"); + request.AddJsonBody(JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data))); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public List list_communities(int start = 0, int size = 25) + { + RestRequest request = new RestRequest($"/g/s/community/managed?start={start}&size={size}"); + var response = RClient.ExecuteGet(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("communityList").GetRawText()); + } + + public List get_blog_categories(int start = 0, int size = 25) + { + RestRequest request = new RestRequest($"/x{CommunityId}/s/blog-category?start={start}&size={size}"); + var response = RClient.ExecuteGet(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("blogCategoryList").GetRawText()); + } + + + public Task change_sidebar_color(string color) + { + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/configuration"); + Dictionary data = new Dictionary() + { + { "path", "appearance.leftSidePanel.style.iconColor" }, + { "value", color.Length == 7 ? color : "#000000" }, + { "timestamp", helpers.GetTimestamp() * 1000 } + }; + request.AddHeader("NDC-MSG-SIG", System.Text.Json.JsonSerializer.Serialize(data)); + request.AddJsonBody(JsonSerializer.Serialize(data)); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public AdvancedCommunityInfo get_community_info() + { + RestRequest request = new RestRequest($"/g/s-x{CommunityId}/community/info?withTopicList=1&withInfluencerList=1&influencerListOrderStrategy=fansCount"); + var response = RClient.ExecuteGet(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("community").GetRawText()); + } + + public Task promote(string userId, Types.RoleTypes roleType) + { + string _role = ""; + switch (roleType) + { + case Types.RoleTypes.Agent: + _role = "transfer-agent"; + break; + case Types.RoleTypes.Leader: + _role = "leader"; + break; + case Types.RoleTypes.Curator: + _role = "curator"; + break; + } + RestRequest request = new RestRequest($"/x{CommunityId}/s/user-profile/{userId}/{_role}"); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public List get_join_request(int start = 0, int size = 25) + { + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/membership-request?status=pending?start={start}&size={size}"); + var response = RClient.ExecuteGet(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetRawText()); + } + + public Task accept_join_request(string userId) + { + Dictionary data = new Dictionary(); + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/membership-request/{userId}/accept"); + request.AddJsonBody(JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", JsonSerializer.Serialize(data)); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + public Task reject_join_request(string userId) + { + Dictionary data = new Dictionary(); + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/membership-request/{userId}/reject"); + request.AddJsonBody(JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", JsonSerializer.Serialize(data)); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public CommunityStats get_community_stats() + { + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/stats"); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return JsonSerializer.Deserialize(JsonDocument.Parse(response.Content).RootElement.GetProperty("communityStats").GetRawText()); + } + + public List get_community_user_stats(Types.RoleTypes roleType, int start = 0, int size = 25) + { + string _target = ""; + switch (roleType) + { + case Types.RoleTypes.Leader: + _target = "leader"; + break; + case Types.RoleTypes.Curator: + _target = "curator"; + break; + default: + _target = "leader"; + break; + } + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/stats/moderation?type={_target}&start={start}&size={size}"); + var response = RClient.ExecuteGet(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText()); + } + + public Task change_welcome_message(string message, bool isEnabled = true) + { + Dictionary data = new Dictionary() + { + { "path", "general.welcomeMessage" }, + { "value", new Dictionary() + { + { "enabled", isEnabled }, + { "text", message } + } }, + { "timestamp", helpers.GetTimestamp() * 1000 } + }; + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/configuration"); + request.AddJsonBody(JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data))); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public Task change_amino_id(string aminoId) + { + Dictionary data = new() + { + { "endpoint", aminoId }, + { "timestamp", helpers.GetTimestamp() * 1000 } + }; + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/settings"); + request.AddJsonBody(JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data))); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public Task change_guidelines(string guidelines) + { + Dictionary data = new() + { + { "content", guidelines }, + { "timestamp", helpers.GetTimestamp() * 1000 } + }; + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/guidelines"); + request.AddJsonBody(JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data))); + var response = RClient.ExecutePost(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public Task edit_community(string name = null, string description = null, string aminoId = null, Types.Supported_Languages primaryLanguage = Types.Supported_Languages.English, string themePackUrl = null) + { + string _lang = "en"; + switch (primaryLanguage) + { + case Types.Supported_Languages.English: + _lang = "en"; + break; + case Types.Supported_Languages.Spanish: + _lang = "es"; + break; + case Types.Supported_Languages.Portuguese: + _lang = "pt"; + break; + case Types.Supported_Languages.Arabic: + _lang = "ar"; + break; + case Types.Supported_Languages.Russian: + _lang = "ru"; + break; + case Types.Supported_Languages.French: + _lang = "fr"; + break; + case Types.Supported_Languages.German: + _lang = "de"; + break; + } + Dictionary data = new(); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + data.Add("primaryLanguage", _lang); + + if (name != null) data.Add("name", name); + if (description != null) data.Add("content", description); + if (aminoId != null) data.Add("endpoint", aminoId); + if (themePackUrl != null) data.Add("themePackUrl", themePackUrl); + + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/settings"); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data))); + request.AddJsonBody(JsonSerializer.Serialize(data)); + var response = RClient.ExecutePost(request); + if(!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public Task change_module(Types.ModuleTypes moduleType, bool isEnabled) + { + string _module = ""; + switch(moduleType) + { + case Types.ModuleTypes.Chat: + _module = "module.chat.enabled"; + break; + case Types.ModuleTypes.LiveChat: + _module = "module.chat.avChat.videoEnabled"; + break; + case Types.ModuleTypes.ScreeningRoom: + _module = "module.chat.avChat.screeningRoomEnabled"; + break; + case Types.ModuleTypes.PublicChats: + _module = "module.chat.publicChat.enabled"; + break; + case Types.ModuleTypes.Posts: + _module = "module.post.enabled"; + break; + case Types.ModuleTypes.Ranking: + _module = "module.ranking.enabled"; + break; + case Types.ModuleTypes.Leaderboards: + _module = "module.ranking.leaderboardEnabled"; + break; + case Types.ModuleTypes.Featured: + _module = "module.featured.enabled"; + break; + case Types.ModuleTypes.FeaturedPosts: + _module = "module.featured.postEnabled"; + break; + case Types.ModuleTypes.FeaturedUsers: + _module = "module.featured.memberEnabled"; + break; + case Types.ModuleTypes.FeaturedChats: + _module = "module.featured.publicChatRoomEnabled"; + break; + case Types.ModuleTypes.SharedFolder: + _module = "module.sharedFolder.enabled"; + break; + case Types.ModuleTypes.Influencer: + _module = "module.influencer.enabled"; + break; + case Types.ModuleTypes.Catalog: + _module = "module.catalog.enabled"; + break; + case Types.ModuleTypes.ExternalContent: + _module = "module.externalContent.enabled"; + break; + case Types.ModuleTypes.TopicCategories: + _module = "module.topicCategories.enabled"; + break; + } + + Dictionary data = new Dictionary() + { + { "path", _module }, + { "value", isEnabled }, + { "timestamp", helpers.GetTimestamp() * 1000 } + }; + RestRequest request = new RestRequest($"/x{CommunityId}/s/community/configuration"); + request.AddJsonBody(JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", JsonSerializer.Serialize(data)); + var response = RClient.ExecutePost(request); + if(!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public Task add_influencer(string userId, int monthlyFee) + { + Dictionary data = new Dictionary() + { + { "monthlyFee", monthlyFee }, + { "timestamp", helpers.GetTimestamp() * 1000 }, + }; + RestRequest request = new RestRequest($"/x{CommunityId}/s/influencer/{userId}"); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data))); + request.AddJsonBody(JsonSerializer.Serialize(data)); + var response = RClient.ExecutePost(request); + if(!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public Task remove_influencer(string userId) + { + RestRequest request = new RestRequest($"/x{CommunityId}/s/influencer/{userId}"); + var response = RClient.Delete(request); + if (!response.IsSuccessStatusCode) { return Task.CompletedTask; } + if (Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + public List get_notice_list(int start = 0, int size = 25) + { + RestRequest request = new RestRequest($"/x{CommunityId}/s/notice?type=management&status=1&sart={start}&size={size}"); + var response = RClient.ExecuteGet(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("noticeList").GetRawText()); + } + + public Task delete_pending_role(string noticeId) + { + RestRequest request = new RestRequest($"/x{CommunityId}/s/notice/{noticeId}"); + var response = RClient.Delete(request); + if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); } + if(Client.Debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + } +} diff --git a/Amino.NET/Amino.NET.csproj b/Amino.NET/Amino.NET.csproj index ccb7b3a..2d3c658 100644 --- a/Amino.NET/Amino.NET.csproj +++ b/Amino.NET/Amino.NET.csproj @@ -2,7 +2,7 @@ net7.0 - 1.5.2 + 1.7.0 FabioTheFox FabiDev An unofficial C# wrapper for Aminos REST API for making amino bots and tools @@ -22,6 +22,7 @@ true FabioTheFox Amino.NET + README.md @@ -38,6 +39,10 @@ + + True + \ + True diff --git a/Amino.NET/Builders/PostBuilder.cs b/Amino.NET/Builders/PostBuilder.cs index d27f6cc..ab2f040 100644 --- a/Amino.NET/Builders/PostBuilder.cs +++ b/Amino.NET/Builders/PostBuilder.cs @@ -3,7 +3,7 @@ using System.IO; using System.Reflection.Metadata.Ecma335; -namespace Amino.NET.Builders +namespace Amino.Builders { public class PostBuilder { diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index f4fed6a..a2da4fc 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) @@ -235,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; } @@ -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,37 +308,37 @@ 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 } }; RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/auth/logout"); - request.AddJsonBody(data); + request.AddJsonBody(JsonConvert.SerializeObject(data)); request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); 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,23 @@ public Task logout() /// public Task login_sid(string sessionId, bool fetchProfile = true, bool connectSocket = true) { - this.sessionID = sessionId; - + this.SessionId = sessionId; + this.UserId = helpers.sid_to_uid(sessionId); + headerBuilder(); 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(); @@ -406,7 +409,7 @@ public Task register_google(string nickname, string googleToken, string password Dictionary data = new Dictionary() { - { "secret", $"12 {googleToken}" }, + { "secret", $"32 {googleToken}" }, { "secret2", $"0 {password}" }, { "deviceID", deviceId }, { "clientType", 100 }, @@ -423,7 +426,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 +445,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 +475,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 +505,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 +519,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 +527,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 +557,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 +573,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 +585,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 +601,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 +614,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 +624,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 +640,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 +658,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 +692,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 +704,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 +725,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()); } /// @@ -749,29 +744,18 @@ 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 (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.CommunityProfile C_Profile = new Objects.CommunityProfile(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 +764,16 @@ 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); + request.AddHeader("SMDEVICEID", Guid.NewGuid().ToString()); + request.AddOrUpdateHeader("Content-Type", "application/x-www-form-urlencoded"); 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.GetProperty("account").GetRawText()); } /// @@ -799,27 +784,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); } - - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); - JArray _chatList = jsonObj["threadList"]; - foreach (JObject chatJson in _chatList) - { - Objects.Chat chat = new Objects.Chat(chatJson); + if (Debug) { Trace.WriteLine(response.Content); } - chatList.Add(chat); - } - return chatList; + return System.Text.Json.JsonSerializer.Deserialize>(JsonDocument.Parse(response.Content).RootElement.GetProperty("threadList").GetRawText()); } @@ -830,17 +805,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()); } /// @@ -852,23 +825,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 @@ -877,13 +842,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; } @@ -894,14 +859,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; } @@ -913,7 +878,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 })); @@ -925,7 +890,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; } @@ -939,14 +904,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; } @@ -959,48 +924,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"]; - 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()); } /// @@ -1010,24 +959,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()); } /// @@ -1037,24 +978,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()); } @@ -1068,21 +1001,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()); } /// @@ -1091,25 +1016,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()); } /// @@ -1120,7 +1037,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); @@ -1128,14 +1045,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()); + } /// @@ -1171,15 +1083,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()); } /// @@ -1193,7 +1098,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}"); @@ -1210,7 +1115,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; } @@ -1224,11 +1129,11 @@ 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 }, - { "adminOpNote", new JObject() { "content", reason } }, + { "adminOpNote", new JObject() { { "content", reason } } }, { "timestamp", helpers.GetTimestamp() * 1000 } }; RestClient client = new RestClient(helpers.BaseUrl); @@ -1239,7 +1144,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; } /// @@ -1250,7 +1155,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 }, @@ -1263,7 +1168,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; } @@ -1279,7 +1184,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; } @@ -1290,13 +1195,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; } @@ -1307,13 +1212,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; } /// @@ -1323,13 +1228,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; } @@ -1340,13 +1245,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; } @@ -1358,7 +1263,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); } @@ -1369,7 +1274,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; } @@ -1381,7 +1286,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() @@ -1394,7 +1299,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; } @@ -1405,13 +1310,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; } @@ -1425,7 +1330,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() @@ -1443,7 +1348,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; } @@ -1472,7 +1377,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) { @@ -1497,7 +1402,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"]; @@ -1514,7 +1419,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); @@ -1567,13 +1472,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; } @@ -1585,7 +1490,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() @@ -1601,7 +1506,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; } @@ -1612,7 +1517,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 }, @@ -1625,7 +1530,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; } @@ -1636,13 +1541,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; } @@ -1653,13 +1558,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; } @@ -1672,7 +1577,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); @@ -1713,7 +1618,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; } @@ -1726,7 +1631,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) @@ -1747,7 +1652,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; } @@ -1759,7 +1664,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(); @@ -1789,7 +1694,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; } @@ -1801,7 +1706,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); @@ -1820,7 +1725,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; } @@ -1830,15 +1735,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()); } /// @@ -1848,31 +1752,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: @@ -1884,16 +1788,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()); } /// @@ -1902,16 +1798,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.GetProperty("wallet").GetRawText()); } /// @@ -1922,23 +1816,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()); } /// @@ -1953,10 +1839,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(); } /// @@ -1971,10 +1855,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.GetProperty("linkInfoV2").GetRawText()); } /// @@ -1984,9 +1866,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 }, @@ -2006,10 +1888,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.GetProperty("linkInfoV2").GetRawText()); } /// @@ -2023,16 +1903,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(); } /// @@ -2041,13 +1913,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; } @@ -2061,21 +1933,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()); } /// @@ -2091,10 +1955,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()); } /// @@ -2116,7 +1978,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); @@ -2125,7 +1987,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; } @@ -2155,10 +2017,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()); } /// @@ -2168,7 +2029,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 }, @@ -2181,7 +2042,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; } @@ -2193,23 +2054,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()); } /// @@ -2236,7 +2089,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; } @@ -2265,27 +2118,11 @@ public Objects.Message send_message(string message, string chatId, Types.Message } message = message.Replace("<$", "").Replace("$>", ""); JObject data = new JObject(); - JObject attachementSub = new JObject(); - JObject extensionSub = new JObject(); - JObject extensionSuBArray = new JObject(); data.Add("type", (int)messageType); data.Add("content", message); data.Add("clientRefId", helpers.GetTimestamp() / 10 % 1000000000); data.Add("timestamp", helpers.GetTimestamp() * 1000); - attachementSub.Add("objectId", null); - attachementSub.Add("objectType", null); - attachementSub.Add("link", null); - attachementSub.Add("title", null); - attachementSub.Add("content", null); - attachementSub.Add("mediaList", null); - extensionSuBArray.Add("link", null); - extensionSuBArray.Add("mediaType", 100); - extensionSuBArray.Add("mediaUploadValue", null); - extensionSuBArray.Add("mediaUploadValueContentType", "image/jpg"); - extensionSub.Add("mentionedArray", new JArray(mentions)); - extensionSub.Add("linkSnippetList", new JArray(extensionSuBArray)); - data.Add("attachedObject", attachementSub); - data.Add("extensions", extensionSub); + data.Add("extensions", new JObject() { { "mentionedArray", new JArray(mentions) } }); if (replyTo != null) { data.Add("replyMessageId", replyTo); } RestClient client = new RestClient(helpers.BaseUrl); @@ -2295,8 +2132,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()); } /// @@ -2310,26 +2147,10 @@ public Objects.Message send_message(string message, string chatId, Types.Message public Task send_file_message(string chatId, byte[] file, Types.upload_File_Types fileType) { JObject data = new JObject(); - JObject attachementSub = new JObject(); - JObject extensionSub = new JObject(); - JObject extensionSuBArray = new JObject(); data.Add("clientRefId", helpers.GetTimestamp() / 10 % 1000000000); data.Add("timestamp", helpers.GetTimestamp() * 1000); data.Add("content", null); data.Add("type", 0); - attachementSub.Add("objectId", null); - attachementSub.Add("objectType", null); - attachementSub.Add("link", null); - attachementSub.Add("title", null); - attachementSub.Add("content", null); - attachementSub.Add("mediaList", null); - extensionSuBArray.Add("link", null); - extensionSuBArray.Add("mediaType", 100); - extensionSuBArray.Add("mediaUploadValue", null); - extensionSuBArray.Add("mediaUploadValueContentType", "image/jpg"); - extensionSub.Add("linkSnippetList", new JArray(extensionSuBArray)); - data.Add("attachedObject", attachementSub); - data.Add("extensions", extensionSub); switch (fileType) { @@ -2344,11 +2165,12 @@ public Task send_file_message(string chatId, byte[] file, Types.upload_File_Type data.Add("enableUhqEnabled", true); break; case Types.upload_File_Types.Audio: + data.Remove("type"); data.Add("type", 2); data.Add("mediaType", 110); break; } - data.Add("mediaUploadValue", Encoding.UTF8.GetString(Convert.FromBase64String(Convert.ToBase64String(file)))); + data.Add("mediaUploadValue", Convert.ToBase64String(file)); RestClient client = new RestClient(helpers.BaseUrl); @@ -2358,7 +2180,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; } @@ -2412,7 +2234,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; } @@ -2462,7 +2284,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; } @@ -2479,8 +2301,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()); } @@ -2497,8 +2319,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()); } /// @@ -2515,8 +2337,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()); } /// @@ -2548,7 +2370,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 @@ -2579,11 +2401,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 e0d2e6d..e28202a 100644 --- a/Amino.NET/Events/EventHandler.cs +++ b/Amino.NET/Events/EventHandler.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Text.Json; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using Amino.Objects; + namespace Amino.Events { @@ -19,78 +16,111 @@ 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 { - dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(webSocketMessage.ToString()); - if(jsonObj["o"]["chatMessage"]["mediaType"] != null) + JsonElement root = JsonDocument.Parse(webSocketMessage.ToString()).RootElement; + if(root.GetProperty("o").GetProperty("chatMessage").GetProperty("mediaType").ValueKind != JsonValueKind.Null) { - 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 - 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; @@ -98,19 +128,27 @@ public Task ReceiveEvent(JObject 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/AdditionalItemBenefits.cs b/Amino.NET/Objects/AdditionalItemBenefits.cs new file mode 100644 index 0000000..9693f48 --- /dev/null +++ b/Amino.NET/Objects/AdditionalItemBenefits.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class AdditionalItemBenefits + { + [JsonPropertyName("firstMonthFreeAminoPlusMembership")] public bool? FirstMonthFreeAminoPlus { get; set; } + } +} diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs index 0329813..a6213e6 100644 --- a/Amino.NET/Objects/AdvancedCommunityInfo.cs +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -1,234 +1,45 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; +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 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 GenericProfile Agent { get; set; } + [JsonPropertyName("themePack")] public CommunityThemePack ThemePack { get; set; } + [JsonPropertyName("advancedSettings")] public CommunityAdvancedSettings AdvancedSettings { get; set; } + + [JsonPropertyName("userAddedTopicList")] public List UserAddedTopicList { get; set; } + [JsonPropertyName("mediaList")] public List> MediaList { get; set; } } -} +} \ No newline at end of file diff --git a/Amino.NET/Objects/AvatarFrame.cs b/Amino.NET/Objects/AvatarFrame.cs index 3737482..d85cd64 100644 --- a/Amino.NET/Objects/AvatarFrame.cs +++ b/Amino.NET/Objects/AvatarFrame.cs @@ -1,131 +1,27 @@ -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..e51cbee --- /dev/null +++ b/Amino.NET/Objects/AvatarFrameConfig.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +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/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..3e25145 100644 --- a/Amino.NET/Objects/Blog.cs +++ b/Amino.NET/Objects/Blog.cs @@ -1,139 +1,34 @@ -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 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; 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; + [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; set; } } } diff --git a/Amino.NET/Objects/BlogCategory.cs b/Amino.NET/Objects/BlogCategory.cs new file mode 100644 index 0000000..b980010 --- /dev/null +++ b/Amino.NET/Objects/BlogCategory.cs @@ -0,0 +1,24 @@ +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 BlogCategory + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; } + [JsonPropertyName("icon")] public string IconUrl { get; set; } + [JsonPropertyName("style")] public int Style { get; set; } + [JsonPropertyName("label")] public string Label { get; set; } + [JsonPropertyName("content")] public string Content { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("position")] public int Position { get; set; } + [JsonPropertyName("type")] public int Type { get; set; } + [JsonPropertyName("categoryId")] public string CategoryId { get; set; } + [JsonPropertyName("blogsCount")] public int BlogsCount { get; set; } + } +} diff --git a/Amino.NET/Objects/Chat.cs b/Amino.NET/Objects/Chat.cs index a1c2100..6e73820 100644 --- a/Amino.NET/Objects/Chat.cs +++ b/Amino.NET/Objects/Chat.cs @@ -1,184 +1,36 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Collections.Generic; +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; 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/ChatAnnouncement.cs b/Amino.NET/Objects/ChatAnnouncement.cs index eb0e02b..1c49da1 100644 --- a/Amino.NET/Objects/ChatAnnouncement.cs +++ b/Amino.NET/Objects/ChatAnnouncement.cs @@ -1,49 +1,22 @@ -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/ChatEvent.cs b/Amino.NET/Objects/ChatEvent.cs index 9382200..36c8bfb 100644 --- a/Amino.NET/Objects/ChatEvent.cs +++ b/Amino.NET/Objects/ChatEvent.cs @@ -1,45 +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 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/ChatExtensions.cs b/Amino.NET/Objects/ChatExtensions.cs new file mode 100644 index 0000000..a294f0b --- /dev/null +++ b/Amino.NET/Objects/ChatExtensions.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +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/ChatTip.cs b/Amino.NET/Objects/ChatTip.cs index 8270103..858595a 100644 --- a/Amino.NET/Objects/ChatTip.cs +++ b/Amino.NET/Objects/ChatTip.cs @@ -1,134 +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 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..91081c7 --- /dev/null +++ b/Amino.NET/Objects/ChatTipExtensions.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +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..0c42ba0 100644 --- a/Amino.NET/Objects/ChatTipToggle.cs +++ b/Amino.NET/Objects/ChatTipToggle.cs @@ -1,121 +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 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/CoinHistoryEntry.cs b/Amino.NET/Objects/CoinHistoryEntry.cs index 6a43be3..40682e1 100644 --- a/Amino.NET/Objects/CoinHistoryEntry.cs +++ b/Amino.NET/Objects/CoinHistoryEntry.cs @@ -1,68 +1,25 @@ -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; } + [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; } - 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"]; - } - } } } diff --git a/Amino.NET/Objects/Comment.cs b/Amino.NET/Objects/Comment.cs index 6b15563..ea9d279 100644 --- a/Amino.NET/Objects/Comment.cs +++ b/Amino.NET/Objects/Comment.cs @@ -1,85 +1,23 @@ -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; } + [JsonPropertyName("author")] public GenericProfile Author { get; 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..c7b9dae 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.Collections.Generic; +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; } + [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; } + [JsonIgnore][JsonPropertyName("userAddedTopicList")] public string UserAddedTopicList { get; set; } + [JsonPropertyName("agent")] public GenericProfile Agent { get; set; } + [JsonPropertyName("themePack")] public CommunityThemePack ThemePack { get; 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 { } - } - } } } diff --git a/Amino.NET/Objects/CommunityAdvancedSettings.cs b/Amino.NET/Objects/CommunityAdvancedSettings.cs new file mode 100644 index 0000000..4e60a67 --- /dev/null +++ b/Amino.NET/Objects/CommunityAdvancedSettings.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +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; } + [JsonPropertyName("welcomeMessageText")] public string WelcomeMessageText { get; set; } + + } +} diff --git a/Amino.NET/Objects/CommunityInfo.cs b/Amino.NET/Objects/CommunityInfo.cs index e0c6391..d16be2b 100644 --- a/Amino.NET/Objects/CommunityInfo.cs +++ b/Amino.NET/Objects/CommunityInfo.cs @@ -1,123 +1,13 @@ -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/CommunityNewsFeed.cs b/Amino.NET/Objects/CommunityNewsFeed.cs new file mode 100644 index 0000000..7343be0 --- /dev/null +++ b/Amino.NET/Objects/CommunityNewsFeed.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +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..7986a60 --- /dev/null +++ b/Amino.NET/Objects/CommunityRankingTable.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +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/CommunityStats.cs b/Amino.NET/Objects/CommunityStats.cs new file mode 100644 index 0000000..973cb39 --- /dev/null +++ b/Amino.NET/Objects/CommunityStats.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 CommunityStats + { + [JsonPropertyName("dailyActiveMembers")] public int DailyActiveMembers { get; set; } + [JsonPropertyName("monthlyActiveMembers")] public int MonthlyActiveMembers { get; set; } + [JsonPropertyName("totalTimeSpent")] public int TotalTimeSpent { get; set; } + [JsonPropertyName("totalPostsCreated")] public int TotalPostsCreated { get; set; } + [JsonPropertyName("newMembersToday")] public int NewMembersToday { get; set; } + [JsonPropertyName("totalMembers")] public int TotalMembers { get; set; } + } +} diff --git a/Amino.NET/Objects/CommunityThemePack.cs b/Amino.NET/Objects/CommunityThemePack.cs new file mode 100644 index 0000000..7a9b0f0 --- /dev/null +++ b/Amino.NET/Objects/CommunityThemePack.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class CommunityThemePack + { + [JsonPropertyName("themeColor")] public string ThemeColor { get; set; } + [JsonPropertyName("themePackHash")] public string ThemePackHash { get; set; } + [JsonPropertyName("themePackRevision")] public int ThemePackRevision { get; set; } + [JsonPropertyName("themePackUrl")] public string ThemePackUrl { get; set; } + } +} diff --git a/Amino.NET/Objects/CurrentUserInfo.cs b/Amino.NET/Objects/CurrentUserInfo.cs new file mode 100644 index 0000000..4f2894c --- /dev/null +++ b/Amino.NET/Objects/CurrentUserInfo.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +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/DeletedMessage.cs b/Amino.NET/Objects/DeletedMessage.cs index 729072a..184dddf 100644 --- a/Amino.NET/Objects/DeletedMessage.cs +++ b/Amino.NET/Objects/DeletedMessage.cs @@ -1,119 +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 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/DeviceInfo.cs b/Amino.NET/Objects/DeviceInfo.cs new file mode 100644 index 0000000..7aa077f --- /dev/null +++ b/Amino.NET/Objects/DeviceInfo.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class DeviceInfo + { + [JsonPropertyName("lastClientType")] public int? LastClientType { get; set; } + } +} diff --git a/Amino.NET/Objects/FromCode.cs b/Amino.NET/Objects/FromCode.cs index 23fd901..cf11264 100644 --- a/Amino.NET/Objects/FromCode.cs +++ b/Amino.NET/Objects/FromCode.cs @@ -1,35 +1,13 @@ - -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..111e4b4 100644 --- a/Amino.NET/Objects/FromInvite.cs +++ b/Amino.NET/Objects/FromInvite.cs @@ -1,540 +1,14 @@ -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; 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/GenericAuthorExtensions.cs b/Amino.NET/Objects/GenericAuthorExtensions.cs new file mode 100644 index 0000000..52fc7b2 --- /dev/null +++ b/Amino.NET/Objects/GenericAuthorExtensions.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; + +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/GenericAvatarFrame.cs b/Amino.NET/Objects/GenericAvatarFrame.cs new file mode 100644 index 0000000..3acb5c6 --- /dev/null +++ b/Amino.NET/Objects/GenericAvatarFrame.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +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/GenericChatMember.cs b/Amino.NET/Objects/GenericChatMember.cs new file mode 100644 index 0000000..6211c0b --- /dev/null +++ b/Amino.NET/Objects/GenericChatMember.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +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/GenericMessage.cs b/Amino.NET/Objects/GenericMessage.cs new file mode 100644 index 0000000..9f24ceb --- /dev/null +++ b/Amino.NET/Objects/GenericMessage.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; + +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..fb5de25 --- /dev/null +++ b/Amino.NET/Objects/GenericMessageAuthor.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +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..8aea89b --- /dev/null +++ b/Amino.NET/Objects/GenericPostAuthor.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +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 new file mode 100644 index 0000000..ae28066 --- /dev/null +++ b/Amino.NET/Objects/GenericProfile.cs @@ -0,0 +1,30 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class GenericProfile // ROOT JSON ELEMENT: userProfile + { + 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("role")] public int? Role { get; set; } + + [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/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 1a86e0f..4b596ec 100644 --- a/Amino.NET/Objects/ImageMessage.cs +++ b/Amino.NET/Objects/ImageMessage.cs @@ -1,123 +1,29 @@ -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 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; } - 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 { } - } - - } - } } diff --git a/Amino.NET/Objects/InfluencerFanClubMember.cs b/Amino.NET/Objects/InfluencerFanClubMember.cs new file mode 100644 index 0000000..f9fb207 --- /dev/null +++ b/Amino.NET/Objects/InfluencerFanClubMember.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +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/InfluencerInfo.cs b/Amino.NET/Objects/InfluencerInfo.cs index 599ade6..541e2bb 100644 --- a/Amino.NET/Objects/InfluencerInfo.cs +++ b/Amino.NET/Objects/InfluencerInfo.cs @@ -1,204 +1,13 @@ -using Newtonsoft.Json.Linq; -using System.Collections.Generic; +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/InfluencerPriceInfo.cs b/Amino.NET/Objects/InfluencerPriceInfo.cs new file mode 100644 index 0000000..828abff --- /dev/null +++ b/Amino.NET/Objects/InfluencerPriceInfo.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +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..77b4c45 --- /dev/null +++ b/Amino.NET/Objects/Invitation.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; + +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/InviteCode.cs b/Amino.NET/Objects/InviteCode.cs index 181b6ad..2452d80 100644 --- a/Amino.NET/Objects/InviteCode.cs +++ b/Amino.NET/Objects/InviteCode.cs @@ -1,125 +1,16 @@ -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; } + [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; } - - 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"]; - } - - - } - } } } diff --git a/Amino.NET/Objects/ItemOwnershipInfo.cs b/Amino.NET/Objects/ItemOwnershipInfo.cs new file mode 100644 index 0000000..e1351fc --- /dev/null +++ b/Amino.NET/Objects/ItemOwnershipInfo.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +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..bf68b0d --- /dev/null +++ b/Amino.NET/Objects/ItemRestrictionInfo.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; + +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; } + + } +} diff --git a/Amino.NET/Objects/JoinRequest.cs b/Amino.NET/Objects/JoinRequest.cs new file mode 100644 index 0000000..2b13874 --- /dev/null +++ b/Amino.NET/Objects/JoinRequest.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 JoinRequest + { + [JsonPropertyName("communityMembershipRequestCount")] public int CommunityMembershipRequestCount { get; set; } + [JsonPropertyName("communityMembershipRequestList")] public List CommunityMembershipRequestList { get; set; } + } +} diff --git a/Amino.NET/Objects/JoinRequestApplicant.cs b/Amino.NET/Objects/JoinRequestApplicant.cs new file mode 100644 index 0000000..4a53bef --- /dev/null +++ b/Amino.NET/Objects/JoinRequestApplicant.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 JoinRequestApplicant + { + [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/JoinRequestUser.cs b/Amino.NET/Objects/JoinRequestUser.cs new file mode 100644 index 0000000..6420985 --- /dev/null +++ b/Amino.NET/Objects/JoinRequestUser.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 JoinRequestUser + { + [JsonPropertyName("status")] public int Status { get; set; } + [JsonPropertyName("requestId")] public string RequestId { get; set; } + [JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; } + [JsonPropertyName("ndcId")] public int CommunityId { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + [JsonPropertyName("message")] public string Message { get; set; } + [JsonPropertyName("uid")] public string UserId { get; set; } + [JsonPropertyName("applicant")] public JoinRequestApplicant Applicant { get; set; } + } +} diff --git a/Amino.NET/Objects/JoinedChatMember.cs b/Amino.NET/Objects/JoinedChatMember.cs index eca3833..4c7a602 100644 --- a/Amino.NET/Objects/JoinedChatMember.cs +++ b/Amino.NET/Objects/JoinedChatMember.cs @@ -1,118 +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 JoinedChatMember { - 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 + [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; } - 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"]; - } - } - } } } diff --git a/Amino.NET/Objects/LastChatMessageSummary.cs b/Amino.NET/Objects/LastChatMessageSummary.cs new file mode 100644 index 0000000..d92c380 --- /dev/null +++ b/Amino.NET/Objects/LastChatMessageSummary.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class LastChatMessageSummary + { + [JsonPropertyName("uid")] public string UserId { get; set; } + [JsonPropertyName("isHidden")] public bool? IsHidden { get; set; } + [JsonPropertyName("mediaType")] public int? 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; } + + } +} diff --git a/Amino.NET/Objects/LeftChatMember.cs b/Amino.NET/Objects/LeftChatMember.cs index fb4200c..bbb9455 100644 --- a/Amino.NET/Objects/LeftChatMember.cs +++ b/Amino.NET/Objects/LeftChatMember.cs @@ -1,46 +1,22 @@ -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; } + [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; } - 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(); - - } } } diff --git a/Amino.NET/Objects/LinkInfo.cs b/Amino.NET/Objects/LinkInfo.cs new file mode 100644 index 0000000..e75efe8 --- /dev/null +++ b/Amino.NET/Objects/LinkInfo.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +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..0423e30 --- /dev/null +++ b/Amino.NET/Objects/LinkInfoExtensions.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace Amino.Objects +{ + public class LinkInfoExtensions + { + [JsonPropertyName("community")] Community Community { get; set; } + [JsonPropertyName("linkInfo")] LinkInfo LinkInfo { get; set; } + } +} diff --git a/Amino.NET/Objects/Membership.cs b/Amino.NET/Objects/Membership.cs new file mode 100644 index 0000000..eb211c9 --- /dev/null +++ b/Amino.NET/Objects/Membership.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; + +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..f9f1c2b 100644 --- a/Amino.NET/Objects/MembershipInfo.cs +++ b/Amino.NET/Objects/MembershipInfo.cs @@ -1,49 +1,13 @@ -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/Message.cs b/Amino.NET/Objects/Message.cs index 91df94d..bb4c19c 100644 --- a/Amino.NET/Objects/Message.cs +++ b/Amino.NET/Objects/Message.cs @@ -1,56 +1,19 @@ -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/Notice.cs b/Amino.NET/Objects/Notice.cs new file mode 100644 index 0000000..4b2b440 --- /dev/null +++ b/Amino.NET/Objects/Notice.cs @@ -0,0 +1,28 @@ +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 Notice + { + [JsonPropertyName("icon")] public string IconUrl { get; set; } + //[JsonPropertyName("community")] No Data + [JsonPropertyName("title")] public string Title { get; set; } + [JsonPropertyName("ndcId")] public int? CommunityId { get; set; } + [JsonPropertyName("noticeId")] public string NoticeId { get; set; } + [JsonPropertyName("notificationId")] public string NotificationId { get; set; } + [JsonPropertyName("status")] public int? Status { get; set; } + [JsonPropertyName("type")] public int? Type { get; set; } + [JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; } + [JsonPropertyName("createdTime")] public string CreatedTime { get; set; } + //[JsonPropertyName("content")] No Data + + [JsonPropertyName("operator")] public GenericProfile Operator { get; set; } + [JsonPropertyName("targetUser")] public GenericProfile TargetUser { get; set; } + [JsonPropertyName("extensions")] public NoticeExtensions Extensions { get; set; } + } +} diff --git a/Amino.NET/Objects/NoticeExtensionConfig.cs b/Amino.NET/Objects/NoticeExtensionConfig.cs new file mode 100644 index 0000000..c79618f --- /dev/null +++ b/Amino.NET/Objects/NoticeExtensionConfig.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 NoticeExtensionConfig + { + [JsonPropertyName("showCommunity")] public bool? ShowCommunity { get; set; } + [JsonPropertyName("showOperator")] public bool? ShowOperator { get; set; } + [JsonPropertyName("allowQuickOperation")] public bool? AllowQuickOperation { get; set; } + [JsonPropertyName("operationList")] public List OperationList { get; set; } + } +} diff --git a/Amino.NET/Objects/NoticeExtensionOperation.cs b/Amino.NET/Objects/NoticeExtensionOperation.cs new file mode 100644 index 0000000..ed5a5d0 --- /dev/null +++ b/Amino.NET/Objects/NoticeExtensionOperation.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 NoticeExtensionOperation + { + [JsonPropertyName("text")] public string Text { get; set; } + [JsonPropertyName("operationType")] public int? OperationType { get; set; } + } +} diff --git a/Amino.NET/Objects/NoticeExtensionStyle.cs b/Amino.NET/Objects/NoticeExtensionStyle.cs new file mode 100644 index 0000000..30491ac --- /dev/null +++ b/Amino.NET/Objects/NoticeExtensionStyle.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 NoticeExtensionStyle + { + [JsonPropertyName("backgroundColor")] public string BackgroundColor { get; set; } + } +} diff --git a/Amino.NET/Objects/NoticeExtensions.cs b/Amino.NET/Objects/NoticeExtensions.cs new file mode 100644 index 0000000..9c25770 --- /dev/null +++ b/Amino.NET/Objects/NoticeExtensions.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 NoticeExtensions + { + [JsonPropertyName("operatorUid")] public string OperatorUid { get; set; } + [JsonPropertyName("style")] public NoticeExtensionStyle Style { get; set; } + [JsonPropertyName("config")] public NoticeExtensionConfig Config { get; set; } + } +} diff --git a/Amino.NET/Objects/PagingInfo.cs b/Amino.NET/Objects/PagingInfo.cs new file mode 100644 index 0000000..a4d120c --- /dev/null +++ b/Amino.NET/Objects/PagingInfo.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +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/ParticipatedExperiments.cs b/Amino.NET/Objects/ParticipatedExperiments.cs new file mode 100644 index 0000000..fd701bf --- /dev/null +++ b/Amino.NET/Objects/ParticipatedExperiments.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +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/Post.cs b/Amino.NET/Objects/Post.cs index c792a08..cd5c412 100644 --- a/Amino.NET/Objects/Post.cs +++ b/Amino.NET/Objects/Post.cs @@ -1,132 +1,36 @@ -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..07b3997 --- /dev/null +++ b/Amino.NET/Objects/PostExtensions.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +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 new file mode 100644 index 0000000..6fe4553 --- /dev/null +++ b/Amino.NET/Objects/SocketBase.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +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; } + [JsonPropertyName("chatBubbleId")] public string ChatBubbleId { get; set; } + } +} diff --git a/Amino.NET/Objects/SpecialChatEvent.cs b/Amino.NET/Objects/SpecialChatEvent.cs index 5c4a874..a095537 100644 --- a/Amino.NET/Objects/SpecialChatEvent.cs +++ b/Amino.NET/Objects/SpecialChatEvent.cs @@ -1,123 +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 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..1508c84 --- /dev/null +++ b/Amino.NET/Objects/Sticker.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +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..8eff388 --- /dev/null +++ b/Amino.NET/Objects/StickerCollectionSummary.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +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..cca7874 100644 --- a/Amino.NET/Objects/StickerMessage.cs +++ b/Amino.NET/Objects/StickerMessage.cs @@ -1,203 +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 StickerMessage { - public int _type { get; } - public int communityId { get; } - public int alertOption { get; } - public int membershipStatus { get; } + 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; } - 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"]; - } - } - } } } diff --git a/Amino.NET/Objects/TipInfo.cs b/Amino.NET/Objects/TipInfo.cs new file mode 100644 index 0000000..29fd34b --- /dev/null +++ b/Amino.NET/Objects/TipInfo.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +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/Topic.cs b/Amino.NET/Objects/Topic.cs new file mode 100644 index 0000000..36d909e --- /dev/null +++ b/Amino.NET/Objects/Topic.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 Topic + { + [JsonPropertyName("topicId")] public int TopicId { get; set; } + [JsonPropertyName("name")] public string Name { get; set; } + [JsonPropertyName("style")] public TopicStyle Style { get; set; } + } +} diff --git a/Amino.NET/Objects/TopicStyle.cs b/Amino.NET/Objects/TopicStyle.cs new file mode 100644 index 0000000..d053c4e --- /dev/null +++ b/Amino.NET/Objects/TopicStyle.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 TopicStyle + { + [JsonPropertyName("backgroundColor")] public string BackgroundColor { get; set; } + } +} diff --git a/Amino.NET/Objects/UserAccountAdvancedSettings.cs b/Amino.NET/Objects/UserAccountAdvancedSettings.cs new file mode 100644 index 0000000..376bc1a --- /dev/null +++ b/Amino.NET/Objects/UserAccountAdvancedSettings.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +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..631f7fc --- /dev/null +++ b/Amino.NET/Objects/UserAccountExtensions.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; + +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")] public DeviceInfo DeviceInfo { get; set; } + + } +} diff --git a/Amino.NET/Objects/UserAchievements.cs b/Amino.NET/Objects/UserAchievements.cs index 866cf42..acbea9e 100644 --- a/Amino.NET/Objects/UserAchievements.cs +++ b/Amino.NET/Objects/UserAchievements.cs @@ -1,24 +1,10 @@ -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 { 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/UserCheckins.cs b/Amino.NET/Objects/UserCheckins.cs index dc73b73..27bce50 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 df44a8a..ebd6864 100644 --- a/Amino.NET/Objects/UserProfile.cs +++ b/Amino.NET/Objects/UserProfile.cs @@ -1,93 +1,43 @@ -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 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; } - - 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 { } - } - } - + [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("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; } + [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; } } } \ No newline at end of file diff --git a/Amino.NET/Objects/UserVisitor.cs b/Amino.NET/Objects/UserVisitor.cs index b1dcbcf..df5bf94 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..4f0d971 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..5dc5e3d 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..6149c77 --- /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 new file mode 100644 index 0000000..340a0ad --- /dev/null +++ b/Amino.NET/Objects/WalletHistoryExtraData.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +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/WalletInfo.cs b/Amino.NET/Objects/WalletInfo.cs index 6e3c647..ab5452a 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 float? 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..0b1757d 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..3f5a34c 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 a426d23..180cbc8 100644 --- a/Amino.NET/Objects/chatMember.cs +++ b/Amino.NET/Objects/chatMember.cs @@ -1,71 +1,21 @@ -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 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; } } } diff --git a/Amino.NET/Objects/communityProfile.cs b/Amino.NET/Objects/communityProfile.cs deleted file mode 100644 index f2dc854..0000000 --- a/Amino.NET/Objects/communityProfile.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Amino.Objects -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class CommunityProfile - { - 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 CommunityProfile(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/eventLog.cs b/Amino.NET/Objects/eventLog.cs index 6d573d8..1377738 100644 --- a/Amino.NET/Objects/eventLog.cs +++ b/Amino.NET/Objects/eventLog.cs @@ -1,63 +1,23 @@ -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(); + [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; } - 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"]; - } - - } } } diff --git a/Amino.NET/Objects/globalProfile.cs b/Amino.NET/Objects/globalProfile.cs index e42e17b..4cf15f7 100644 --- a/Amino.NET/Objects/globalProfile.cs +++ b/Amino.NET/Objects/globalProfile.cs @@ -1,109 +1,43 @@ -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; } + [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; } - - - 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"]; - } - } } diff --git a/Amino.NET/Objects/messageCollection.cs b/Amino.NET/Objects/messageCollection.cs index bf3afbf..e3d5b3a 100644 --- a/Amino.NET/Objects/messageCollection.cs +++ b/Amino.NET/Objects/messageCollection.cs @@ -1,126 +1,11 @@ -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; } } } diff --git a/Amino.NET/Objects/userAccount.cs b/Amino.NET/Objects/userAccount.cs index de6f2de..151436e 100644 --- a/Amino.NET/Objects/userAccount.cs +++ b/Amino.NET/Objects/userAccount.cs @@ -1,115 +1,32 @@ -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) - { - 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"]; - - } - } - } } } diff --git a/Amino.NET/SubClient.cs b/Amino.NET/SubClient.cs index 6a42e38..dd0ba55 100644 --- a/Amino.NET/SubClient.cs +++ b/Amino.NET/SubClient.cs @@ -1,4 +1,4 @@ -using Amino.NET.Builders; +using Amino.Objects; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RestSharp; @@ -11,8 +11,10 @@ using System.Reactive.Subjects; using System.Runtime.Serialization.Formatters; using System.Text; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Amino.Builders; namespace Amino { @@ -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()); } @@ -118,9 +111,9 @@ public Task generate_invite_code(int duration = 0, bool force = true) data.Add("timestamp", helpers.GetTimestamp() * 1000); request.AddJsonBody(JsonConvert.SerializeObject(data)); request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); - var response = client.ExecuteGet(request); + 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; } @@ -880,7 +873,7 @@ public Task send_activity_time() int optInAdsFlags = 2147483647; int tzf = helpers.TzFilter(); data.Add("userActiveTimeChunkList", timeData); - data.Add("OptInAdsFlags", optInAdsFlags); + data.Add("optInAdsFlags", optInAdsFlags); data.Add("timestamp", (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds); data.Add("timezone", tzf); @@ -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) @@ -1194,11 +1187,12 @@ public Task send_file_message(string chatId, byte[] file, Types.upload_File_Type data.Add("enableUhqEnabled", true); break; case Types.upload_File_Types.Audio: + data.Remove("type"); data.Add("type", 2); data.Add("mediaType", 110); break; } - data.Add("mediaUploadValue", Encoding.UTF8.GetString(Convert.FromBase64String(Convert.ToBase64String(file)))); + data.Add("mediaUploadValue", Convert.ToBase64String(file)); RestClient client = new RestClient(helpers.BaseUrl); @@ -1208,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; } @@ -1251,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; } @@ -1280,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; } @@ -1302,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; } @@ -1326,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; } @@ -1343,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; } @@ -1362,70 +1356,54 @@ 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; } 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); } - if (debug) { Trace.WriteLine(response.Content); } + if (Debug) { Trace.WriteLine(response.Content); } return Task.CompletedTask; } 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); } - 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) @@ -1435,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) @@ -1482,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) @@ -1512,40 +1481,30 @@ 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) { - 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) @@ -1555,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) @@ -1566,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()); } @@ -1585,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) @@ -1595,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; } @@ -1618,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()); } @@ -1672,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) @@ -1685,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; } @@ -1696,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; } @@ -1709,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; } @@ -1745,11 +1695,13 @@ 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; } + public Amino.Client GetClient() => this.client; + public string GetCurrentCommunityId() => this.communityId; /// /// Not to be used in general use (THIS FUNCTION WILL DISPOSE THE SUBCLIENT) diff --git a/Amino.NET/Types.cs b/Amino.NET/Types.cs index b6293a3..e7be465 100644 --- a/Amino.NET/Types.cs +++ b/Amino.NET/Types.cs @@ -133,6 +133,13 @@ public enum Featured_Types Wiki, Chat } + + public enum Join_Types + { + Open = 0, + Request = 1, + Private = 2 + } public enum Object_Types { User = 0, @@ -240,13 +247,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 @@ -269,5 +276,32 @@ public enum Leaderboard_Ranking_Types CheckIn = 4, quiz = 5 } + + public enum RoleTypes + { + Agent, + Leader, + Curator + } + + public enum ModuleTypes + { + Chat, + LiveChat, + ScreeningRoom, + PublicChats, + Posts, + Ranking, + Leaderboards, + Featured, + FeaturedPosts, + FeaturedUsers, + FeaturedChats, + SharedFolder, + Influencer, + Catalog, + ExternalContent, + TopicCategories + } } } diff --git a/Amino.NET/WebSocketHandler.cs b/Amino.NET/WebSocketHandler.cs index 6252106..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,18 +65,18 @@ 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}"); } - eventHandler.ReceiveEvent(JObject.Parse(msg.Text), _client); + eventHandler.ReceiveEvent(msg.Text, _client); }); await ws_client.Start(); @@ -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."); } diff --git a/Amino.NET/helpers.cs b/Amino.NET/helpers.cs index 757cf09..5ccf2b9 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; @@ -234,31 +235,35 @@ public static List> getTimeData() /// /// /// - public static dynamic DecodeSid(string session) + public static Dictionary DecodeSid(string sid) { - // Replace characters and adjust padding - session = session.Replace('-', '_').Replace('+', '/'); - int padding = session.Length % 4; - if (padding > 0) + sid = sid.Replace('-', '+').Replace('_', '/'); + + int padding = 4 - (sid.Length % 4); + if (padding < 4) { - session = session.PadRight(session.Length + (4 - padding), '='); + sid += new string('=', padding); } - // Decode base64, remove the first byte, and remove the last 21 bytes - byte[] bytes = Convert.FromBase64String(session); - bytes = bytes.Skip(1).Take(bytes.Length - 21).ToArray(); - - // Convert bytes to UTF-8 string and parse JSON directly - string jsonString = Encoding.UTF8.GetString(bytes); - return System.Text.Json.JsonSerializer.Deserialize(jsonString); - } + byte[] decodedBytes = Convert.FromBase64String(sid); - public static string sid_to_uid(string session) { return DecodeSid(session)["2"]; } - 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"]; } + byte[] trimmedBytes = new byte[decodedBytes.Length - 21]; + Array.Copy(decodedBytes, 1, trimmedBytes, 0, trimmedBytes.Length); + string jsonString = Encoding.UTF8.GetString(trimmedBytes); + // Deserialize JSON string to dictionary + var options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + var dictionary = System.Text.Json.JsonSerializer.Deserialize>(jsonString, options); + return dictionary; + } + public static string sid_to_uid(string session) { return DecodeSid(session)["2"].ToString(); } + public static string sid_to_ip_address(string session) { return DecodeSid(session)["4"].ToString(); } + public static string sid_created_time(string session) { return DecodeSid(session)["5"].ToString(); } + public static string sid_to_client_type(string session) { return DecodeSid(session)["6"].ToString(); } } }