Skip to content

Commit

Permalink
Adding missing Emoji.Add arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Sep 8, 2019
1 parent 7a808c6 commit 02c09ae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/Reddit.NET/Inputs/Emoji/EmojiAddInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,27 @@ public class EmojiAddInput
/// </summary>
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; }

/// <summary>
/// Data for emoji to be uploaded.
/// </summary>
/// <param name="name">Name of the emoji to be created. It can be alphanumeric without any special characters except '-' & '_' and cannot exceed 24 characters</param>
/// <param name="s3Key">S3 key of the uploaded image which can be obtained from the S3 url. This is of the form subreddit/hash_value</param>
public EmojiAddInput(string name, string s3Key)
/// <param name="modFlairOnly">If this emoji is exclusive to mods' flairs (or mod-assigned flairs).</param>
/// <param name="postFlairAllowed">If this emoji should be usable on post flairs.</param>
/// <param name="userFlairAllowed">If this emoji should be usable on user flairs.</param>
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;
}
}
}
31 changes: 29 additions & 2 deletions src/Reddit.NET/Models/Emoji.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Xml.Serialization;
Expand Down Expand Up @@ -30,11 +29,27 @@ public Emoji(string appId, string appSecret, string refreshToken, string accessT
/// <param name="subreddit">The subreddit with the emojis</param>
/// <param name="emojiAddInput">A valid EmojiAddInput instance</param>
/// <returns>(TODO - Untested)</returns>
// TODO returns {"json": {"errors": []}}
public object Add(string subreddit, EmojiAddInput emojiAddInput)
{
return SendRequest<object>("api/v1/" + subreddit + "/emoji.json", emojiAddInput, Method.POST);
}

// TODO - Needs testing.
/// <summary>
/// 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.
/// </summary>
/// <param name="subreddit">The subreddit with the emojis</param>
/// <param name="emojiAddInput">A valid EmojiAddInput instance</param>
/// <returns>(TODO - Untested)</returns>
// TODO returns {"json": {"errors": []}}
public async Task<object> AddAsync(string subreddit, EmojiAddInput emojiAddInput)
{
return await SendRequestAsync<object>("api/v1/" + subreddit + "/emoji.json", emojiAddInput, Method.POST);
}

// TODO - Needs testing.
/// <summary>
/// Delete a Subreddit emoji. Remove the emoji from Cassandra and purge the assets from S3 and the image resizing provider.
Expand All @@ -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.
/// <summary>
/// Delete a Subreddit emoji. Remove the emoji from Cassandra and purge the assets from S3 and the image resizing provider.
/// </summary>
/// <param name="subreddit">The subreddit with the emojis</param>
/// <param name="emojiName">The name of the emoji to be deleted</param>
/// <returns>(TODO - Untested)</returns>
public async Task<object> DeleteAsync(string subreddit, string emojiName)
{
return JsonConvert.DeserializeObject(await ExecuteRequestAsync("api/v1/" + subreddit + "/emoji/" + emojiName, Method.DELETE));
}

/// <summary>
/// Acquire and return an upload lease to s3 temp bucket.
Expand Down

0 comments on commit 02c09ae

Please sign in to comment.