Skip to content

Commit 77a5540

Browse files
committed
refactored more objects
1 parent 2855efc commit 77a5540

8 files changed

Lines changed: 106 additions & 670 deletions

File tree

Amino.NET/Objects/ImageMessage.cs

Lines changed: 19 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,30 @@
11
using Newtonsoft.Json;
22
using Newtonsoft.Json.Linq;
3+
using System.Text.Json.Serialization;
34

45
namespace Amino.Objects
56
{
67
//MediaType: 100
7-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
8+
// ROOT JSON ELEMENT: o/chatMessage
89
public class ImageMessage
910
{
10-
public int _type { get; }
11-
public int communityId { get; }
12-
public string mediaUrl { get; }
13-
public string chatId { get; }
14-
public int mediaType { get; }
15-
public int clientRefId { get; }
16-
public string messageId { get; }
17-
public string objectId { get; }
18-
public string createdTime { get; }
19-
public int type { get; }
20-
public bool isHidden { get; }
21-
public bool includedInSummary { get; }
22-
public string chatBubbleId { get; }
23-
public int chatBubbleVersion { get; }
24-
public int alertOption { get; }
25-
public int membershipStatus { get; }
26-
public string json { get; }
27-
public _Author Author { get; }
28-
29-
public ImageMessage(JObject _json)
30-
{
31-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
32-
try { _type = (int)jsonObj["t"]; } catch { }
33-
try { communityId = (int)jsonObj["o"]["ndcId"]; } catch { }
34-
try { mediaUrl = (string)jsonObj["o"]["chatMessage"]["mediaValue"]; } catch { }
35-
try { chatId = (string)jsonObj["o"]["chatMessage"]["threadId"]; } catch { }
36-
try { mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"]; } catch { }
37-
try { clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"]; } catch { }
38-
try { messageId = (string)jsonObj["o"]["chatMessage"]["messageId"]; } catch { }
39-
try { objectId = (string)jsonObj["o"]["chatMessage"]["uid"]; } catch { }
40-
try { createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"]; } catch { }
41-
try { type = (int)jsonObj["o"]["chatMessage"]["type"]; } catch { }
42-
try { isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"]; } catch { }
43-
try { includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"]; } catch { }
44-
try { chatBubbleId = (string)jsonObj["o"]["chatMessage"]["chatBubbleId"]; } catch { }
45-
try { chatBubbleVersion = (int)jsonObj["o"]["chatMessage"]["chatBubbleVersion"]; } catch { }
46-
try { alertOption = (int)jsonObj["o"]["alertOption"]; } catch { }
47-
try { membershipStatus = (int)jsonObj["o"]["membershipStatus"]; } catch { }
48-
json = _json.ToString();
49-
Author = new _Author(_json);
50-
}
51-
52-
53-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
54-
public class _Author
55-
{
56-
public string userId { get; }
57-
public int status { get; }
58-
public string iconUrl { get; }
59-
public int reputation { get; }
60-
public int role { get; }
61-
public string nickname { get; }
62-
public int level { get; }
63-
public int accountMembershipStatus { get; }
64-
public _AvatarFrame AvatarFrame { get; }
65-
public _InfluencerInfo InfluencerInfo { get; }
66-
67-
public _Author(JObject _json)
68-
{
69-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
70-
try { userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"]; } catch { }
71-
try { status = (int)jsonObj["o"]["chatMessage"]["author"]["status"]; } catch { }
72-
try { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; } catch { }
73-
try { reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"]; } catch { }
74-
try { role = (int)jsonObj["o"]["chatMessage"]["author"]["role"]; } catch { }
75-
try { nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"]; } catch { }
76-
try { level = (int)jsonObj["o"]["chatMessage"]["author"]["level"]; } catch { }
77-
try { if (jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } } catch { }
78-
try { if (jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } } catch { }
79-
}
80-
81-
82-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
83-
public class _AvatarFrame
84-
{
85-
public int status { get; }
86-
public int version { get; }
87-
public string resourceUrl { get; }
88-
public string name { get; }
89-
public string iconUrl { get; }
90-
public int frameType { get; }
91-
public string frameId { get; }
92-
93-
public _AvatarFrame(JObject _json)
94-
{
95-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
96-
try { status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"]; } catch { }
97-
try { version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"]; } catch { }
98-
try { resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"]; } catch { }
99-
try { name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"]; } catch { }
100-
try { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"]; } catch { }
101-
try { frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"]; } catch { }
102-
try { frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"]; } catch { }
103-
}
104-
}
105-
106-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
107-
public class _InfluencerInfo
108-
{
109-
public int fansCount { get; }
110-
public int monthlyFee { get; }
111-
112-
public _InfluencerInfo(JObject _json)
113-
{
114-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
115-
try { fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"]; } catch { }
116-
try { monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"]; } catch { }
117-
}
118-
119-
}
120-
}
11+
SocketBase SocketBase { get; set; } // NEEDS TO BE SET AFTER
12+
public string Json { get; set; } // NEEDS TO BE SET AFTER
13+
[JsonPropertyName("mediaValue")]public string MediaUrl { get; set; }
14+
[JsonPropertyName("threadId")]public string ChatId { get; set; }
15+
[JsonPropertyName("mediaType")]public int MediaType { get; set; }
16+
[JsonPropertyName("clientRefId")]public int ClientRefId { get; set; }
17+
[JsonPropertyName("messageId")]public string MessageId { get; set; }
18+
[JsonPropertyName("uid")]public string ObjectId { get; set; }
19+
[JsonPropertyName("createdTime")]public string CreatedTime { get; set; }
20+
[JsonPropertyName("type")]public int Type { get; set; }
21+
[JsonPropertyName("isHidden")]public bool IsHidden { get; set; }
22+
[JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; }
23+
[JsonPropertyName("chatBubbleId")]public string ChatBubbleId { get; set; }
24+
[JsonPropertyName("chatBubbleVersion")]public int ChatBubbleVersion { get; set; }
25+
[JsonPropertyName("alertOption")]public int AlertOption { get; set; }
26+
[JsonPropertyName("membershipStatus")]public int MembershipStatus { get; set; }
27+
[JsonPropertyName("author")]public GenericProfile Author { get; set; }
12128

12229

12330
}
Lines changed: 4 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1,204 +1,14 @@
11
using Newtonsoft.Json.Linq;
22
using System.Collections.Generic;
3+
using System.Text.Json.Serialization;
34

45
namespace Amino.Objects
56
{
67
public class InfluencerInfo
78
{
89

9-
public _FanClubMember MyFanClub { get; }
10-
public _FanClubUserProfile InfluencerUserProfile { get; }
11-
public List<_FanClubMember> FanClubMembers { get; } = new();
12-
public string json { get; }
13-
14-
public InfluencerInfo(JObject json)
15-
{
16-
this.json = json.ToString();
17-
try { MyFanClub = new(JObject.Parse((string)json["myFanClub"])); } catch { }
18-
try { InfluencerUserProfile = new(JObject.Parse((string)json["influencerUserProfile"])); } catch { }
19-
if (json["fanClubList"] != null) { foreach (JObject clubMember in json["fanClubList"]) { FanClubMembers.Add(new(clubMember)); } }
20-
21-
}
22-
23-
24-
25-
public class _FanClubMember
26-
{
27-
public string userId { get; }
28-
public string lastThankedTime { get; }
29-
public string expiredTime { get; }
30-
public string createdTime { get; }
31-
public int fansStatus { get; } = 0;
32-
public _FanClubUserProfile FanUserProfile { get; }
33-
34-
public _FanClubMember(JObject json)
35-
{
36-
try { userId = (string)json["uid"]; } catch { }
37-
try { lastThankedTime = (string)json["lastThankedTime"]; } catch { }
38-
try { expiredTime = (string)json["expiredTime"]; } catch { }
39-
try { createdTime = (string)json["createdTime"]; } catch { }
40-
try { fansStatus = (int)json["fansStatus"]; } catch { }
41-
42-
try { FanUserProfile = new(JObject.Parse((string)json["fansUserProfile"])); } catch { }
43-
}
44-
45-
46-
47-
}
48-
public class _FanClubUserProfile
49-
{
50-
public int status { get; } = 0;
51-
public string moodSticker { get; }
52-
public int itemsCount { get; } = 0;
53-
public int consecutiveCheckInDays { get; } = 0;
54-
public string userId { get; }
55-
public string modifiedTime { get; }
56-
public int followingStatus { get; } = 0;
57-
public int onlineStatus { get; } = 0;
58-
public int accountMembershipStatus { get; } = 0;
59-
public bool isGlobal { get; } = false;
60-
public string avatarFrameId { get; }
61-
public int reputation { get; } = 0;
62-
public int postsCount { get; } = 0;
63-
public int membersCount { get; } = 0;
64-
public string nickname { get; }
65-
public string iconUrl { get; }
66-
public bool isNicknameVerified { get; } = false;
67-
public string mood { get; }
68-
public int level { get; } = 0;
69-
public int notificationSubscriptionStatus { get; } = 0;
70-
public bool pushEnabled { get; } = false;
71-
public int membershipStatus { get; } = 0;
72-
public string content { get; }
73-
public int joinedCount { get; } = 0;
74-
public int role { get; } = 0;
75-
public int commentsCount { get; } = 0;
76-
public int communityId { get; } = 0;
77-
public string createdTime { get; }
78-
public int storiesCount { get; } = 0;
79-
public int blogsCount { get; } = 0;
80-
public _AvatarFrame AvatarFrame { get; }
81-
public _Extensions Extensions { get; }
82-
public _InfluencerInfo InfluencerInfo { get; }
83-
84-
85-
public _FanClubUserProfile(JObject json)
86-
{
87-
try { status = (int)json["status"]; } catch { }
88-
try { moodSticker = (string)json["moodSticker"]; } catch { }
89-
try { itemsCount = (int)json["itemsCount"]; } catch { }
90-
try { consecutiveCheckInDays = (int)json["consecutiveCheckInDays"]; } catch { }
91-
try { userId = (string)json["uid"]; } catch { }
92-
try { modifiedTime = (string)json["modifiedTime"]; } catch { }
93-
try { followingStatus = (int)json["followingStatus"]; } catch { }
94-
try { onlineStatus = (int)json["onlineStatus"]; } catch { }
95-
try { accountMembershipStatus = (int)json["accountMembershipStatus"]; } catch { }
96-
try { isGlobal = (bool)json["isGlobal"]; } catch { }
97-
try { reputation = (int)json["reputation"]; } catch { }
98-
try { postsCount = (int)json["postsCount"]; } catch { }
99-
try { membersCount = (int)json["membersCount"]; } catch { }
100-
try { nickname = (string)json["nickname"]; } catch { }
101-
try { iconUrl = (string)json["icon"]; } catch { }
102-
try { isNicknameVerified = (bool)json["isNicknameVerified"]; } catch { }
103-
try { mood = (string)json["mood"]; } catch { }
104-
try { level = (int)json["level"]; } catch { }
105-
try { notificationSubscriptionStatus = (int)json["notificationSubscriptionStatus"]; } catch { }
106-
try { pushEnabled = (bool)json["pushEnabled"]; } catch { }
107-
try { membershipStatus = (int)json["membershipStatus"]; } catch { }
108-
try { content = (string)json["content"]; } catch { }
109-
try { joinedCount = (int)json["joinedCount"]; } catch { }
110-
try { role = (int)json["role"]; } catch { }
111-
try { commentsCount = (int)json["commentsCount"]; } catch { }
112-
try { communityId = (int)json["ndcId"]; } catch { }
113-
try { createdTime = (string)json["createdTime"]; } catch { }
114-
try { storiesCount = (int)json["storiesCount"]; } catch { }
115-
try { blogsCount = (int)json["blogsCount"]; } catch { }
116-
117-
if (json["extensions"] != null) { Extensions = new(JObject.Parse((string)json["extensions"])); }
118-
if (json["avatarFrame"] != null) { AvatarFrame = new(JObject.Parse((string)json["avatarFrame"])); }
119-
if (json["influencerInfo"] != null) { InfluencerInfo = new(JObject.Parse((string)json["influencerInfo"])); }
120-
}
121-
122-
123-
124-
public class _AvatarFrame
125-
{
126-
public int status { get; } = 0;
127-
public int ownershipStatus { get; } = 0;
128-
public int version { get; } = 0;
129-
public string resoureUrl { get; }
130-
public string name { get; }
131-
public string iconUrl { get; }
132-
public int frameType { get; } = 0;
133-
public string frameId { get; }
134-
135-
public _AvatarFrame(JObject json)
136-
{
137-
try { status = (int)json["status"]; } catch { }
138-
try { ownershipStatus = (int)json["ownershipStatus"]; } catch { }
139-
try { version = (int)json["version"]; } catch { }
140-
try { resoureUrl = (string)json["resourceUrl"]; } catch { }
141-
try { name = (string)json["name"]; } catch { }
142-
try { iconUrl = (string)json["icon"]; } catch { }
143-
try { frameType = (int)json["frameType"]; } catch { }
144-
try { frameId = (string)json["frameId"]; } catch { }
145-
}
146-
}
147-
148-
public class _InfluencerInfo
149-
{
150-
public bool pinned { get; } = false;
151-
public string createdTime { get; }
152-
public int fansCount { get; } = 0;
153-
public int monthlyFee { get; } = 0;
154-
155-
public _InfluencerInfo(JObject json)
156-
{
157-
try { pinned = (bool)json["pinned"]; } catch { }
158-
try { createdTime = (string)json["createdTime"]; } catch { }
159-
try { fansCount = (int)json["fansCount"]; } catch { }
160-
try { monthlyFee = (int)json["monthlyFee"]; } catch { }
161-
}
162-
}
163-
164-
public class _Extensions
165-
{
166-
public string defaultBubbleId { get; }
167-
public _Style Style { get; }
168-
public List<_CustomTitle> CustomTitles { get; } = new List<_CustomTitle>();
169-
170-
public _Extensions(JObject json)
171-
{
172-
try { defaultBubbleId = (string)json["defaultBubbleId"]; } catch { }
173-
if (json["style"] != null) { Style = new(JObject.Parse((string)json["style"])); }
174-
if (json["customTitles"] != null)
175-
{
176-
foreach(JObject title in json["customTitles"]) { CustomTitles.Add(new(title)); }
177-
}
178-
}
179-
180-
public class _CustomTitle
181-
{
182-
public string color { get; }
183-
public string title { get; }
184-
185-
public _CustomTitle(JObject json)
186-
{
187-
try { color = (string)json["color"]; } catch { }
188-
try { title = (string)json["title"]; } catch { }
189-
}
190-
}
191-
192-
public class _Style
193-
{
194-
public string backgroundColor { get; }
195-
196-
public _Style(JObject json)
197-
{
198-
try { backgroundColor = (string)json["backgroundColor"]; } catch { }
199-
}
200-
}
201-
}
202-
}
10+
[JsonPropertyName("myFanClub")]public InfluencerFanClubMember MyFanClub { get; set; }
11+
[JsonPropertyName("influencerUserProfile")]public UserProfile InfluencerUserProfile { get; set; }
12+
[JsonPropertyName("fanClubList")]public List<InfluencerFanClubMember> FanClubMembers { get; set; }
20313
}
20414
}

0 commit comments

Comments
 (0)