Skip to content

Commit 41a467f

Browse files
committed
finish ACM class
1 parent af78211 commit 41a467f

8 files changed

Lines changed: 346 additions & 1 deletion

File tree

Amino.NET/ACMClient.cs

Lines changed: 235 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Diagnostics;
77
using System.Linq;
8+
using System.Reflection.Metadata.Ecma335;
89
using System.Runtime.InteropServices;
910
using System.Text;
1011
using System.Text.Json;
@@ -229,5 +230,238 @@ public CommunityStats get_community_stats()
229230
if (Client.Debug) { Trace.WriteLine(response.Content); }
230231
return JsonSerializer.Deserialize<CommunityStats>(JsonDocument.Parse(response.Content).RootElement.GetProperty("communityStats").GetRawText());
231232
}
232-
}
233+
234+
public List<UserProfile> get_community_user_stats(Types.RoleTypes roleType, int start = 0, int size = 25)
235+
{
236+
string _target = "";
237+
switch (roleType)
238+
{
239+
case Types.RoleTypes.Leader:
240+
_target = "leader";
241+
break;
242+
case Types.RoleTypes.Curator:
243+
_target = "curator";
244+
break;
245+
default:
246+
_target = "leader";
247+
break;
248+
}
249+
RestRequest request = new RestRequest($"/x{CommunityId}/s/community/stats/moderation?type={_target}&start={start}&size={size}");
250+
var response = RClient.ExecuteGet(request);
251+
if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
252+
if (Client.Debug) { Trace.WriteLine(response.Content); }
253+
return JsonSerializer.Deserialize<List<UserProfile>>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText());
254+
}
255+
256+
public Task change_welcome_message(string message, bool isEnabled = true)
257+
{
258+
Dictionary<string, object> data = new Dictionary<string, object>()
259+
{
260+
{ "path", "general.welcomeMessage" },
261+
{ "value", new Dictionary<string, object>()
262+
{
263+
{ "enabled", isEnabled },
264+
{ "text", message }
265+
} },
266+
{ "timestamp", helpers.GetTimestamp() * 1000 }
267+
};
268+
RestRequest request = new RestRequest($"/x{CommunityId}/s/community/configuration");
269+
request.AddJsonBody(JsonSerializer.Serialize(data));
270+
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data)));
271+
var response = RClient.ExecutePost(request);
272+
if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
273+
if(Client.Debug) { Trace.WriteLine(response.Content); }
274+
return Task.CompletedTask;
275+
}
276+
277+
public Task change_amino_id(string aminoId)
278+
{
279+
Dictionary<string, object> data = new()
280+
{
281+
{ "endpoint", aminoId },
282+
{ "timestamp", helpers.GetTimestamp() * 1000 }
283+
};
284+
RestRequest request = new RestRequest($"/x{CommunityId}/s/community/settings");
285+
request.AddJsonBody(JsonSerializer.Serialize(data));
286+
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data)));
287+
var response = RClient.ExecutePost(request);
288+
if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
289+
if(Client.Debug) { Trace.WriteLine(response.Content); }
290+
return Task.CompletedTask;
291+
}
292+
293+
public Task change_guidelines(string guidelines)
294+
{
295+
Dictionary<string, object> data = new()
296+
{
297+
{ "content", guidelines },
298+
{ "timestamp", helpers.GetTimestamp() * 1000 }
299+
};
300+
RestRequest request = new RestRequest($"/x{CommunityId}/s/community/guidelines");
301+
request.AddJsonBody(JsonSerializer.Serialize(data));
302+
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data)));
303+
var response = RClient.ExecutePost(request);
304+
if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
305+
if(Client.Debug) { Trace.WriteLine(response.Content); }
306+
return Task.CompletedTask;
307+
}
308+
309+
public Task edit_community(string name = null, string description = null, string aminoId = null, Types.Supported_Languages primaryLanguage = Types.Supported_Languages.English, string themePackUrl = null)
310+
{
311+
string _lang = "en";
312+
switch (primaryLanguage)
313+
{
314+
case Types.Supported_Languages.English:
315+
_lang = "en";
316+
break;
317+
case Types.Supported_Languages.Spanish:
318+
_lang = "es";
319+
break;
320+
case Types.Supported_Languages.Portuguese:
321+
_lang = "pt";
322+
break;
323+
case Types.Supported_Languages.Arabic:
324+
_lang = "ar";
325+
break;
326+
case Types.Supported_Languages.Russian:
327+
_lang = "ru";
328+
break;
329+
case Types.Supported_Languages.French:
330+
_lang = "fr";
331+
break;
332+
case Types.Supported_Languages.German:
333+
_lang = "de";
334+
break;
335+
}
336+
Dictionary<string, object> data = new();
337+
data.Add("timestamp", helpers.GetTimestamp() * 1000);
338+
data.Add("primaryLanguage", _lang);
339+
340+
if (name != null) data.Add("name", name);
341+
if (description != null) data.Add("content", description);
342+
if (aminoId != null) data.Add("endpoint", aminoId);
343+
if (themePackUrl != null) data.Add("themePackUrl", themePackUrl);
344+
345+
RestRequest request = new RestRequest($"/x{CommunityId}/s/community/settings");
346+
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data)));
347+
request.AddJsonBody(JsonSerializer.Serialize(data));
348+
var response = RClient.ExecutePost(request);
349+
if(!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
350+
if(Client.Debug) { Trace.WriteLine(response.Content); }
351+
return Task.CompletedTask;
352+
}
353+
354+
public Task change_module(Types.ModuleTypes moduleType, bool isEnabled)
355+
{
356+
string _module = "";
357+
switch(moduleType)
358+
{
359+
case Types.ModuleTypes.Chat:
360+
_module = "module.chat.enabled";
361+
break;
362+
case Types.ModuleTypes.LiveChat:
363+
_module = "module.chat.avChat.videoEnabled";
364+
break;
365+
case Types.ModuleTypes.ScreeningRoom:
366+
_module = "module.chat.avChat.screeningRoomEnabled";
367+
break;
368+
case Types.ModuleTypes.PublicChats:
369+
_module = "module.chat.publicChat.enabled";
370+
break;
371+
case Types.ModuleTypes.Posts:
372+
_module = "module.post.enabled";
373+
break;
374+
case Types.ModuleTypes.Ranking:
375+
_module = "module.ranking.enabled";
376+
break;
377+
case Types.ModuleTypes.Leaderboards:
378+
_module = "module.ranking.leaderboardEnabled";
379+
break;
380+
case Types.ModuleTypes.Featured:
381+
_module = "module.featured.enabled";
382+
break;
383+
case Types.ModuleTypes.FeaturedPosts:
384+
_module = "module.featured.postEnabled";
385+
break;
386+
case Types.ModuleTypes.FeaturedUsers:
387+
_module = "module.featured.memberEnabled";
388+
break;
389+
case Types.ModuleTypes.FeaturedChats:
390+
_module = "module.featured.publicChatRoomEnabled";
391+
break;
392+
case Types.ModuleTypes.SharedFolder:
393+
_module = "module.sharedFolder.enabled";
394+
break;
395+
case Types.ModuleTypes.Influencer:
396+
_module = "module.influencer.enabled";
397+
break;
398+
case Types.ModuleTypes.Catalog:
399+
_module = "module.catalog.enabled";
400+
break;
401+
case Types.ModuleTypes.ExternalContent:
402+
_module = "module.externalContent.enabled";
403+
break;
404+
case Types.ModuleTypes.TopicCategories:
405+
_module = "module.topicCategories.enabled";
406+
break;
407+
}
408+
409+
Dictionary<string, object> data = new Dictionary<string, object>()
410+
{
411+
{ "path", _module },
412+
{ "value", isEnabled },
413+
{ "timestamp", helpers.GetTimestamp() * 1000 }
414+
};
415+
RestRequest request = new RestRequest($"/x{CommunityId}/s/community/configuration");
416+
request.AddJsonBody(JsonSerializer.Serialize(data));
417+
request.AddHeader("NDC-MSG-SIG", JsonSerializer.Serialize(data));
418+
var response = RClient.ExecutePost(request);
419+
if(!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
420+
if(Client.Debug) { Trace.WriteLine(response.Content); }
421+
return Task.CompletedTask;
422+
}
423+
424+
public Task add_influencer(string userId, int monthlyFee)
425+
{
426+
Dictionary<string, object> data = new Dictionary<string, object>()
427+
{
428+
{ "monthlyFee", monthlyFee },
429+
{ "timestamp", helpers.GetTimestamp() * 1000 },
430+
};
431+
RestRequest request = new RestRequest($"/x{CommunityId}/s/influencer/{userId}");
432+
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonSerializer.Serialize(data)));
433+
request.AddJsonBody(JsonSerializer.Serialize(data));
434+
var response = RClient.ExecutePost(request);
435+
if(!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
436+
if(Client.Debug) { Trace.WriteLine(response.Content); }
437+
return Task.CompletedTask;
438+
}
439+
440+
public Task remove_influencer(string userId)
441+
{
442+
RestRequest request = new RestRequest($"/x{CommunityId}/s/influencer/{userId}");
443+
var response = RClient.Delete(request);
444+
if (!response.IsSuccessStatusCode) { return Task.CompletedTask; }
445+
if (Client.Debug) { Trace.WriteLine(response.Content); }
446+
return Task.CompletedTask;
447+
}
448+
449+
public List<Notice> get_notice_list(int start = 0, int size = 25)
450+
{
451+
RestRequest request = new RestRequest($"/x{CommunityId}/s/notice?type=management&status=1&sart={start}&size={size}");
452+
var response = RClient.ExecuteGet(request);
453+
if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
454+
if(Client.Debug) { Trace.WriteLine(response.Content); }
455+
return JsonSerializer.Deserialize<List<Notice>>(JsonDocument.Parse(response.Content).RootElement.GetProperty("noticeList").GetRawText());
456+
}
457+
458+
public Task delete_pending_role(string noticeId)
459+
{
460+
RestRequest request = new RestRequest($"/x{CommunityId}/s/notice/{noticeId}");
461+
var response = RClient.Delete(request);
462+
if (!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
463+
if(Client.Debug) { Trace.WriteLine(response.Content); }
464+
return Task.CompletedTask;
465+
}
466+
}
233467
}

