diff --git a/src/Reddit.NET/Inputs/Emoji/EmojiAddInput.cs b/src/Reddit.NET/Inputs/Emoji/EmojiAddInput.cs index 920a1a4f..9b4c7ba8 100644 --- a/src/Reddit.NET/Inputs/Emoji/EmojiAddInput.cs +++ b/src/Reddit.NET/Inputs/Emoji/EmojiAddInput.cs @@ -15,15 +15,27 @@ public class EmojiAddInput /// public string s3_key { get; set; } + public bool mod_flair_only { get; set; } + + public bool post_flair_allowed { get; set; } + + public bool user_flair_allowed { get; set; } + /// /// Data for emoji to be uploaded. /// /// Name of the emoji to be created. It can be alphanumeric without any special characters except '-' & '_' and cannot exceed 24 characters /// S3 key of the uploaded image which can be obtained from the S3 url. This is of the form subreddit/hash_value - public EmojiAddInput(string name, string s3Key) + /// If this emoji is exclusive to mods' flairs (or mod-assigned flairs). + /// If this emoji should be usable on post flairs. + /// If this emoji should be usable on user flairs. + public EmojiAddInput(string name, string s3Key, bool modFlairOnly, bool postFlairAllowed, bool userFlairAllowed) { this.name = name; s3_key = s3Key; + mod_flair_only = modFlairOnly; + post_flair_allowed = postFlairAllowed; + user_flair_allowed = userFlairAllowed; } } } diff --git a/src/Reddit.NET/Models/Emoji.cs b/src/Reddit.NET/Models/Emoji.cs index c27877f1..f0770bcb 100644 --- a/src/Reddit.NET/Models/Emoji.cs +++ b/src/Reddit.NET/Models/Emoji.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Net; using System.Threading.Tasks; using System.Xml.Serialization; @@ -30,11 +29,27 @@ public Emoji(string appId, string appSecret, string refreshToken, string accessT /// The subreddit with the emojis /// A valid EmojiAddInput instance /// (TODO - Untested) + // TODO returns {"json": {"errors": []}} public object Add(string subreddit, EmojiAddInput emojiAddInput) { return SendRequest("api/v1/" + subreddit + "/emoji.json", emojiAddInput, Method.POST); } + // TODO - Needs testing. + /// + /// Add an emoji to the DB by posting a message on emoji_upload_q. + /// A job processor that listens on a queue uses the s3_key provided in the request to locate the image in S3 Temp Bucket and moves it to the PERM bucket. + /// It also adds it to the DB using name as the column and sr_fullname as the key and sends the status on the websocket URL that is provided as part of this response. + /// + /// The subreddit with the emojis + /// A valid EmojiAddInput instance + /// (TODO - Untested) + // TODO returns {"json": {"errors": []}} + public async Task AddAsync(string subreddit, EmojiAddInput emojiAddInput) + { + return await SendRequestAsync("api/v1/" + subreddit + "/emoji.json", emojiAddInput, Method.POST); + } + // TODO - Needs testing. /// /// Delete a Subreddit emoji. Remove the emoji from Cassandra and purge the assets from S3 and the image resizing provider. @@ -46,6 +61,18 @@ public object Delete(string subreddit, string emojiName) { return JsonConvert.DeserializeObject(ExecuteRequest("api/v1/" + subreddit + "/emoji/" + emojiName, Method.DELETE)); } + + // TODO - Needs testing. + /// + /// Delete a Subreddit emoji. Remove the emoji from Cassandra and purge the assets from S3 and the image resizing provider. + /// + /// The subreddit with the emojis + /// The name of the emoji to be deleted + /// (TODO - Untested) + public async Task DeleteAsync(string subreddit, string emojiName) + { + return JsonConvert.DeserializeObject(await ExecuteRequestAsync("api/v1/" + subreddit + "/emoji/" + emojiName, Method.DELETE)); + } /// /// Acquire and return an upload lease to s3 temp bucket.