travis-ci/travis-core — pull request #352 by BanzaiMan (2014-02-13 11:51:04+00:00)
Title: HipChat API V2 support

Using the [Relevant API documentation](https://www.hipchat.com/docs/apiv2/method/send_room_notification), we construct a straightforward HTTP POST request with the V2 API to send notifications.

The API version is automatically detected by the length of the token
provided. According to the support email I received, V1 tokens are 30
characters long. The mail did not specify the length for V2 tokens, but
it seems safe to assume they are 40 characters long.

The following changes in V2 are noted:

1. `Content-Type` header must be set to `application/json`
2. Request will be formed as a JSON string (not with form parameters)
3. Room name or ID will be used in the request path, so it needs to be
encoded properly. Some room names may not be encoded properly. If this
is suspected to be a problem with the notification, inspect
`Travis::Addons::Hipchat::HttpHelper::UNSAFE_URL_CHARS`.
See http://tools.ietf.org/html/rfc1738 for information on URI encoding.