hipchat-api 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rspec +2 -1
- data/.rvmrc +1 -0
- data/.travis.yml +7 -1
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -18
- data/LICENSE.txt +1 -1
- data/README.md +14 -20
- data/Rakefile +2 -41
- data/hipchat-api.gemspec +22 -68
- data/lib/hipchat-api.rb +101 -17
- data/lib/hipchat-api/version.rb +5 -0
- data/spec/hipchat-api_spec.rb +6 -6
- data/spec/spec_helper.rb +1 -4
- metadata +109 -75
- data/CHANGLOG.markdown +0 -11
- data/VERSION +0 -1
data/.gitignore
ADDED
data/.rspec
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
--
|
1
|
+
--colour
|
2
|
+
--format doc
|
data/.rvmrc
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# 1.0.3 (2012-07-13)
|
2
|
+
|
3
|
+
* Add support to the new message_format param when publishing messages to a room. Thanks @rtopitt.
|
4
|
+
|
5
|
+
# 1.0.2 (2011-09-09)
|
6
|
+
|
7
|
+
* Added missing HipChat API methods: `rooms_create`, `rooms_delete`
|
8
|
+
|
9
|
+
# 1.0.1 (2011-05-09)
|
10
|
+
|
11
|
+
* Set the default HIPCHAT_API_URL to use https
|
12
|
+
|
13
|
+
# 1.0.0 (2011-05-07)
|
14
|
+
|
15
|
+
* Initial release
|
data/Gemfile
CHANGED
@@ -1,20 +1,3 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
2
|
|
6
|
-
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
group :development do
|
9
|
-
gem "rspec", "~> 2.6.0"
|
10
|
-
gem "bundler", "~> 1.0.0"
|
11
|
-
gem "jeweler", "~> 1.6.0"
|
12
|
-
gem "rcov", ">= 0"
|
13
|
-
end
|
14
|
-
|
15
|
-
group :test do
|
16
|
-
gem 'mocha'
|
17
|
-
gem 'fakeweb'
|
18
|
-
end
|
19
|
-
|
20
|
-
gem 'httparty'
|
3
|
+
gemspec
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
hipchat-api
|
2
|
-
===========
|
1
|
+
# hipchat-api
|
3
2
|
|
4
3
|
[![Project Status](http://stillmaintained.com/czarneckid/hipchat-api.png)](http://stillmaintained.com/czarneckid/hipchat-api) [![Build Status](http://travis-ci.org/czarneckid/hipchat-api.png)](http://travis-ci.org/czarneckid/hipchat-api)
|
5
4
|
|
@@ -7,33 +6,30 @@ Ruby gem for interacting with HipChat API
|
|
7
6
|
|
8
7
|
* https://www.hipchat.com/docs/api
|
9
8
|
|
10
|
-
Compatibility
|
11
|
-
-------------
|
9
|
+
## Compatibility
|
12
10
|
|
13
11
|
hipchat-API has been tested under Ruby 1.8.7 and Ruby 1.9.2
|
14
12
|
|
15
|
-
Requirements
|
16
|
-
------------
|
13
|
+
## Requirements
|
17
14
|
|
18
15
|
* HTTParty
|
19
16
|
|
20
|
-
Install
|
21
|
-
-------
|
17
|
+
## Install
|
22
18
|
|
23
|
-
|
19
|
+
```
|
20
|
+
gem install hipchat-api
|
21
|
+
```
|
24
22
|
|
25
|
-
Example
|
26
|
-
-------
|
23
|
+
## Example
|
27
24
|
|
28
25
|
```ruby
|
29
|
-
|
26
|
+
require 'hipchat-api'
|
30
27
|
=> true
|
31
|
-
|
28
|
+
hipchat_api = HipChat::API.new('api_token')
|
32
29
|
=> #<HipChat::API:0x000001013d7280 @token="api_token", @hipchat_api_url="https://api.hipchat.com/v1">
|
33
30
|
```
|
34
31
|
|
35
|
-
API methods
|
36
|
-
-----------
|
32
|
+
## API methods
|
37
33
|
|
38
34
|
* Room-related methods
|
39
35
|
|
@@ -56,8 +52,7 @@ users_show(user_id)
|
|
56
52
|
users_update(user_id, email = nil, name = nil, title = nil, is_group_admin = nil, password = nil, timezone = nil)
|
57
53
|
```
|
58
54
|
|
59
|
-
Contributing to hipchat-api
|
60
|
-
---------------------------
|
55
|
+
## Contributing to hipchat-api
|
61
56
|
|
62
57
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
63
58
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
@@ -67,7 +62,6 @@ Contributing to hipchat-api
|
|
67
62
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
68
63
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
69
64
|
|
70
|
-
Copyright
|
71
|
-
---------
|
65
|
+
## Copyright
|
72
66
|
|
73
|
-
Copyright (c) 2011 David Czarnecki. See LICENSE.txt for further details.
|
67
|
+
Copyright (c) 2011-2012 David Czarnecki. See LICENSE.txt for further details.
|
data/Rakefile
CHANGED
@@ -1,29 +1,5 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
1
|
require 'bundler'
|
5
|
-
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "hipchat-api"
|
18
|
-
gem.homepage = "http://github.com/czarneckid/hipchat-api"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Ruby gem for interacting with HipChat}
|
21
|
-
gem.description = %Q{Ruby gem for interacting with HipChat}
|
22
|
-
gem.email = "czarneckid@acm.org"
|
23
|
-
gem.authors = ["David Czarnecki"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
2
|
+
Bundler::GemHelper.install_tasks
|
27
3
|
|
28
4
|
require 'rspec/core'
|
29
5
|
require 'rspec/core/rake_task'
|
@@ -33,26 +9,11 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
33
9
|
# spec.ruby_opts = ['-w']
|
34
10
|
end
|
35
11
|
|
36
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
37
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
38
|
-
spec.rcov = true
|
39
|
-
end
|
40
|
-
|
41
12
|
task :default => :spec
|
42
13
|
|
43
|
-
require 'rake/rdoctask'
|
44
|
-
Rake::RDocTask.new do |rdoc|
|
45
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
-
|
47
|
-
rdoc.rdoc_dir = 'rdoc'
|
48
|
-
rdoc.title = "hipchat-api #{version}"
|
49
|
-
rdoc.rdoc_files.include('README*')
|
50
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
-
end
|
52
|
-
|
53
14
|
namespace :spec do
|
54
15
|
desc "Runs specs on Ruby 1.8.7 and 1.9.2"
|
55
16
|
task :rubies do
|
56
|
-
system "rvm 1.8.7@hipchat-api_gem,1.9.2@hipchat-api_gem rake"
|
17
|
+
system "rvm 1.8.7@hipchat-api_gem,1.9.2@hipchat-api_gem,1.9.3@hipchat-api_gem do rake"
|
57
18
|
end
|
58
19
|
end
|
data/hipchat-api.gemspec
CHANGED
@@ -1,76 +1,30 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
5
3
|
|
6
|
-
|
7
|
-
s.name = %q{hipchat-api}
|
8
|
-
s.version = "1.0.2"
|
4
|
+
require 'hipchat-api/version'
|
9
5
|
|
10
|
-
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "hipchat-api"
|
8
|
+
s.version = HipChat::API::VERSION.dup
|
9
|
+
s.authors = ["David Czarnecki"]
|
10
|
+
s.email = ["czarneckid@acm.org"]
|
11
|
+
s.homepage = "http://github.com/czarneckid/hipchat-api"
|
12
|
+
s.summary = %q{Ruby gem for interacting with HipChat}
|
13
13
|
s.description = %q{Ruby gem for interacting with HipChat}
|
14
|
-
s.email = %q{czarneckid@acm.org}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
".rvmrc",
|
23
|
-
".travis.yml",
|
24
|
-
"CHANGLOG.markdown",
|
25
|
-
"Gemfile",
|
26
|
-
"LICENSE.txt",
|
27
|
-
"README.md",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"hipchat-api.gemspec",
|
31
|
-
"lib/hipchat-api.rb",
|
32
|
-
"spec/fakeweb/rooms_create_response.json",
|
33
|
-
"spec/fakeweb/rooms_delete_response.json",
|
34
|
-
"spec/fakeweb/rooms_history_response.json",
|
35
|
-
"spec/fakeweb/rooms_list_response.json",
|
36
|
-
"spec/fakeweb/rooms_message_response.json",
|
37
|
-
"spec/fakeweb/rooms_show_response.json",
|
38
|
-
"spec/fakeweb/users_create_response.json",
|
39
|
-
"spec/fakeweb/users_delete_response.json",
|
40
|
-
"spec/fakeweb/users_list_response.json",
|
41
|
-
"spec/fakeweb/users_show_response.json",
|
42
|
-
"spec/fakeweb/users_update_response.json",
|
43
|
-
"spec/hipchat-api_spec.rb",
|
44
|
-
"spec/spec_helper.rb"
|
45
|
-
]
|
46
|
-
s.homepage = %q{http://github.com/czarneckid/hipchat-api}
|
47
|
-
s.licenses = [%q{MIT}]
|
48
|
-
s.require_paths = [%q{lib}]
|
49
|
-
s.rubygems_version = %q{1.8.8}
|
50
|
-
s.summary = %q{Ruby gem for interacting with HipChat}
|
51
14
|
|
52
|
-
|
53
|
-
s.specification_version = 3
|
15
|
+
s.rubyforge_project = "hipchat-api"
|
54
16
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
67
|
-
end
|
68
|
-
else
|
69
|
-
s.add_dependency(%q<httparty>, [">= 0"])
|
70
|
-
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
71
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
72
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
|
73
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
74
|
-
end
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency('httparty')
|
23
|
+
|
24
|
+
s.add_development_dependency('fakeweb')
|
25
|
+
s.add_development_dependency('mocha')
|
26
|
+
s.add_development_dependency('rspec', '~> 2.7.0')
|
27
|
+
s.add_development_dependency('rake')
|
75
28
|
end
|
76
29
|
|
30
|
+
|
data/lib/hipchat-api.rb
CHANGED
@@ -1,98 +1,177 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'hipchat-api/version'
|
2
3
|
|
3
4
|
module HipChat
|
4
5
|
class API
|
5
6
|
include HTTParty
|
6
7
|
|
7
|
-
|
8
|
+
# Default timeout of 3 seconds
|
8
9
|
DEFAULT_TIMEOUT = 3
|
9
10
|
|
11
|
+
# Default headers for HTTP requests
|
10
12
|
DEFAULT_HEADERS = {
|
11
13
|
'User-Agent' => "HipChat gem #{VERSION}",
|
12
14
|
}
|
13
15
|
|
16
|
+
# HipChat API URL
|
17
|
+
HIPCHAT_API_URL = 'https://api.hipchat.com/v1'
|
18
|
+
|
14
19
|
headers(DEFAULT_HEADERS)
|
15
20
|
default_timeout(DEFAULT_TIMEOUT)
|
16
21
|
format(:json)
|
17
22
|
|
18
|
-
|
19
|
-
|
23
|
+
# HipChat API URL
|
20
24
|
attr_accessor :hipchat_api_url
|
25
|
+
|
26
|
+
# HipChat access token
|
21
27
|
attr_accessor :token
|
22
28
|
|
29
|
+
# Create a new instance of the +HipChat::API+ for interacting with HipChat
|
30
|
+
#
|
31
|
+
# @param token [String] HipChat access token
|
32
|
+
# @param hipchat_api_url [String] HipChat API URL
|
23
33
|
def initialize(token, hipchat_api_url = HIPCHAT_API_URL)
|
24
34
|
@token = token
|
25
35
|
@hipchat_api_url = hipchat_api_url
|
26
36
|
end
|
27
37
|
|
38
|
+
# Turn on HTTParty debugging
|
39
|
+
#
|
40
|
+
# @param location [Object] Output "sink" for HTTP debugging
|
28
41
|
def debug(location = $stderr)
|
29
42
|
self.class.debug_output(location)
|
30
43
|
end
|
31
44
|
|
45
|
+
# Set new HTTP headers for requests
|
46
|
+
#
|
47
|
+
# @param http_headers [Hash] HTTP headers
|
32
48
|
def set_http_headers(http_headers = {})
|
33
49
|
http_headers.merge!(DEFAULT_HEADERS)
|
34
50
|
self.class.headers(http_headers)
|
35
51
|
end
|
36
52
|
|
53
|
+
# Set new HTTP timeout for requests
|
54
|
+
#
|
55
|
+
# @param timeout [int] Timeout in seconds
|
37
56
|
def set_timeout(timeout)
|
38
57
|
self.class.default_timeout(timeout)
|
39
58
|
end
|
40
59
|
|
41
|
-
#
|
60
|
+
# Creates a new room.
|
61
|
+
#
|
62
|
+
# @param name [String] Name of the room.
|
63
|
+
# @param owner_user_id [int] User ID of the room's owner.
|
64
|
+
# @param privacy [String, 'public'] Privacy setting for room.
|
65
|
+
# @param topic [String, ''] Room topic.
|
66
|
+
# @param guest_access [int, 0] Whether or not to enable guest access for this room. 0 = false, 1 = true. (default: 0).
|
67
|
+
#
|
68
|
+
# @see https://www.hipchat.com/docs/api/method/rooms/create
|
42
69
|
def rooms_create(name, owner_user_id, privacy = 'public', topic = '', guest_access = 0)
|
43
70
|
self.class.post(hipchat_api_url_for('rooms/create'), :body => {:auth_token => @token, :name => name, :owner_user_id => owner_user_id,
|
44
71
|
:topic => topic, :privacy => privacy, :guest_access => guest_access})
|
45
72
|
end
|
46
73
|
|
47
|
-
#
|
74
|
+
# Deletes a room and kicks the current participants.
|
75
|
+
#
|
76
|
+
# @param room_id [int] ID of the room
|
77
|
+
#
|
78
|
+
# @see https://www.hipchat.com/docs/api/method/rooms/delete
|
48
79
|
def rooms_delete(room_id)
|
49
80
|
self.class.post(hipchat_api_url_for('rooms/delete'), :body => {:auth_token => @token, :room_id => room_id})
|
50
81
|
end
|
51
82
|
|
52
|
-
#
|
83
|
+
# Fetch chat history for this room.
|
84
|
+
#
|
85
|
+
# @param room_id [int] ID of the room.
|
86
|
+
# @param date [String] Either the date to fetch history for in YYYY-MM-DD format, or "recent" to fetch the latest 50 messages.
|
87
|
+
# @param timezone [String] Your timezone. Must be a supported PHP timezone. (default: UTC)
|
88
|
+
#
|
89
|
+
# @see https://www.hipchat.com/docs/api/method/rooms/history
|
53
90
|
def rooms_history(room_id, date, timezone)
|
54
91
|
self.class.get(hipchat_api_url_for('rooms/history'), :query => {:auth_token => @token, :room_id => room_id, :date => date,
|
55
92
|
:timezone => timezone})
|
56
93
|
end
|
57
94
|
|
58
|
-
#
|
95
|
+
# List rooms for this group.
|
96
|
+
#
|
97
|
+
# @see https://www.hipchat.com/docs/api/method/rooms/list
|
59
98
|
def rooms_list
|
60
99
|
self.class.get(hipchat_api_url_for('rooms/list'), :query => {:auth_token => @token})
|
61
100
|
end
|
62
101
|
|
63
|
-
#
|
64
|
-
|
102
|
+
# Send a message to a room.
|
103
|
+
#
|
104
|
+
# @param room_id [int] ID of the room.
|
105
|
+
# @param from [String] Name the message will appear be sent from. Must be less than 15 characters long. May contain letters, numbers, -, _, and spaces.
|
106
|
+
# @param message [String] The message body. Must be valid XHTML. HTML entities must be escaped (e.g.: & instead of &). May contain basic tags: a, b, i, strong, em, br, img, pre, code. 5000 characters max.
|
107
|
+
# @param notify [int] Boolean flag of whether or not this message should trigger a notification for people in the room (based on their individual notification preferences). 0 = false, 1 = true. (default: 0)
|
108
|
+
# @param color [String] Background color for message. One of "yellow", "red", "green", "purple", or "random". (default: yellow)
|
109
|
+
# @param message_format [String] Determines how the message is treated by HipChat's server and rendered inside HipChat applications. One of "html" or "text". (default: html)
|
110
|
+
# @see https://www.hipchat.com/docs/api/method/rooms/message
|
111
|
+
def rooms_message(room_id, from, message, notify = 0, color = 'yellow', message_format = 'html')
|
65
112
|
self.class.post(hipchat_api_url_for('rooms/message'), :body => {:auth_token => @token, :room_id => room_id, :from => from,
|
66
|
-
:message => message, :notify => notify, :color => color})
|
113
|
+
:message => message, :notify => notify, :color => color, :message_format => message_format})
|
67
114
|
end
|
68
115
|
|
69
|
-
#
|
116
|
+
# Get room details.
|
117
|
+
#
|
118
|
+
# @param room_id [int] ID of the room.
|
119
|
+
#
|
120
|
+
# @see https://www.hipchat.com/docs/api/method/rooms/show
|
70
121
|
def rooms_show(room_id)
|
71
122
|
self.class.get(hipchat_api_url_for('rooms/show'), :query => {:auth_token => @token, :room_id => room_id})
|
72
123
|
end
|
73
|
-
|
74
|
-
#
|
124
|
+
|
125
|
+
# Create a new user in your group.
|
126
|
+
#
|
127
|
+
# @param email [String] User's email.
|
128
|
+
# @param name [String] User's full name.
|
129
|
+
# @param title [String] User's title.
|
130
|
+
# @param is_group_admin [int] Whether or not this user is an admin. 0 = false, 1 = true. (default: 0)
|
131
|
+
# @param password [String, nil] User's password. If not provided, a randomly generated password will be returned.
|
132
|
+
# @param timezone [String, 'UTC'] User's timezone. Must be a PHP supported timezone. (default: UTC)
|
133
|
+
#
|
134
|
+
# @see https://www.hipchat.com/docs/api/method/users/create
|
75
135
|
def users_create(email, name, title, is_group_admin = 0, password = nil, timezone = 'UTC')
|
76
136
|
self.class.post(hipchat_api_url_for('users/create'), :body => {:auth_token => @token, :email => email, :name => name, :title => title,
|
77
137
|
:is_group_admin => is_group_admin, :password => password, :timezone => timezone}.reject!{|key, value| value.nil?})
|
78
138
|
end
|
79
139
|
|
80
|
-
#
|
140
|
+
# Delete a user.
|
141
|
+
#
|
142
|
+
# @param user_id [String] ID or email address of the user.
|
143
|
+
#
|
144
|
+
# @see https://www.hipchat.com/docs/api/method/users/delete
|
81
145
|
def users_delete(user_id)
|
82
146
|
self.class.post(hipchat_api_url_for('users/delete'), :body => {:auth_token => @token, :user_id => user_id})
|
83
147
|
end
|
84
148
|
|
85
|
-
#
|
149
|
+
# List all users in the group.
|
150
|
+
#
|
151
|
+
# @see https://www.hipchat.com/docs/api/method/users/list
|
86
152
|
def users_list
|
87
153
|
self.class.get(hipchat_api_url_for('users/list'), :query => {:auth_token => @token})
|
88
154
|
end
|
89
155
|
|
90
|
-
#
|
156
|
+
# Get a user's details.
|
157
|
+
#
|
158
|
+
# @param user_id [String] ID or email address of the user.
|
159
|
+
#
|
160
|
+
# @see https://www.hipchat.com/docs/api/method/users/show
|
91
161
|
def users_show(user_id)
|
92
162
|
self.class.get(hipchat_api_url_for('users/show'), :query => {:auth_token => @token, :user_id => user_id})
|
93
163
|
end
|
94
164
|
|
95
|
-
#
|
165
|
+
# Update a user.
|
166
|
+
#
|
167
|
+
# @param email [String] User's email.
|
168
|
+
# @param name [String] User's full name.
|
169
|
+
# @param title [String] User's title.
|
170
|
+
# @param is_group_admin [int] Whether or not this user is an admin. 0 = false, 1 = true. (default: 0)
|
171
|
+
# @param password [String, nil] User's password.
|
172
|
+
# @param timezone [String, nil] User's timezone. Must be a PHP supported timezone. (default: UTC)
|
173
|
+
#
|
174
|
+
# @see https://www.hipchat.com/docs/api/method/users/update
|
96
175
|
def users_update(user_id, email = nil, name = nil, title = nil, is_group_admin = nil, password = nil, timezone = nil)
|
97
176
|
self.class.post(hipchat_api_url_for('users/update'), :body => {:auth_token => @token, :user_id => user_id, :email => email,
|
98
177
|
:name => name, :title => title, :is_group_admin => is_group_admin, :password => password, :timezone => timezone}.reject!{|key, value| value.nil?})
|
@@ -100,6 +179,11 @@ module HipChat
|
|
100
179
|
|
101
180
|
private
|
102
181
|
|
182
|
+
# Create a URL appropriate for accessing the HipChat API with a given API method.
|
183
|
+
#
|
184
|
+
# @param method [String] HipChat API method
|
185
|
+
#
|
186
|
+
# @return URL appropriate for accessing the HipChat API with a given API method.
|
103
187
|
def hipchat_api_url_for(method)
|
104
188
|
"#{@hipchat_api_url}/#{method}"
|
105
189
|
end
|
data/spec/hipchat-api_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'fakeweb'
|
3
3
|
|
4
4
|
describe "HipChat::API" do
|
@@ -7,9 +7,13 @@ describe "HipChat::API" do
|
|
7
7
|
FakeWeb.clean_registry
|
8
8
|
@hipchat_api = HipChat::API.new('token')
|
9
9
|
end
|
10
|
+
|
11
|
+
after(:each) do
|
12
|
+
FakeWeb.allow_net_connect = true
|
13
|
+
end
|
10
14
|
|
11
15
|
it "should be the correct version" do
|
12
|
-
HipChat::API::VERSION.should == '1.0.
|
16
|
+
HipChat::API::VERSION.should == '1.0.3'
|
13
17
|
end
|
14
18
|
|
15
19
|
it "should create a new instance with the correct parameters" do
|
@@ -150,8 +154,4 @@ describe "HipChat::API" do
|
|
150
154
|
users_update_response.should_not be nil
|
151
155
|
users_update_response['user']['email'].should == 'new-email-address@hipchat.com'
|
152
156
|
end
|
153
|
-
|
154
|
-
after(:each) do
|
155
|
-
FakeWeb.allow_net_connect = true
|
156
|
-
end
|
157
157
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
1
|
require 'rspec'
|
4
2
|
require 'hipchat-api'
|
5
3
|
require 'mocha'
|
@@ -8,6 +6,5 @@ require 'mocha'
|
|
8
6
|
# in ./support/ and its subdirectories.
|
9
7
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
8
|
|
11
|
-
RSpec.configure do |config|
|
12
|
-
|
9
|
+
RSpec.configure do |config|
|
13
10
|
end
|
metadata
CHANGED
@@ -1,94 +1,116 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipchat-api
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
4
5
|
prerelease:
|
5
|
-
version: 1.0.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- David Czarnecki
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: httparty
|
17
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rspec
|
28
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
25
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: fakeweb
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: bundler
|
39
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
41
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mocha
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
45
54
|
type: :development
|
46
55
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
|
49
|
-
|
50
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
51
65
|
none: false
|
52
|
-
requirements:
|
66
|
+
requirements:
|
53
67
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.7.0
|
56
70
|
type: :development
|
57
71
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: rcov
|
61
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
62
73
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.7.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
67
86
|
type: :development
|
68
87
|
prerelease: false
|
69
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
70
94
|
description: Ruby gem for interacting with HipChat
|
71
|
-
email:
|
95
|
+
email:
|
96
|
+
- czarneckid@acm.org
|
72
97
|
executables: []
|
73
|
-
|
74
98
|
extensions: []
|
75
|
-
|
76
|
-
|
77
|
-
- LICENSE.txt
|
78
|
-
- README.md
|
79
|
-
files:
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
80
101
|
- .document
|
102
|
+
- .gitignore
|
81
103
|
- .rspec
|
82
104
|
- .rvmrc
|
83
105
|
- .travis.yml
|
84
|
-
-
|
106
|
+
- CHANGELOG.md
|
85
107
|
- Gemfile
|
86
108
|
- LICENSE.txt
|
87
109
|
- README.md
|
88
110
|
- Rakefile
|
89
|
-
- VERSION
|
90
111
|
- hipchat-api.gemspec
|
91
112
|
- lib/hipchat-api.rb
|
113
|
+
- lib/hipchat-api/version.rb
|
92
114
|
- spec/fakeweb/rooms_create_response.json
|
93
115
|
- spec/fakeweb/rooms_delete_response.json
|
94
116
|
- spec/fakeweb/rooms_history_response.json
|
@@ -103,34 +125,46 @@ files:
|
|
103
125
|
- spec/hipchat-api_spec.rb
|
104
126
|
- spec/spec_helper.rb
|
105
127
|
homepage: http://github.com/czarneckid/hipchat-api
|
106
|
-
licenses:
|
107
|
-
- MIT
|
128
|
+
licenses: []
|
108
129
|
post_install_message:
|
109
130
|
rdoc_options: []
|
110
|
-
|
111
|
-
require_paths:
|
131
|
+
require_paths:
|
112
132
|
- lib
|
113
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
134
|
none: false
|
115
|
-
requirements:
|
116
|
-
- -
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
|
119
|
-
segments:
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
segments:
|
120
140
|
- 0
|
121
|
-
|
122
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
hash: 63267852503552239
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
143
|
none: false
|
124
|
-
requirements:
|
125
|
-
- -
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version:
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
hash: 63267852503552239
|
128
151
|
requirements: []
|
129
|
-
|
130
|
-
|
131
|
-
rubygems_version: 1.8.8
|
152
|
+
rubyforge_project: hipchat-api
|
153
|
+
rubygems_version: 1.8.23
|
132
154
|
signing_key:
|
133
155
|
specification_version: 3
|
134
156
|
summary: Ruby gem for interacting with HipChat
|
135
|
-
test_files:
|
136
|
-
|
157
|
+
test_files:
|
158
|
+
- spec/fakeweb/rooms_create_response.json
|
159
|
+
- spec/fakeweb/rooms_delete_response.json
|
160
|
+
- spec/fakeweb/rooms_history_response.json
|
161
|
+
- spec/fakeweb/rooms_list_response.json
|
162
|
+
- spec/fakeweb/rooms_message_response.json
|
163
|
+
- spec/fakeweb/rooms_show_response.json
|
164
|
+
- spec/fakeweb/users_create_response.json
|
165
|
+
- spec/fakeweb/users_delete_response.json
|
166
|
+
- spec/fakeweb/users_list_response.json
|
167
|
+
- spec/fakeweb/users_show_response.json
|
168
|
+
- spec/fakeweb/users_update_response.json
|
169
|
+
- spec/hipchat-api_spec.rb
|
170
|
+
- spec/spec_helper.rb
|
data/CHANGLOG.markdown
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.2
|