public async Task <bool> SetUserFlairAsync(string subreddit, string name, string text, string css = null)
        {
            var uri  = $"{BaseUri}/r/{subreddit}/api/flair";
            var data = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("api_type", "json"),
                new KeyValuePair <string, string>("name", name),
                new KeyValuePair <string, string>("text", "text")
            };

            if (css != null)
            {
                data.Add(new KeyValuePair <string, string>("css_class", css));
            }

            var result = await _requester.PostAsync(uri, data);

            return(!result["errors"].Any());
        }
        public async Task <bool> SendMessageAsync(string toUserName, string subject, string body)
        {
            const int maxSubjectLength = 100;

            if (string.IsNullOrEmpty(toUserName))
            {
                throw new ArgumentException("toUserName is required.");
            }
            if (string.IsNullOrEmpty(subject))
            {
                throw new ArgumentException("subject is required.");
            }
            if (string.IsNullOrEmpty(body))
            {
                throw new ArgumentException("body is required.");
            }
            if (subject.Length > maxSubjectLength)
            {
                throw new ArgumentException("subject must not be longer than 100 characters.");
            }

            // for some reason, the /api/compose endpoint uses a POST request but wants its
            // parameters in the query string.
            var parameters = new[]
            {
                new { key = "to", value = toUserName },
                new { key = "subject", value = subject },
                new { key = "text", value = body }
            };

            var pairs = from p in parameters
                        select $"{Uri.EscapeDataString(p.key)}={Uri.EscapeDataString(p.value)}";

            var uri = $"{BaseUri}/api/compose?{string.Join("&", pairs)}";

            Trace.WriteLine("POST " + uri);
            var result = await _requester.PostAsync(uri);

            return(true);
        }