예제 #1
0
        /// <summary>
        /// Register that the requesting person considers the specified content as abusive.
        /// </summary>
        /// <param name="contentID">ID of the content marked as abusive</param>
        /// <param name="abuse_report">an AbuseReport object containing the abuse report information</param>
        /// <returns>an AbuseReport object containing the newly created abuse report</returns>
        public AbuseReport CreateAbuseReport(int contentID, AbuseReport abuse_report)
        {
            string url = contentUrl + "/" + contentID.ToString() + "/abuseReports";

            string json = JsonConvert.SerializeObject(abuse_report, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
            string result = "";
            try
            {
                result = PostAbsolute(url, json); //makes the HTTP request
            }
            catch (HttpException e)
            {
                switch (e.GetHttpCode())
                {
                    case 400:
                        throw new HttpException(e.WebEventCode, "An input field is missing or malformed", e);
                    case 403:
                        throw new HttpException(e.WebEventCode, "You are not allowed to access or mark this content as abusive", e);
                    case 404:
                        throw new HttpException(e.WebEventCode, "The specified content does not exist", e);
                    default:
                        throw;
                }
            }

            JObject Json = JObject.Parse(result);
            return Json.ToObject<AbuseReport>();
        }