Amino.NET/Objects/GenericProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class GenericProfile // ROOT JSON ELEMENT: userProfile
1919
[JsonPropertyName("nickname")]public string Nickname { get; set; }
2020
[JsonPropertyName("icon")]public string IconUrl { get; set; }
2121
[JsonPropertyName("ndcId")]public int? CommunityId { get; set; }
22+
[JsonPropertyName("role")] public int? Role { get; set; }
2223

2324
[JsonPropertyName("avatarFrame")] public GenericAvatarFrame AvatarFrame { get; set; }
2425
[JsonPropertyName("influencerInfo")] public InfluencerPriceInfo InfluencerInfo { get; set; }

Amino.NET/Objects/Notice.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class Notice
11+
{
12+
[JsonPropertyName("icon")] public string IconUrl { get; set; }
13+
//[JsonPropertyName("community")] No Data
14+
[JsonPropertyName("title")] public string Title { get; set; }
15+
[JsonPropertyName("ndcId")] public int? CommunityId { get; set; }
16+
[JsonPropertyName("noticeId")] public string NoticeId { get; set; }
17+
[JsonPropertyName("notificationId")] public string NotificationId { get; set; }
18+
[JsonPropertyName("status")] public int? Status { get; set; }
19+
[JsonPropertyName("type")] public int? Type { get; set; }
20+
[JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; }
21+
[JsonPropertyName("createdTime")] public string CreatedTime { get; set; }
22+
//[JsonPropertyName("content")] No Data
23+
24+
[JsonPropertyName("operator")] public GenericProfile Operator { get; set; }
25+
[JsonPropertyName("targetUser")] public GenericProfile TargetUser { get; set; }
26+
[JsonPropertyName("extensions")] public NoticeExtensions Extensions { get; set; }
27+
}
28+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class NoticeExtensionConfig
11+
{
12+
[JsonPropertyName("showCommunity")] public bool? ShowCommunity { get; set; }
13+
[JsonPropertyName("showOperator")] public bool? ShowOperator { get; set; }
14+
[JsonPropertyName("allowQuickOperation")] public bool? AllowQuickOperation { get; set; }
15+
[JsonPropertyName("operationList")] public List<NoticeExtensionOperation> OperationList { get; set; }
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class NoticeExtensionOperation
11+
{
12+
[JsonPropertyName("text")] public string Text { get; set; }
13+
[JsonPropertyName("operationType")] public int? OperationType { get; set; }
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class NoticeExtensionStyle
11+
{
12+
[JsonPropertyName("backgroundColor")] public string BackgroundColor { get; set; }
13+
}
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class NoticeExtensions
11+
{
12+
[JsonPropertyName("operatorUid")] public string OperatorUid { get; set; }
13+
[JsonPropertyName("style")] public NoticeExtensionStyle Style { get; set; }
14+
[JsonPropertyName("config")] public NoticeExtensionConfig Config { get; set; }
15+
}
16+
}

Amino.NET/Types.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,5 +283,25 @@ public enum RoleTypes
283283
Leader,
284284
Curator
285285
}
286+
287+
public enum ModuleTypes
288+
{
289+
Chat,
290+
LiveChat,
291+
ScreeningRoom,
292+
PublicChats,
293+
Posts,
294+
Ranking,
295+
Leaderboards,
296+
Featured,
297+
FeaturedPosts,
298+
FeaturedUsers,
299+
FeaturedChats,
300+
SharedFolder,
301+
Influencer,
302+
Catalog,
303+
ExternalContent,
304+
TopicCategories
305+
}
286306
}
287307
}

0 commit comments

Comments
 (0)