Esempio n. 1
0
        public HipchatMessage ComposeMessage()
        {
            var messageBody = $"{ComposeSubject()}\n\n {ComposeContent()}";
            var message     = new HipchatMessage
            {
                Color   = HipchatMessageColor.Red,
                Format  = HipchatMessageFormat.Text,
                Message = messageBody,
                Notify  = true
            };

            return(message);
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> SendNotificationAsync(string room, HipchatMessage message)
        {
            if (string.IsNullOrWhiteSpace(room))
            {
                throw new RoomMissingException("HipchatClient failure: Room name or id is missing.");
            }

            using (var client = new HttpClient())
            {
                var roomUri           = $"https://api.hipchat.com/v2/room/{Uri.EscapeDataString(room)}/notification?auth_token={_authToken}";
                var serializedPayload = JsonConvert.SerializeObject(message);
                var payload           = new StringContent(serializedPayload, Encoding.UTF8, "application/json");
                var response          = await client.PostAsync(roomUri, payload);

                return(response);
            }
        }