Exemple #1
0
        public async Task <UpdateChannelResponse> Update(GenericData customData, MessageInput msg = null, bool skipPush = false)
        {
            var payload = new JObject();

            payload.Add(new JProperty("data", customData.ToJObject()));
            if (msg != null)
            {
                payload.Add(new JProperty("message", msg.ToJObject()));

                if (skipPush)
                {
                    payload.Add("skip_push", true);
                }
            }

            var request = this._client.BuildAppRequest(this.Endpoint, HttpMethod.POST);

            request.SetJsonBody(payload.ToString());

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

            if (response.StatusCode == System.Net.HttpStatusCode.Created)
            {
                this._data = customData;
                var respObj = JObject.Parse(response.Content);
                return(UpdateChannelResponse.FromJObject(respObj));
            }
            throw StreamChatException.FromResponse(response);
        }
Exemple #2
0
        public async Task <UpdateChannelResponse> AssignRoles(AssignRoleRequest roleRequest)
        {
            var request = this._client.BuildAppRequest(this.Endpoint, HttpMethod.POST);

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

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

            if (response.StatusCode != System.Net.HttpStatusCode.Created)
            {
                throw StreamChatException.FromResponse(response);
            }

            var respObj = JObject.Parse(response.Content);

            return(UpdateChannelResponse.FromJObject(respObj));
        }