/// <summary> /// Submit report to content and/or user for moderation. /// </summary> /// <param name="callback">This will be called when the operation succeeded. The result is ReportingSubmitResponse Model.</param> public void SubmitReport(ReportingSubmitData reportData, ResultCallback <ReportingSubmitResponse> callback) { Report.GetFunctionLog(this.GetType().Name); if (!this.session.IsValid()) { callback.TryError(ErrorCode.IsNotLoggedIn); return; } this.coroutineRunner.Run( this.api.SubmitReport(this.@namespace, this.session.AuthorizationToken, reportData, callback)); }
public IEnumerator SubmitReport(string @namespace, string accessToken, ReportingSubmitData reportData, ResultCallback <ReportingSubmitResponse> callback) { Report.GetFunctionLog(this.GetType().Name); Assert.IsNotNull(@namespace, "Can't create content! Namespace parameter is null!"); Assert.IsNotNull(accessToken, "Can't create content! AccessToken parameter is null!"); Assert.IsNotNull(reportData, "Can't create content! reasonGroup parameter is null!"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/v1/public/namespaces/{namespace}/reports") .WithPathParam("namespace", @namespace) .WithContentType(MediaType.ApplicationJson) .WithBearerAuth(accessToken) .WithBody(reportData.ToUtf8Json()) .Accepts(MediaType.ApplicationJson) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParseJson <ReportingSubmitResponse>(); callback.Try(result); }