Code Monkey home page Code Monkey logo

hipchat-rb's Introduction

HipChat Wrapper

A very basic wrapper for the HipChat HTTP API.

CI Status


Coverage Status

Requirements

  • Ruby 2.0.0 or higher
  • HipChat Account, sign up here!

Installation

Gemfile

gem 'hipchat'

Install

gem install hipchat

Usage

client = HipChat::Client.new(api_token, :api_version => 'v1')
# Set http proxy
client = HipChat::Client.new(api_token, :api_version => 'v1', :http_proxy => 'http://proxy_host:proxy_port')

# 'username' is the name for which the message will be presented as from
client['my room'].send('username', 'I talk')

# Send notifications to users (default false)
client['my room'].send('username', 'I quit!', :notify => true)

# Color it red. or "yellow", "green", "purple", "random" (default "yellow")
client['my room'].send('username', 'Build failed!', :color => 'red')

# Have your message rendered as text in HipChat (see https://www.hipchat.com/docs/api/method/rooms/message)
client['my room'].send('username', '@coworker Build faild!', :message_format => 'text')

# Update the topic of a room in HipChat (see https://www.hipchat.com/docs/api/method/rooms/topic)
client['my room'].topic('Free Ice Cream in the kitchen')

# Change the from field for a topic update (default "API")
client['my room'].topic('Weekely sales: $10,000', :from => 'Sales Team')

# Get history from a room
client['my room'].history()

# Get history for a date in time with a particular timezone (default is latest 75 messages, timezone default is 'UTC')
client['my room'].history(:date => '2010-11-19', :timezone => 'PST')

# Create a new room, V1 requires owner_user_id (see https://www.hipchat.com/docs/api/method/rooms/create)
client.create_room("Name", :owner_user_id => 'user_id')
client = HipChat::Client.new(api_token)
# Set http proxy
client = HipChat::Client.new(api_token, :http_proxy => 'http://proxy_host:proxy_port')

# 'username' is the name for which the message will be presented as from
client['my room'].send('username', 'I talk')

# Send notifications to users (default false)
client['my room'].send('username', 'I quit!', :notify => true)

# Color it red. or "yellow", "green", "purple", "random" (default "yellow")
client['my room'].send('username', 'Build failed!', :color => 'red')

# Have your message rendered as text in HipChat (see https://www.hipchat.com/docs/apiv2/method/send_room_notification)
client['my room'].send('username', '@coworker Build faild!', :message_format => 'text')

# Update the topic of a room in HipChat (see https://www.hipchat.com/docs/apiv2/method/set_topic)
client['my room'].topic('Free Ice Cream in the kitchen')

# Change the from field for a topic update (default "API")
client['my room'].topic('Weekely sales: $10,000', :from => 'Sales Team')

# Get history from a room
client['my room'].history()

# Get history for a date in time with a particular timezone (default is latest 75 messages, timezone default is 'UTC')
client['my room'].history(:date => '2010-11-19', :timezone => 'PST')

# Get statistics from a room
client['my room'].statistics()

# Create a new room (see https://www.hipchat.com/docs/apiv2/method/create_room)
client.create_room("Name", options = {})

# Get room data (see https://www.hipchat.com/docs/apiv2/method/get_room)
client['my room'].get_room

# Update room data (see https://www.hipchat.com/docs/apiv2/method/update_room)
It's recommended to call client['my room'].get_room then pass in modified hash attributes to #update_room
client['my room'].update_room(options = {})

# Delete room (see https://www.hipchat.com/docs/apiv2/method/delete_room)
client['my room'].delete_room

# Invite user to room (see https://www.hipchat.com/docs/apiv2/method/invite_user)
client['my room'].invite("USER_ID_OR_NAME", options = {})

# Sends a user a private message. Valid value for user are user id or email address
client.user('[email protected]').send('I can send private messages')

# Update a user status.  Available options for show are 'away', 'chat', 'dnd', 'xa'
client.user('[email protected]').status('this is my status',
        :name=>'Foo Bar',
        :status=>'Doing very important stuff',
        :show=>'xa',
        :mention_name=>'foo',
        :email=>'[email protected]')

Custom Server URL

client = HipChat::Client.new(api_token, :server_url => 'https://domain.com')
# 'username' is the name for which the message will be presented as from
client['my room'].send('username', 'I talk')

