Esempio n. 1
0
        internal static PartialUpdateChannelResponse FromJObject(JObject jObj)
        {
            var result = new PartialUpdateChannelResponse();
            var data   = JsonHelpers.FromJObject(result, jObj);

            var chanObj = data.GetData <JObject>("channel");

            if (chanObj != null)
            {
                result.Channel = ChannelObjectWithInfo.FromJObject(chanObj);
            }

            var mbrs = data.GetData <JArray>("members");

            if (mbrs != null)
            {
                var members = new List <ChannelMember>();
                foreach (var mbr in mbrs)
                {
                    var memberObj = mbr as JObject;
                    members.Add(ChannelMember.FromJObject(memberObj));
                }
                result.Members = members;
            }

            return(result);
        }
Esempio n. 2
0
        public async Task <PartialUpdateChannelResponse> PartialUpdate(PartialUpdateChannelRequest partialUpdateChannelRequest)
        {
            var request = this._client.BuildAppRequest(this.Endpoint, HttpMethod.PATCH);

            request.SetJsonBody(partialUpdateChannelRequest.ToJObject().ToString());

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

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                if (partialUpdateChannelRequest.Unset != null)
                {
                    partialUpdateChannelRequest.Unset.ForEach(x => this._data.RemoveData(x));
                }
                if (partialUpdateChannelRequest.Set != null)
                {
                    partialUpdateChannelRequest.Set.ForEach(x => this._data.SetData(x.Key, x.Value));
                }

                var respObj = JObject.Parse(response.Content);
                return(PartialUpdateChannelResponse.FromJObject(respObj));
            }
            throw StreamChatException.FromResponse(response);
        }