/// <summary> /// Send a message to a room /// </summary> /// <param name="roomName">The name of the room</param> /// <param name="message">message to send</param> /// <param name="backgroundColor">the background color of the message, only applicable to html format message</param> /// <param name="notify">if the message should notify</param> /// <param name="messageFormat">the format of the message</param> /// <returns>true if the message was sucessfully sent</returns> /// <remarks> /// Auth required with scope 'view_group'. https://www.hipchat.com/docs/apiv2/method/send_room_notification /// </remarks> public bool SendNotification(string roomName, string message, RoomColors backgroundColor = RoomColors.Yellow, bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html) { using (JsonSerializerConfigScope()) { var request = new SendRoomNotificationRequest { Color = backgroundColor, Message = message, MessageFormat = messageFormat, Notify = notify }; return(SendNotification(roomName, request)); } }
public string SendMessage(int roomId, string message, RoomColors backgroundColor = RoomColors.Yellow, bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html) { if (message.IsEmpty()) throw new ArgumentException("Message cannot be blank", "message"); if (message.Length > 10000) throw new ArgumentOutOfRangeException("message", "message length is limited to 10k characters"); var request = new SendMessageRequest { Message = message, Color = backgroundColor.ToString().ToLower(), Notify = notify, Message_Format = messageFormat.ToString().ToLower() }; var json = request.ToJson(); return HipchatEndpoints.SendMessageEndpoint(roomId, _authToken).PostJsonToUrl(request); }
public void PrivateMessageUser(string idOrEmailOrMention, string message, bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Text) { if (idOrEmailOrMention.IsEmpty() || idOrEmailOrMention.Length > 10000) { throw new ArgumentOutOfRangeException("idOrEmailOrMention", "Valid length range: 1 - 10000."); } var endpoint = HipchatEndpoints.PrivateMessageUserEnpointFormat .Fmt(idOrEmailOrMention); var request = new PrivateMessageUserRequest { Message = message, Notify = notify, MessageFormat = messageFormat }; try { using (JsonSerializerConfigScope()) { endpoint .AddHipchatAuthentication(_authToken) .PostJsonToUrl(request); } //We could assert that we get a 204 here and return a boolean success / failure //but i guess we'll just assume everything went well or we would have got an exception } catch (Exception x) { if (x is WebException) { throw ExceptionHelpers.WebExceptionHelper(x as WebException, "send_message"); } throw ExceptionHelpers.GeneralExceptionHelper(x, "PrivateMessageUser"); } }
/// <summary> /// Send a message to a room /// </summary> /// <param name="roomId">The id of the room</param> /// <param name="message">message to send</param> /// <param name="backgroundColor">the background color of the message, only applicable to html format message</param> /// <param name="notify">if the message should notify</param> /// <param name="messageFormat">the format of the message</param> /// <returns>true if the message was sucessfully sent</returns> /// <remarks> /// Auth required with scope 'view_group'. https://www.hipchat.com/docs/apiv2/method/send_room_notification /// </remarks> public bool SendNotification(int roomId, string message, RoomColors backgroundColor = RoomColors.Yellow, bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html) { return(SendNotification(roomId.ToString(CultureInfo.InvariantCulture), message, backgroundColor, notify, messageFormat)); }
public bool SendNotification(string roomName, string message, RoomColors backgroundColor = RoomColors.Yellow, bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html) { using (JsonSerializerConfigScope()) { var request = new SendRoomNotificationRequest { Color = backgroundColor, Message = message, MessageFormat = messageFormat, Notify = notify }; return SendNotification(roomName, request); } }
public bool SendNotification(int roomId, string message, RoomColors backgroundColor = RoomColors.Yellow, bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Html) { return SendNotification(roomId.ToString(CultureInfo.InvariantCulture), message, backgroundColor, notify, messageFormat); }
public void PrivateMessageUser(string idOrEmailOrMention, string message, bool notify = false, HipchatMessageFormat messageFormat = HipchatMessageFormat.Text) { if (idOrEmailOrMention.IsEmpty() || idOrEmailOrMention.Length > 10000) throw new ArgumentOutOfRangeException("idOrEmailOrMention", "Valid length range: 1 - 10000."); var endpoint = HipchatEndpoints.PrivateMessageUserEnpointFormat .Fmt(idOrEmailOrMention); var request = new PrivateMessageUserRequest { Message = message, Notify = notify, MessageFormat = messageFormat }; try { using (JsonSerializerConfigScope()) { endpoint .AddHipchatAuthentication(_authToken) .PostJsonToUrl(request); } //We could assert that we get a 204 here and return a boolean success / failure //but i guess we'll just assume everything went well or we would have got an exception } catch (Exception x) { if (x is WebException) throw ExceptionHelpers.WebExceptionHelper(x as WebException, "send_message"); throw ExceptionHelpers.GeneralExceptionHelper(x, "PrivateMessageUser"); } }