public HipchatCreateRoomResponse CreateRoom(string nameOfRoom, bool guestAccess = false, string ownerUserId = null,
            RoomPrivacy privacy = RoomPrivacy.Public)
        {
            using (JsonSerializerConfigScope())
            {
                var request = new CreateRoomRequest
                {
                    GuestAccess = guestAccess,
                    Name = nameOfRoom,
                    OwnerUserId = ownerUserId,
                    Privacy = privacy
                };

                return CreateRoom(request);
            }
        }
Exemple #2
0
        /// <summary>
        ///  Creates a new room
        /// </summary>
        /// <returns>response containing id and link of the created room</returns>
        /// <remarks>
        /// Auth required with scope 'manage_rooms'. https://api.hipchat.com/v2/room
        /// </remarks>
        public HipchatCreateRoomResponse CreateRoom(CreateRoomRequest request)
        {
            using (JsonSerializerConfigScope())
            {
                if (request.Name.IsEmpty() || request.Name.Length > 50)
                    throw new ArgumentOutOfRangeException("request", "Name of room must be between 1 and 50 characters.");
                try
                {
                    return HipchatEndpoints.CreateRoomEndpoint
                        .AddHipchatAuthentication(_authToken)
                        .PostJsonToUrl(request)
                        .FromJson<HipchatCreateRoomResponse>();
                }
                catch (Exception exception)
                {
                    if (exception is WebException)
                        throw ExceptionHelpers.WebExceptionHelper(exception as WebException, "manage_rooms");

                    throw ExceptionHelpers.GeneralExceptionHelper(exception, "CreateRoom");
                }
            }
        }