Пример #1
0
 /// <summary>
 /// Creates a webhook
 /// </summary>
 /// <param name="roomName">the name of the room</param>
 /// <param name="url">the url to send the webhook POST to</param>
 /// <param name="pattern">optional regex pattern to match against messages.  Only applicable for message events</param>
 /// <param name="eventType">The event to listen for</param>
 /// <param name="name">label for this webhook</param>
 /// <remarks>
 /// Auth required with scope 'admin_room'. https://www.hipchat.com/docs/apiv2/method/create_webhook
 /// </remarks>
 public CreateWebHookResponse CreateWebHook(string roomName, string url, string pattern, RoomEvent eventType, string name)
 {
     using (JsonSerializerConfigScope())
     {
         var request = new CreateWebHookRequest
         {
             Event   = eventType,
             Pattern = pattern,
             Url     = url,
             Name    = name
         };
         return(CreateWebHook(roomName, request));
     }
 }
Пример #2
0
 /// <summary>
 /// Creates a webhook
 /// </summary>
 /// <param name="roomId">the id of the room</param>
 /// <param name="url">the url to send the webhook POST to</param>
 /// <param name="pattern">optional regex pattern to match against messages.  Only applicable for message events</param>
 /// <param name="eventType">The event to listen for</param>
 /// <param name="name">label for this webhook</param>
 /// <remarks>
 /// Auth required with scope 'admin_room'. https://www.hipchat.com/docs/apiv2/method/create_webhook
 /// </remarks>
 public CreateWebHookResponse CreateWebHook(int roomId, string url, string pattern, RoomEvent eventType, string name)
 {
     using (JsonSerializerConfigScope())
     {
         var request = new CreateWebHookRequest
         {
             Event   = eventType,
             Pattern = pattern,
             Url     = url,
             Name    = name
         };
         return(CreateWebHook(roomId.ToString(CultureInfo.InvariantCulture), request));
     }
 }
Пример #3
0
        /// <summary>
        /// Creates a webhook
        /// </summary>
        /// <param name="roomName">the name of the room</param>
        /// <param name="request">the request to send</param>
        /// <remarks>
        /// Auth required with scope 'admin_room'. https://www.hipchat.com/docs/apiv2/method/create_webhook
        /// </remarks>
        public CreateWebHookResponse CreateWebHook(string roomName, CreateWebHookRequest request)
        {
            using (JsonSerializerConfigScope())
            {
                try
                {
                    return(HipchatEndpoints.CreateWebhookEndpointFormat.Fmt(roomName)
                           .AddHipchatAuthentication()
                           .PostJsonToUrl(request)
                           .FromJson <CreateWebHookResponse>());
                }
                catch (Exception exception)
                {
                    if (exception is WebException)
                    {
                        throw ExceptionHelpers.WebExceptionHelper(exception as WebException, "admin_room");
                    }

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