コード例 #1
0
        public void CanGetRoomByName()
        {
            var result = _client.GetRoom(_existingRoomName);

            Assert.NotNull(result);
            Assert.NotNull(result.XmppJid);
            Assert.NotNull(result.Links);
            Assert.NotNull(result.Name);
            Assert.NotNull(result.Created);
            Assert.NotNull(result.Topic);
            Assert.NotEqual(0, result.Id);
            Assert.NotNull(result.Owner);
        }
コード例 #2
0
        public static void SendToRoom(string message, string roomname, string token)
        {
            try
            {
                HipchatClient          client = new HipchatClient(token);
                HipchatGetRoomResponse room   = client.GetRoom(roomname);

                if (room != null)
                {
                    if (message.Contains("KILL"))
                    {
                        client.SendNotification(room.Id, message, RoomColors.Green, true, HipchatMessageFormat.Text);
                    }
                    else if (message.Contains("LOSS"))
                    {
                        client.SendNotification(room.Id, message, RoomColors.Red, true, HipchatMessageFormat.Text);
                    }
                    else
                    {
                        client.SendNotification(room.Id, message, RoomColors.Random, true, HipchatMessageFormat.Text);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #3
0
        public UpdateRoomTests()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();
            var room = _client.CreateRoom("TestUpdateRoom");

            _createdRoomId = room.Id;

            var getRoomResponse = _client.GetRoom(_createdRoomId);

            _owner = getRoomResponse.Owner;
        }
コード例 #4
0
 public static int GetARoomId(HipchatClient client, string roomName)
 {
     try
     {
         var room = client.GetRoom(roomName);
         return(room.Id);
     }
     catch (HipchatRoomNotFoundException)
     {
         var room = client.CreateRoom(roomName);
         return(room.Id);
     }
 }
コード例 #5
0
        public GetAllWebhooksTests()
        {
            HipchatApiConfig.AuthToken = TestsConfig.AuthToken;
            _client = new HipchatClient();


            try
            {
                var existingRoom = _client.GetRoom("Test Webhooks Room");
                _existingRoomId = existingRoom.Id;
            }
            catch (Exception)
            {
                var room = _client.CreateRoom("Test Webhooks Room");
                _existingRoomId = room.Id;
            }
        }
コード例 #6
0
        private bool SendHipchatNotification(string body)
        {
            var client = new HipchatClient(_configuration.ApiKey);

            var existingRoomId = client.GetRoom(_configuration.RoomName);

            var roomColor = (RoomColors)Enum.Parse(typeof(RoomColors), _configuration.NotificationColor, true);

            var sendMessageResult = client.SendNotification(existingRoomId.Id, body, roomColor, true, HipchatMessageFormat.Text);

            if (!sendMessageResult)
            {
                throw new ApplicationException(string.Format("Could not send notification to room {0}", _configuration.RoomName));
            }

            return(true);
        }
コード例 #7
0
ファイル: GetRoomTests.cs プロジェクト: tyllyn/Hipchat-CS
 public void GetRoomThrowsException()
 {
     Assert.Throws <HipchatRoomNotFoundException>(() => _client.GetRoom("this room doesn't exist"));
 }