Beispiel #1
0
        public async Task <TruncateResponse> Truncate(TruncateOptions truncateOptions)
        {
            var request = this._client.BuildAppRequest(this.Endpoint + "/truncate", HttpMethod.POST);

            if (truncateOptions != null)
            {
                request.SetJsonBody(truncateOptions.ToJObject().ToString());
            }

            var response = await this._client.MakeRequest(request);

            if (response.StatusCode == System.Net.HttpStatusCode.Created)
            {
                var respObj = JObject.Parse(response.Content);
                return(TruncateResponse.FromJObject(respObj));
            }
            throw StreamChatException.FromResponse(response);
        }
        internal static TruncateResponse FromJObject(JObject jObj)
        {
            var result = new TruncateResponse();

            var data   = JsonHelpers.FromJObject(result, jObj);
            var msgObj = data.GetData <JObject>("message");

            if (msgObj != null)
            {
                result.Message = Message.FromJObject(msgObj);
            }
            var chanObj = data.GetData <JObject>("channel");

            if (chanObj != null)
            {
                result.Channel = ChannelObjectWithInfo.FromJObject(chanObj);
            }
            result.Duration = data.GetData <string>("duration");

            return(result);
        }