# Send notifications to users (default false)
client['my room'].send('username', 'I quit!', :notify => true)

# Color it red. or "yellow", "green", "purple", "random" (default "yellow")
client['my room'].send('username', 'Build failed!', :color => 'red')

# Have your message rendered as text in HipChat (see https://www.hipchat.com/docs/apiv2/method/send_room_notification)
client['my room'].send('username', '@coworker Build faild!', :message_format => 'text')

# Update the topic of a room in HipChat (see https://www.hipchat.com/docs/apiv2/method/set_topic)
client['my room'].topic('Free Ice Cream in the kitchen')

# Change the from field for a topic update (default "API")
client['my room'].topic('Weekely sales: $10,000', :from => 'Sales Team')

# Get history from a room
client['my room'].history()

# Get history for a date in time with a particular timezone (default is latest 75 messages, timezone default is 'UTC')
client['my room'].history(:date => '2010-11-19', :timezone => 'PST')

# Create a new room (see https://www.hipchat.com/docs/apiv2/method/create_room)
client.create_room("Name", options = {})

# Get room data (see https://www.hipchat.com/docs/apiv2/method/get_room)
client['my room'].get_room

# Update room data (see https://www.hipchat.com/docs/apiv2/method/update_room)
It's easiest to call client['my room'].get_room, parse the json and then pass in modified hash attributes
client['my room'].update_room(options = {})

# Invite user to room (see https://www.hipchat.com/docs/apiv2/method/invite_user)
client['my room'].invite("USER_ID_OR_NAME", options = {})

# Sends a user a private message. Valid value for user are user id or email address
client.user('[email protected]').send('I can send private messages')

Capistrano

Capfile

require 'hipchat/capistrano'

deploy.rb

# Required
set :hipchat_token, "<your token>"
set :hipchat_room_name, "Your room" # If you pass an array such as ["room_a", "room_b"] you can send announcements to multiple rooms.
# Optional
set :hipchat_enabled, true # set to false to prevent any messages from being sent
set :hipchat_announce, false # notify users
set :hipchat_color, 'yellow' #normal message color
set :hipchat_success_color, 'green' #finished deployment message color
set :hipchat_failed_color, 'red' #cancelled deployment message color
set :hipchat_message_format, 'html' # Sets the deployment message format, see https://www.hipchat.com/docs/api/method/rooms/message
set :hipchat_options, {
  :api_version  => "v2" # Set "v2" to send messages with API v2
}

Who did it?

To determine the user that is currently running the deploy, the capistrano tasks will look for the following:

  1. The $HIPCHAT_USER environment variable
  2. The hipchat_human capistrano var.
  3. The git user.name var.
  4. The $USER environment variable.

Commit log notification (only for Capistrano 2)

Send commit log with deploy notification. We currently support git and svn.

set :hipchat_commit_log, true
# Optional
set :hipchat_commit_log_format, ":time :user\n:message\n"
set :hipchat_commit_log_time_format, "%Y/%m/%d %H:%M:%S"
set :hipchat_commit_log_message_format, "^PROJECT-\d+" # extracts ticket number from message

Rails 3 Rake Task

Send a message using a rake task:

rake hipchat:send["hello world"]

or

rake hipchat:send MESSAGE="hello world"

Options like the room, API token, user name and notification flag can be set in YAML.

RAILS_ROOT/config/hipchat.yml:

token: "<your token>"
room: ["Room name(s) or id(s)"] # this is an array
user: "Your name" # Default to `whoami`
notify: true # Defaults to false
api_version: "v2" # optional, defaults to v2
color: "yellow"

Engine Yard

Use a deploy hook to send messages from Engine Yard’s Cloud platform.

RAILS_ROOT/deploy/after_restart.rb:

on_app_master do
  message  = "Deploying revision #{config.active_revision} to #{config.environment_name}"
  message += " (with migrations)" if config.migrate?
  message += "."

  # Send a message via rake task assuming a hipchat.yml in your config like above
  run "cd #{config.release_path} && bundle exec rake hipchat:send MESSAGE='#{message}'"
end

Chef Handler

APIv1 ONLY, use APIv1 Key
NOTE: APIv2 required for HipChat Server & HipChat Data Center

Report on Chef runs.

Within a Recipe:

include_recipe 'chef_handler'

gem_package 'hipchat'

