Ejemplo n.º 1
0
        public async Task<ChannelTypeOutput> UpdateChannelType(string type, ChannelTypeInput channelType)
        {
            var payload = JObject.FromObject(channelType);
            payload.Remove("name");

            var endpoint = string.Format("channeltypes/{0}", type);
            var request = BuildAppRequest(endpoint, HttpMethod.PUT);
            request.SetJsonBody(payload.ToString());

            var response = await this.MakeRequest(request);

            if (response.StatusCode == System.Net.HttpStatusCode.Created)
                return JsonConvert.DeserializeObject<ChannelTypeOutput>(response.Content);

            throw StreamChatException.FromResponse(response);
        }
Ejemplo n.º 2
0
        public async Task<ChannelTypeOutput> CreateChannelType(ChannelTypeInput channelType)
        {
            if (channelType.Commands == null || channelType.Commands.Count == 0)
            {
                channelType.Commands = new List<string>() { Commands.All };
            }
            var request = BuildAppRequest("channeltypes", HttpMethod.POST);
            request.SetJsonBody(JsonConvert.SerializeObject(channelType));

            var response = await this.MakeRequest(request);

            if (response.StatusCode == System.Net.HttpStatusCode.Created)
                return JsonConvert.DeserializeObject<ChannelTypeOutput>(response.Content);

            throw StreamChatException.FromResponse(response);
        }