示例#1
0
 /// <summary>
 /// Posts a payload to Slack.
 /// </summary>
 private void PostPayloadAsync(Payload payload)
 {
     var data = JsonSerializeObject(payload);
     PostPayloadAsync(data);
 }
示例#2
0
        /// <summary>
        /// Builds a payload for Slack.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="username"></param>
        /// <param name="channel"></param>
        /// <param name="iconUrl"></param>
        /// <param name="iconEmoji"></param>
        /// <param name="attachments"></param>
        /// <returns></returns>
        private Payload BuildPayload(string text, string username, string channel, string iconUrl, string iconEmoji, List<Attachment> attachments = null)
        {
            username = string.IsNullOrEmpty(username) ? _username : username;
            channel = string.IsNullOrEmpty(channel) ? _channel : channel;
            iconUrl = string.IsNullOrEmpty(channel) ? _iconUrl : iconUrl;
            iconEmoji = string.IsNullOrEmpty(iconEmoji) ? _iconEmoji : iconEmoji;

            var payload = new Payload {
                Channel = channel,
                Username = username,
                IconUrl = iconUrl,
                IconEmoji = iconEmoji,
                Text = text,
                Attachments = attachments
            };

            return payload;
        }