chef_handler 'HipChat::NotifyRoom' do
  action :enable
  arguments ['API_KEY', 'HIPCHAT_ROOM']
  source File.join(Gem.all_load_paths.grep(/hipchat/).first,
                   'hipchat', 'chef.rb')
end

With client.rb:

   require 'hipchat/chef'
   hipchat_handler = HipChat::NotifyRoom.new("API_KEY", "HIPCHAT_ROOM")
   exception_handlers << hipchat_handler

With HipChat Data Center and HipChat Server

Add an “options” hash to set your URL:

  • arguments [‘API_KEY’, ‘HIPCHAT_ROOM’, options={hipchat_options: {server_url: “https://hipchat.example.com”}}]
  • hipchat_handler = HipChat::NotifyRoom.new(“API_KEY”, “HIPCHAT_ROOM”, options={hipchat_options: {server_url: “https://hipchat.example.com”}})

Copyright

Copyright © 2017 Atlassian. See LICENSE for details.

hipchat-rb's People

Contributors

ali-ehmed avatar ampledata avatar artfuldodger avatar avand avatar cmckni3 avatar colszowka avatar david avatar daviddufresne avatar dgolja avatar epaulet avatar flyinbutrs avatar gabrieldeal avatar jfitisoff avatar joraff avatar justintarthur avatar ktdreyer avatar miknight avatar motns avatar mparuszewski avatar mrchucho avatar nogara avatar rberrelleza avatar rldaggie avatar rodrigopinto avatar scalp42 avatar sonyakc avatar tmonk42 avatar tylerdavis avatar yasuoza avatar zsiddique avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hipchat-rb's Issues

undefined method `to_json' for Hash

Hi, I'm trying to integrate HipChat into my Capistrano deployment.

I've followed the instructions on the README, but I get this error:

undefined method `to_json' for #<Hash:0x0000000169b648>

Googling, I found PR #61, which led me to adding a require "json" just before require hipchat/capistrano.

This fixed the issue.

What also fixed the issue was a require "active_support/core_ext".

Tried on Rails 3.2.18 on ruby 1.9.3-p125 and -p551.

Any idea what's going on? Is the information in the README incorrect?

wrong messaging for non-rails apps

Seems to be hard locked to rails env, always produces production when not a rails project. Maybe default to rack_env?

task :notify_deploy_finished do
  hipchat_client[hipchat_room_name].
    send(deploy_user, "#{human} finished deploying #{application} to #{rails_env}.", hipchat_announce)
end

Bump webmock requirement.

Hi,
I am a co-maintainer of hipchat package in Debian. Debian have webmock version 1.22.6 which breaks hipchat (that requires version 1.22.1 exactly). The errors seems to be of incorrect registration of stubs (check below).

Can you bump webmock dependency to support webmock version 1.22.6?

Test fail log
.............................FF...........................................

Failures:

  1) HipChat (API V2) #statistics is successful without custom options
     Failure/Error: expect(room.statistics()).to be_truthy
     WebMock::NetConnectNotAllowedError:
       Real HTTP connections are disabled. Unregistered request: GET https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone= with headers {'Accept'=>'application/json', 'Content-Type'=>'application/json'}

       You can stub this request with the following snippet:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone=").
         with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
         to_return(:status => 200, :body => "", :headers => {})

       registered request stubs:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date&format&room_id=Hipchat&timezone")

       ============================================================
     # ./lib/hipchat/room.rb:269:in `statistics'
     # ./spec/hipchat_api_v2_spec.rb:61:in `block (3 levels) in <top (required)>'

  2) HipChat (API V2) #statistics is successful from fetched room
     Failure/Error: expect(subject.rooms.first.statistics).to be_truthy
     WebMock::NetConnectNotAllowedError:
       Real HTTP connections are disabled. Unregistered request: GET https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone= with headers {'Accept'=>'application/json', 'Content-Type'=>'application/json'}

       You can stub this request with the following snippet:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date=&format=&room_id=Hipchat&timezone=").
         with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
         to_return(:status => 200, :body => "", :headers => {})

       registered request stubs:

       stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/statistics?auth_token=blah&date&format&room_id=Hipchat&timezone")
       stub_request(:get, "https://api.hipchat.com/v2/room?auth_token=blah").
         with(:body => "",
              :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'})

       ============================================================
     # ./lib/hipchat/room.rb:269:in `statistics'
     # ./spec/hipchat_api_v2_spec.rb:69:in `block (3 levels) in <top (required)>'

Finished in 0.26564 seconds (files took 1.85 seconds to load)
74 examples, 2 failures

Failed examples:

rspec ./spec/hipchat_api_v2_spec.rb:58 # HipChat (API V2) #statistics is successful without custom options
rspec ./spec/hipchat_api_v2_spec.rb:64 # HipChat (API V2) #statistics is successful from fetched room

api v2 username doesn't work

Good day, I'd like to know if username cannot be set in api v2

client = HipChat::Client.new(api_tokenv1)
client['my room'].send('stranger', 'I talk')     #user is displayed as stranger
client = HipChat::Client.new(api_tokenv2, :api_version => 'v2')
client['my room'].send('stranger', 'I talk')    #user is always my username

DEPRECATED: Specify notify flag as an option (e.g., :notify => true)

Hi,

Thanks for building this gem, it works great. I have question though. The Capistrano configuration set :hipchat_announce, false is depreciated and it tells me to use :notify => true. I am not sure how to do that in the Capistrano deploy.rb.

set :hipchat_token, "ab...34"
set :hipchat_room_name, "my_app"
set :hipchat_announce,  false <-- how to write this in the new way?

Thanks!

uninitialized constant HTTParty::Parser::Crack

After upgrading to Rails 3.1, I had to explicitly add the Crack parser to my Gemfile (gem 'crack') in order to prevent the error 'uninitialized constant HTTParty::Parser::Crack'. Could be a HTTParty issue.

color should be provided for rake task

While tracking the code at here
if not provide proper color value, then the v2 api will return

UnknownResponseCode: Unexpected 400 for room `room`

The readme not shows this by default.

Should v2 become the new default api version?

Now that all API v1 use is discouraged, I think that v2 should become default and v1 use should be explicitly requested.

client = HipChat::Client.new(api_token) uses API v2
client = HipChat::Client.new(api_token, api_version: 'v1') uses API v1

Happy to do a PR

Rake task ignoring the user property

The rake test (actually the room.send method) is ignoring the user property and instead always using the user associated with the auth token. Is this expected behavior? The server is basically ignoring the user options value and not defaulting to 'whoami' as per the comment in hipchat.yml. We're trying to use one auth token and have the sender by the person executing the script.

When Hipchat is down, deploys are broken.

*** [hipchat:notify_deploy_started] rolling back
 ** [hipchat:notify_deploy_started] exception while rolling back: HipChat::UnknownResponseCode, Unexpected 502 for room `Developers'
/usr/local/rvm/gems/ruby-2.0.0-p0/gems/hipchat-0.10.0/lib/hipchat.rb:95:in `send': Unexpected 502 for room `Developers' (HipChat::UnknownResponseCode)
  from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/hipchat-0.10.0/lib/hipchat/capistrano.rb:66:in `block in send'
  from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/hipchat-0.10.0/lib/hipchat/capistrano.rb:65:in `each'
  from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/hipchat-0.10.0/lib/hipchat/capistrano.rb:65:in `send'
  from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/hipchat-0.10.0/lib/hipchat/capistrano.rb:29:in `block (3 levels) in <top (required)>'
  from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/capistrano-2.15.4/lib/capistrano/configuration/execution.rb:138:in `instance_eval'

Seems like it should catch bad responses, warn about them, and continue.

README suggests room name can be passed

The README seems to indicate that room name can be passed, but it seems that only room id can be passed.

If so, I could provide a PR to fix the docs or maybe allow room name to be passed as well as room id...

Shouldn't the README recommend using room IDs?

Room names are brittle, they can easily be changed without notice whereas room IDs never change. Wouldn't it be better to encourage people to use IDs instead of names since the library seems to be able to handle either?

rubygems out of date

Hi

FYI:

I wanted to use the send_file method (thanks for adding that). I needed to build the gem from source as the rubygems version is out of date. That worked for me but I would prefer to use rubygems.

Capistrano 3 not compatible

With a fresh capistrano 3 rails app

#Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'hipchat/capistrano'
#Gemfile
  gem "capistrano", "~> 3.0"
  gem "capistrano-rails"
  gem "hipchat"
#deploy.rb
set :hipchat_token, "redacted"
set :hipchat_room_name, "redacted"
set :hipchat_announce, false
set :hipchat_color, 'green'
set :hipchat_failed_color, 'red'

console output

$ cap staging deploy
cap aborted!
undefined method `instance' for Capistrano::Configuration:Class
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/gems/hipchat-0.14.0/lib/hipchat/capistrano.rb:3:in `<top (required)>'
/Users/nikoroberts/Work/eventfuel-server/Capfile:25:in `require'
/Users/nikoroberts/Work/eventfuel-server/Capfile:25:in `<top (required)>'
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/gems/capistrano-3.0.1/lib/capistrano/application.rb:22:in `load_rakefile'
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/gems/capistrano-3.0.1/lib/capistrano/application.rb:12:in `run'
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/gems/capistrano-3.0.1/bin/cap:3:in `<top (required)>'
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/bin/cap:23:in `load'
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/bin/cap:23:in `<main>'
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in `eval'
/Users/nikoroberts/.rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in `<main>'

Do not restrict httparty version

Recently #48 pinned httparty version for ruby 1.8.7, which blocks ruby 1.9+ users to use updated version of httparty.

Ruby 1.8.7 was retired a while ago and no longer supported. Let's make people using 1.8.7 to pin hipchat gem version or httparty version by themselves.

See also discussion on aws/aws-sdk-ruby#273

UnknownResponseCode: Unexpected 400 for room `room` when using API v2

When I attempt to use API v2, I get the error: UnknownResponseCode: Unexpected 400 for room 'room'

I change my token to an API v2 access token and instantiate my client with the :api_version option set to 'v2':

HipChat::Client.new(token, :api_version => 'v2' )

Any idea what the issue might be? Do any other changes need to happen when switching to API v2?

Should we raise an error when passing an invalid api version?

I'm a newbie Ruby and today I had a hard time debugging when passing an invalid api version, I pass 2 instead of v2 to HipChat::Client.new and I ended with this error message:

NoMethodError: undefined method `[]' for nil:NilClass
    from /Users/kureikain/.rvm/gems/ruby-2.2.2/gems/hipchat-1.5.1/lib/hipchat/room.rb:21:in `get_room'

Because of this https://github.com/hipchat/hipchat-rb/blob/master/lib/hipchat/api_version.rb#L96

So I think we should raise an exception when passing an invalid api version to prevent any confusion, probably in https://github.com/hipchat/hipchat-rb/blob/master/lib/hipchat/client.rb#L12

client history timezone does not work for 'PST'

Using the command :

client['my-room'].history(:date => (Time.new(2014, 3, 25).strftime("%Y-%m-%d")), :timezone => "EST")

Arguments for :timezone work for "EST" and "GMT", but it does not work for "PST".

Wrong usage of hipchat_announce option

Usage of hipchat_announce option is completely wrong, at least for my understanding. I guess the intention for this option was to use as "notify" option in hipchat API for sending message. Here is description from docs page https://www.hipchat.com/docs/apiv2/method/send_room_notification:

notify  
Whether this message should trigger a user notification (change the tab color, play a sound, notify mobile phones, etc). Each recipient's notification preferences are taken into account.
Defaults to false.

Basically when this option is set to false messages should be still send but hipchat will not notify users about it. Current behaviour is that message won't be set at all which is completely broken.

It was broken by merging pull #126 Please, revert it.

Support for multistage

We're using capistrano multistage to do things like

cap staging deploy

but the notification always says it's deploying to production. I'll take a look at making a pull request for this.

Send private messages

The API allows you to send private messages, see here. But I don't see this or any other user functionality in this project.

Can't post command message

HI, I am trying to change my status and was going to use a command message for that, so I used:

client['myRoom].send('Ingo', '/available Test')

and it posted "/available Test" instead of changing my status. Is this a bug? Is there a better way to change status?

Ingo

"undefined method `[]' for nil:NilClass" in v1.5.0

This was working in v1.4.0, but now breaks with the following error. Somehow @api.send_config is nil:

      response = self.class.post(@api.send_config[:url],

The backtrace:

undefined method `[]' for nil:NilClass
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/hipchat-1.5.0/lib/hipchat/room.rb:122:in `send'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/hipchat-1.5.0/lib/hipchat/capistrano/tasks/hipchat.rake:46:in `block in send_message'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/hipchat-1.5.0/lib/hipchat/capistrano/tasks/hipchat.rake:44:in `each'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/hipchat-1.5.0/lib/hipchat/capistrano/tasks/hipchat.rake:44:in `send_message'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/hipchat-1.5.0/lib/hipchat/capistrano/tasks/hipchat.rake:11:in `block (2 levels) in <top (required)>'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
~/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/capistrano-3.4.0/lib/capistrano/dsl/task_enhancements.rb:14:in `block in after'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
~/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/capistrano-3.4.0/lib/capistrano/dsl.rb:16:in `invoke'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/capistrano-3.4.0/lib/capistrano/tasks/framework.rake:65:in `block (2 levels) in <top (required)>'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/capistrano-3.4.0/lib/capistrano/tasks/framework.rake:64:in `each'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/capistrano-3.4.0/lib/capistrano/tasks/framework.rake:64:in `block in <top (required)>'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
~/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in `run'
~/.rvm/gems/ruby-2.1.2@my_gemset/gems/capistrano-3.4.0/bin/cap:3:in `<top (required)>'
~/.rvm/gems/ruby-2.1.2@my_gemset/bin/cap:23:in `load'
~/.rvm/gems/ruby-2.1.2@my_gemset/bin/cap:23:in `<main>'
~/.rvm/gems/ruby-2.1.2@my_gemset/bin/ruby_executable_hooks:15:in `eval'
~/.rvm/gems/ruby-2.1.2@my_gemset/bin/ruby_executable_hooks:15:in `<main>'

push v1.5.2 tag to github

When you tag releases, would you mind pushing the tags to GitHub? For example the latest version on Rubygems.org is 1.5.2, but the v1.5.2 tag is missing from the repository.

the scheme http does not accept registry part: :80 (or bad hostname?)

I just wanna tried out the gem and faced this problem

require 'hipchat'

api_token = 'mytokenhere' 

client = HipChat::Client.new(api_token, :api_version => 'v2')

r = client.rooms.first # this line is working fine

r.history

and this is what I got

/Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/generic.rb:214:in `initialize': the scheme http does not accept registry part: :80 (or bad hostname?) (URI::InvalidURIError)
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/http.rb:84:in `initialize'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/common.rb:214:in `new'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/common.rb:214:in `parse'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/common.rb:747:in `parse'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/common.rb:1232:in `URI'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1029:in `proxy_uri'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1016:in `proxy?'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:869:in `connect'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:852:in `start'
    from /Users/ream/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1369:in `request'
    from /Users/ream/.rvm/gems/ruby-2.1.1/gems/httparty-0.13.1/lib/httparty/request.rb:93:in `perform'
    from /Users/ream/.rvm/gems/ruby-2.1.1/gems/httparty-0.13.1/lib/httparty.rb:521:in `perform_request'
    from /Users/ream/.rvm/gems/ruby-2.1.1/gems/httparty-0.13.1/lib/httparty.rb:457:in `get'
    from /Users/ream/.rvm/gems/ruby-2.1.1/gems/hipchat-1.2.0/lib/hipchat/room.rb:169:in `history'
    from run.rb:11:in `<main>'

Any quick fix to this? Just wanna tried out only.

HipChat status api endpoint?

Hello!

Can't wait to try out the v2 api!

Would it be possible to include a method for pulling down the current system status reported on http://status.hipchat.com/ ?

We have a vendor/dependency dashboard that shows statuses of API states (Github, PagerDuty, RubyGems, etc..) and would love to see a current status for the HipChat API since we depend on it for lots of notifications.

Thank you!
Chris

Create user?

Am I missing something here, or is there really no way to create new users via this lib? I'm going to take a crack at building the functionality and see where I end up, unless, of course someone corrects me on this.

Chef Usage

There's no Chef Handler usage instructions in the README.

Consider not overwriting the Object#send method.

https://github.com/hipchat/hipchat-rb/blob/master/lib/hipchat.rb#L76
https://github.com/hipchat/hipchat-rb/blob/master/lib/hipchat/capistrano.rb#L54

This isn't technically a bug, as hipchat-rb works great, but you might consider not overwriting http://ruby-doc.org/core-2.0.0/Object.html#method-i-send in HipChat::Room and in the capistrano recipe.

Here's a failing test, if that helps:

gems/hipchat-0.10.0> cat spec/new_spec.rb 
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe HipChat do
  subject { HipChat::Client.new('blah') }

  let(:room) { subject['Hipchat'] }
  it 'doesnt overwrite ruby core methods' do
    #$stderr.puts(:hi, room.send(:inspect));
    room.__send__(:inspect).should == room.send(:inspect)
  end
end
gems/hipchat-0.10.0> rspec spec/new_spec.rb 
F

Failures:

  1) HipChat doesnt overwrite ruby core methods
     Failure/Error: room.__send__(:inspect).should == room.send(:inspect)
     ArgumentError:
       wrong number of arguments (1 for 2)
     # ./lib/hipchat.rb:63:in `send'
     # ./spec/new_spec.rb:8:in `block (2 levels) in <top (required)>'

Finished in 0.00043 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/new_spec.rb:6 # HipChat doesnt overwrite ruby core methods

JSON dependency issue between Chef and HTTParty

Hi -

Chef 11.8.x has its JSON dependency locked to <= 1.7.7, >= 1.4.4.

Hipchat loads httparty 0.12 by default which has its own JSON dependency locked to ~>1.8.

Because of this when I try to integrate Hipchat into my Chef recipes I'm getting the following exception:

Gem::LoadError

artifact_deploy[entitlements-service](/tmp/vagrant-chef-1/chef-solo-1/cookbooks/play/providers/app.rb line 81) had an error: Gem::LoadError: ruby_block[notify-hipchat](/tmp/vagrant-chef-1/chef-solo-1/cookbooks/entitlements-service/recipes/default.rb line 100) had an error: Gem::LoadError: Unable to activate httparty-0.12.0, because json-1.7.7 conflicts with json (~> 1.8)

Has anybody solved this problem and successfully integrated Hipchat with Chef 11.8.x?

Personal tokens no longer work. Need "Room" token

HipChat::Unauthorized: Access denied to room {room name}

Something must have changed very recently, but it seems that you can no longer send messages to a room via personal v2 token. You have to generate a "room" level token.

The API situation with Hipchat is VERY confusing. The right place to generate this new token is under Group Admin -> Rooms -> {Your Room} -> Tokens

The url should look something like this:
https://{company}.hipchat.com/admin/rooms/tokens/{room id}

Crack::ParseError: Invalid JSON string


client =  HipChat::Client.new('token')
client.rooms
Crack::ParseError: Invalid JSON string
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/crack-0.1.8/lib/crack/json.rb:14:in `parse'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/parser.rb:116:in `json'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/parser.rb:136:in `send'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/parser.rb:136:in `parse_supported_format'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/parser.rb:103:in `parse'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/parser.rb:66:in `call'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/request.rb:217:in `parse_response'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/request.rb:189:in `handle_response'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty/request.rb:71:in `perform'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty.rb:394:in `perform_request'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/httparty-0.7.4/lib/httparty.rb:346:in `get'
    from /Users/sb/.rvm/gems/ruby-1.8.7-p334@plumdistrict/gems/hipchat-0.2.0/lib/hipchat.rb:16:in `rooms'
    from (irb):4

Unexpected 504 for room

Anyone seen this before?

Error: #<HipChat::UnknownResponseCode: Unexpected 504 for room `Playlist Builder'>"]
/Volumes/Storage/martincleaver/.chefdk/gem/ruby/2.1.0/gems/hipchat-1.5.2/lib/hipchat/room.rb:142:in `send': Unexpected 504 for room `Playlist Builder' (HipChat::UnknownResponseCode)

504 doesn't even appear in https://www.hipchat.com/docs/apiv2/response_codes or https://www.hipchat.com/docs/api/response_codes

I suppose I'll just have to catch such exceptions. Weird.

.history should get all history?

I am confused a bit by your documentation regarding the history method. Since it is stated as simply just getting history, should that not return all history? Apparently it only gets some form of recent history at the moment.

How would you get all history? Does one have to iterate through all dates from some point in time forward or can some range be defined?

HTTParty 0.13.4 breaks hipchat-rb 1.5.1

Just attempted to integrate hipchat into rails project and got the following error:

NameError: uninitialized constant HTTParty::HashConversions::ERB
from /usr/local/var/rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:33:in `normalize_param'

and it's related to this issue: jnunemaker/httparty#398

Looks like you'll need to tie the gem to a version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.