Skip to content

Commit

Permalink
finish ACM class
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioGaming committed Jun 3, 2024
1 parent af78211 commit 41a467f
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 1 deletion.
236 changes: 235 additions & 1 deletion Amino.NET/ACMClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -229,5 +230,238 @@ public CommunityStats get_community_stats()
if (Client.Debug) { Trace.WriteLine(response.Content); }
return JsonSerializer.Deserialize<CommunityStats>(JsonDocument.Parse(response.Content).RootElement.GetProperty("communityStats").GetRawText());
}
}

public List<UserProfile> 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<List<UserProfile>>(JsonDocument.Parse(response.Content).RootElement.GetProperty("userProfileList").GetRawText());
}

public Task change_welcome_message(string message, bool isEnabled = true)
{
Dictionary<string, object> data = new Dictionary<string, object>()
{
{ "path", "general.welcomeMessage" },
{ "value", new Dictionary<string, object>()
{
{ "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<string, object> 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<string, object> 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<string, object> 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<string, object> data = new Dictionary<string, object>()
{
{ "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<string, object> data = new Dictionary<string, object>()
{
{ "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<Notice> 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<List<Notice>>(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;
}
}
}
1 change: 1 addition & 0 deletions Amino.NET/Objects/GenericProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class GenericProfile // ROOT JSON ELEMENT: userProfile
[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; }
Expand Down
28 changes: 28 additions & 0 deletions Amino.NET/Objects/Notice.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
17 changes: 17 additions & 0 deletions Amino.NET/Objects/NoticeExtensionConfig.cs
Original file line number Diff line number Diff line change
@@ -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<NoticeExtensionOperation> OperationList { get; set; }
}
}
15 changes: 15 additions & 0 deletions Amino.NET/Objects/NoticeExtensionOperation.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
14 changes: 14 additions & 0 deletions Amino.NET/Objects/NoticeExtensionStyle.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
16 changes: 16 additions & 0 deletions Amino.NET/Objects/NoticeExtensions.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
20 changes: 20 additions & 0 deletions Amino.NET/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,25 @@ public enum RoleTypes
Leader,
Curator
}

public enum ModuleTypes
{
Chat,
LiveChat,
ScreeningRoom,
PublicChats,
Posts,
Ranking,
Leaderboards,
Featured,
FeaturedPosts,
FeaturedUsers,
FeaturedChats,
SharedFolder,
Influencer,
Catalog,
ExternalContent,
TopicCategories
}
}
}

0 comments on commit 41a467f

Please sign in to comment.