コード例 #1
0
        public async Task CreateChannelAsync(ChannelOrGroupCreationDto model)
        {
            if (string.IsNullOrWhiteSpace(model.Title))
            {
                throw new ArgumentException("Title can't be empty");
            }

            if (string.IsNullOrWhiteSpace(model.Description))
            {
                throw new ArgumentException("Description can't be empty");
            }

            var request = new TLRequestCreateChannel()
            {
                Title = model.Title,
                About = model.Description
            };

            await client.SendRequestAsync <object>(request);
        }
コード例 #2
0
        public async Task CreateGroupAsync(ChannelOrGroupCreationDto model)
        {
            if (string.IsNullOrWhiteSpace(model.Title))
            {
                throw new ArgumentException("Title can't be empty");
            }

            var uri = new Uri(_slackApiLink + "channels.create");

            using (HttpClient httpClient = new HttpClient())
            {
                var sendModel = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("token", _slackConfigurations.UserToken),
                    new KeyValuePair <string, string>("name", model.Title)
                };
                using (FormUrlEncodedContent content = new FormUrlEncodedContent(sendModel))
                {
                    await httpClient.PostAsync(uri, content);
                }
            }
        }
コード例 #3
0
 public async Task CreateChannelAsync(ChannelOrGroupCreationDto model)
 => throw new NotImplementedException("This method is not supported in Slack");